Skip to content

Instantly share code, notes, and snippets.

@jhpoelen
Last active August 29, 2015 14:23
Show Gist options
  • Save jhpoelen/955e9d01145e1f202428 to your computer and use it in GitHub Desktop.
Save jhpoelen/955e9d01145e1f202428 to your computer and use it in GitHub Desktop.
GBIF download script - requests archive that includes all of GBIF spatial records without (spatial) issues.
{
"creator":"jhpoelen",
"notification_address": ["jhpoelen+gbif@gmail.com"],
"predicate":
{
"type":"and",
"predicates": [
{"type":"equals","key":"HAS_GEOSPATIAL_ISSUE","value":"false"},
{"type":"equals","key":"HAS_COORDINATE","value":"true"}
]
}
}
# Sample script to request occurrence downloads from GBIF
# see http://www.gbif.org/developer/occurrence
if [ ! $# -eq 3 ]
then
echo "usage: gbif_download [username] [password] [filter filename]"
exit
fi
USER=$1
PASSWORD=$2
FILTER_JSON=$3
curl -i --user $USER:$PASSWORD -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d @$FILTER_JSON http://api.gbif.org/v1/occurrence/download/request
# Sample script to check the status of occurrence downloads from GBIF
# see http://www.gbif.org/developer/occurrence
if [ ! $# -eq 2 ]
then
echo "usage: gbif_download [username] [password]"
exit
fi
USER=$1
PASSWORD=$2
curl -i --user $USER:$PASSWORD -H "Content-Type: application/json" -H "Accept: application/json" http://api.gbif.org/v1/occurrence/download/user/$USER
{
"offset": 0,
"limit": 20,
"endOfRecords": true,
"count": 5,
"results": [
{
"key": "0000381-150615163101818",
"doi": "doi:10.15468/dl.izel5b",
"request": {
"predicate": {
"type": "and",
"predicates": [
{
"type": "equals",
"key": "HAS_GEOSPATIAL_ISSUE",
"value": "false"
},
{
"type": "equals",
"key": "HAS_COORDINATE",
"value": "true"
}
]
},
"creator": "jhpoelen",
"format": "DWCA",
"notificationAddresses": [
"jhpoelen+gbif@gmail.com"
],
"sendNotification": false
},
"created": "2015-06-16T16:09:01.737+0000",
"modified": "2015-06-16T17:56:29.555+0000",
"status": "SUCCEEDED",
"downloadLink": "http://api.gbif.org/v1/occurrence/download/request/0000381-150615163101818.zip",
"size": 76382210827,
"totalRecords": 470818956,
"numberDatasets": 11758
},
{
"key": "0007639-141024112412452",
"request": {
"creator": "jhpoelen",
"format": "DWCA",
"notificationAddresses": [
"jhpoelen@xs4all.nl"
],
"sendNotification": true
},
"created": "2014-11-21T22:56:20.081+0000",
"modified": "2014-11-21T22:56:53.419+0000",
"status": "CANCELLED",
"downloadLink": "http://api.gbif.org/v1/occurrence/download/request/0007639-141024112412452.zip",
"size": 0,
"totalRecords": 517325594,
"numberDatasets": 0
},
{
"key": "0007609-141024112412452",
"request": {
"creator": "jhpoelen",
"format": "DWCA",
"notificationAddresses": [
"jhpoelen@xs4all.nl"
],
"sendNotification": true
},
"created": "2014-11-21T21:04:59.352+0000",
"modified": "2014-11-21T23:57:34.156+0000",
"status": "SUCCEEDED",
"downloadLink": "http://api.gbif.org/v1/occurrence/download/request/0007609-141024112412452.zip",
"size": 80999381097,
"totalRecords": 517325594,
"numberDatasets": 12596
},
{
"key": "0001155-140711145354668",
"request": {
"creator": "jhpoelen",
"format": "DWCA",
"notificationAddresses": [
"jhpoelen@xs4all.nl"
],
"sendNotification": false
},
"created": "2014-07-19T15:01:35.726+0000",
"modified": "2014-07-19T23:11:20.460+0000",
"status": "SUCCEEDED",
"downloadLink": "http://api.gbif.org/v1/occurrence/download/request/0001155-140711145354668.zip",
"size": 41308707727,
"totalRecords": 447514771,
"numberDatasets": 12449
},
{
"key": "0001094-140711145354668",
"request": {
"predicate": {
"type": "equals",
"key": "TAXON_KEY",
"value": "2440447"
},
"creator": "jhpoelen",
"format": "DWCA",
"notificationAddresses": [
"jhpoelen@xs4all.nl"
],
"sendNotification": false
},
"created": "2014-07-18T19:56:13.260+0000",
"modified": "2014-07-18T19:58:32.312+0000",
"status": "SUCCEEDED",
"downloadLink": "http://api.gbif.org/v1/occurrence/download/request/0001094-140711145354668.zip",
"size": 4769479,
"totalRecords": 29505,
"numberDatasets": 121
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment