Wraps idig_search
to provide defaults specific to searching
specimen records. Using this function instead of idig_search
directly is recommened.
Queries need to be specified as a nested list structure that will serialize
to an iDigBio query object's JSON as expected by the iDigBio API:
https://github.com/iDigBio/idigbio-search-api/wiki/Query-Format
As an example, the first sample query looks like this in JSON in the API
documentation:
{
"scientificname": {
"type": "exists"
},
"family": "asteraceae"
}
To rewrite this in R for use as the rq parameter to
idig_search_records
or idig_search_media
, it would look like
this:
rq <- list("scientificname"=list("type"="exists"),
"family"="asteraceae"
)
An example of a more complex JSON query with nested structures:
{
"geopoint": {
"type": "geo_bounding_box",
"top_left": {
"lat": 19.23,
"lon": -130
},
"bottom_right": {
"lat": -45.1119,
"lon": 179.99999
}
}
}
To rewrite this in R for use as the rq parameter, use nested calls to the
list() function:
rq <- list(geopoint=list(
type="geo_bounding_box",
top_left=list(lat=19.23, lon=-130),
bottom_right=list(lat=-45.1119, lon= 179.99999)
)
)
See the Examples section below for more samples of simpler and more complex
queries. Please refer to the API documentation for the full functionality
availible in queries.
All matching results are returned up to the max_items cap (default 100,000).
If more results are wanted, a higher max_items can be passed as an option.
This API loads records 5,000 at a time using HTTP so performance with large
sets of data is not very good. Expect result sets over 50,000 records to
take tens of minutes. You can use the idig_count_records
or
idig_count_media
functions to find out how many records a
query will return; these are fast.
The iDigBio API will only return 5,000 records at a time but this function
will automatically page through the results and return them all. Limit
and offset are availible if manual paging of results is needed though the
max_items cap still applies. The item count comes from the results header
not the count of actual records in the limit/offset window.
Return is a data.frame containing the requested fields (or the default
fields). The columns in the data frame are untyped and no factors are pre-
built. Attribution and other metadata is attached to the dataframe in the
data.frame's attributes. (I.e. attributes(df)
)