-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trigger a download using multiple predicates #50
Comments
thanks for your question @damianooldoni @stijnvanhoey @peterdesmet you two I think did most of the download methods. Any thoughts on the above? Here's the JSON body that's sent in that example you gave: {
"creator": "<hidden>",
"notification_address": [
"<hidden>"
],
"send_notification": "true",
"created": 2019,
"predicate": {
"type": "and",
"predicates": [
{
"type": "equals",
"key": "BASIS_OF_RECORD",
"value": "OBSERVATION"
},
{
"type": "equals",
"key": "BASIS_OF_RECORD",
"value": "LITERATURE"
},
{
"type": "equals",
"key": "BASIS_OF_RECORD",
"value": "PRESERVED_SPECIMEN"
},
{
"type": "equals",
"key": "BASIS_OF_RECORD",
"value": "MATERIAL_SAMPLE"
},
{
"type": "equals",
"key": "BASIS_OF_RECORD",
"value": "UNKNOWN"
},
{
"type": "equals",
"key": "BASIS_OF_RECORD",
"value": "HUMAN_OBSERVATION"
},
{
"type": "equals",
"key": "COUNTRY",
"value": "BE"
},
{
"type": "greaterThanOrEquals",
"key": "YEAR",
"value": "1000"
},
{
"type": "lessThanOrEquals",
"key": "YEAR",
"value": "2019"
},
{
"type": "equals",
"key": "HAS_COORDINATE",
"value": "TRUE"
}
]
}
} does that look as expected? |
any thoughts @stijnvanhoey @peterdesmet ? |
The current
So, it is more a matter of missing documentation... |
the
and these are combined with the
@damianooldoni can you have a check if this is correct and similar to the rgbif request? |
@damianooldoni any time to take a look at question from @stijnvanhoey ? if not, i'll take a look |
yes, @sckott . Actually It totally slipped my mind. countries <- c("BE", "NL")
basis_of_record <- c("HUMAN_OBSERVATION", "LITERATURE")
year_begin <- 1990
year_end <- 1991
rgbif::occ_download(
paste0("basisOfRecord = ", paste(basis_of_record, collapse = ",")),
paste0("country = ", paste(countries, collapse = ",")),
paste0("hasCoordinate = TRUE"),
paste0("year >= ", year_begin),
paste0("year <= ", year_end)
) which results in following API query:
This has same structure of the query posted by @stijnvanhoey: only the order changes ( I will double check the solution provided by @stijnvanhoey and if it works this issue can be closed. |
As the result is the same, we should improve the documentation of pygbif to make sure this use case is explained to other users as well. Or we could improve the documentation by providing an explanation of the object oriented way of using pygbif more in general? |
+1 to improving docs/adding examples |
I test is again to be completely sure. Yes, documentation should be improved as well. I can give a try. |
I found that this doesn't work: gbif_query = GbifDownload(xxxxxxx, xxxxxxxxx) # user name and pwd
gbif_query.add_iterative_predicate('basisOfRecord', ['LITERATURE', 'HUMAN_OBSERVATION'])
gbif_query.add_iterative_predicate('taxonKey', [1898286, 1894840])
gbif_query.add_predicate('hasCoordinate', 'TRUE', predicate_type='equals')
gbif_query.post_download(xxxxxxx, xxxxxxxxx) # user name and pwd while this works:
This means that the parameters of the shortcut function This has to be documented as well or, even better I think, should be changed. Converting keys automatically (as in |
converting for the user makes sense, what do you think @stijnvanhoey ? |
I'm sorry, I agree that using the Darwin-core terms make much more sense for the user. I would refactor the input of it before updating the documentation. |
thanks @stijnvanhoey - agree we should refactor. Does one of you have time for this? or should I put it on my to do list? |
I won't be able to do it the coming weeks, so it would rather be November that I can contribute on this. Currently too busy on remake of pandas documentation ;-) |
ok, thanks @stijnvanhoey - pandas docs sounds fun and impt. I'll probably take a crack at it, but will make sure you two have a look at it |
Thanks @sckott . Just back from two weeks holidays and I don't see time to do it even. Still, available for review. So, ping me if needed. |
+1 for adding this to the docs. I had to search through the issues to find this info. |
duplicate of #104 |
I would like to trigger a download based on a query structured as follows (just an example):
If I try something like this:
I get a valid but empty
occurrence.txt
file because observations cannot have multiple values ofbasisOfRecords
. This is clearly a query with multiple levels of predicates involved: an OR withinbasisOfRecord
values and a general AND for all query keys.Via
rgbif
R package I can do it easily. Here below an example with taxon keys and countries in vectors where values are comma separated:Unfortunately, I cannot pass multiple values in this way to pygbif. I am quite new to pygbif, so probably I miss something. However, I didn't find any example in documentation tackling such situations.
Python version:
3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 18:50:55) [MSC v.1915 64 bit (AMD64)]
pygbif version:
Any help is welcome. Thanks.
The text was updated successfully, but these errors were encountered: