Skip to content

Commit

Permalink
Update download.py
Browse files Browse the repository at this point in the history
updated code chunk for occ.download function
  • Loading branch information
CecSve committed May 12, 2023
1 parent 7b8e3b3 commit 93b3884
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pygbif/occurrences/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def download(queries, format = "SIMPLE_CSV", user=None, pwd=None, email=None, pr
:return: A dictionary, of results
Usage:: TODO: add additional examples of more complex queries
Usage::
from pygbif import occurrences as occ
Expand All @@ -198,13 +198,13 @@ def download(queries, format = "SIMPLE_CSV", user=None, pwd=None, email=None, pr
# pass output to download_meta for more information
occ.download_meta(occ.download('decimalLatitude > 75'))
# Multiple queries
# multiple queries
gg = occ.download(['decimalLatitude >= 65',
'decimalLatitude <= -65'], pred_type ='or')
gg = occ.download(['depth = 80', 'taxonKey = 2343454'],
pred_type ='or')
# Repratriated data for Costa Rica
# repratriated data for Costa Rica
occ.download(['country = CR', 'repatriated = true'])
# turn off logging
Expand All @@ -215,10 +215,8 @@ def download(queries, format = "SIMPLE_CSV", user=None, pwd=None, email=None, pr
logger.disabled = False
w = occ.download('elevation >= 10000')
# Nested and complex queries with multiple predicates
# For more complex queries, it may be advantagous to format the query in JSON format. It must follow the predicate format described in the API documentation (https://www.gbif.org/developer/occurrence#download):
# nested and complex queries with multiple predicates
## For more complex queries, it may be advantagous to format the query in JSON format. It must follow the predicate format described in the API documentation (https://www.gbif.org/developer/occurrence#download):
query = { "type": "and",
"predicates": [
{ "type": "in",
Expand All @@ -232,11 +230,9 @@ def download(queries, format = "SIMPLE_CSV", user=None, pwd=None, email=None, pr
"values": ["RECORDED_DATE_INVALID",
"TAXON_MATCH_FUZZY",
"TAXON_MATCH_HIGHERRANK"] }} ]}
occ.download(query)
# The same query can also be applied in the occ.download function:
# The same query can also be applied in the occ.download function (including download format specified):
occ.download(['taxonKey in ["2387246", "2399391","2364604"]', 'year !Null', "issue !in ['RECORDED_DATE_INVALID', 'TAXON_MATCH_FUZZY', 'TAXON_MATCH_HIGHERRANK']"], "DWCA")
"""
Expand Down

0 comments on commit 93b3884

Please sign in to comment.