Comments (11)
Thanks for your question. I don't know how to convert the data to lat/long values. We do this in the R package rgbif, through the protolite pkg here https://github.com/jeroen/protolite/blob/master/R/mvt.R - i'll ask some folks if they know how to do this in python
from pygbif.
I do think https://github.com/mapbox/mercantile or https://github.com/tilezen/mapbox-vector-tile#decoding could be useful, but haven't tried this myself.
from pygbif.
thanks @stijnvanhoey
he is already using mapbox_vector_tile.decode
above - but it returns tile coordinates, what he wants is the lat/long coords.
mercantile might be useful here
from pygbif.
I use one option to fix it, then is to apply the function
plt.hexbin(x,y,cmap=color_map,edgecolors='k',extent=(-81.735793,-66.870391,-4.250167,13.394803), gridsize=bins,mincnt=1)
,
where x and y are longitude and latitude, make this plot:
If you wanna see how I make this, I give you a notebook link for you:
https://colab.research.google.com/drive/16FPv6Ko3qFUqAyAaXO-aBHHJ57aDjy72
However, i see than my request is incomplete, because when I use: occurrences.count(taxonKey=7707728, country='CO')
This return value of 2105267 registers, but when I call a quest like this:
occurrences.search(phylumKey= 7707728, country='CO', limit=2e6)
only get 300 datapoints..... anyone knows how can I get all the occurrences for my query?
from pygbif.
the answer for the pagination is that GBIF allows 300 records per request. in rgbif
we handle that pagination internally for the user, but here we don't. python tends to be a more technical set of users, so didn't do pagination for the user here. there's probably a better way to do it, but here's one way:
from pygbif import occurrences
def gbif_search():
limit = 300
offset = 0
endOfRecords = False
out = []
while not endOfRecords:
x = occurrences.search(taxonKey = 9206251, country='MX',
limit=limit, offset=offset)
endOfRecords = x['endOfRecords']
offset = sum([len(z['results']) for z in out]) + len(x["results"])
out.append(x)
return out
x = gbif_search()
sum([len(z['results']) for z in x])
from pygbif.
I'll have a look at the notebook
from pygbif.
I used your code and only change this part for my propose:
x = occurrences.search(taxonKey=7707728, country='CO', limit=limit, offset=offset)
But I get the next error:
HTTPError: 400 Client Error: Bad Request for url: https://api.gbif.org/v1/occurrence/search?taxonKey=7707728&country=CO&limit=300&offset=199800
This error is the same when I try to get all occurrences with a for loop.
from pygbif.
Sorry, didn't tell you the other information, that 200,000 is the max for offset+limit, see https://www.gbif.org/developer/occurrence - You can separate your requests into smaller bins with .search
, or you can switch to the .download
method - it's different syntax from .search, but is more flexible, and has the advantage that there's no limit on records
from pygbif.
@juanpac96 so it looks like you figured out the mapping issue - given your comment in #58 (comment) ?
from pygbif.
Yes, I finally I did it. with download requests, I get it and found the solution to my issue.
from pygbif.
Great, nice work
from pygbif.
Related Issues (20)
- Include predicates IS NULL and IS NOT NULL in the download script HOT 1
- Run integration tests against live GBIF APIs HOT 1
- Add support of in predicate HOT 1
- support the not predicate
- support dictionaries (nested queries)
- Support multiple download format
- Add examples to the documentation of newly implemented features
- Check operators and look-up tables
- add_predicate update
- Option "verbatim" in method species.name_usage throws error for specific taxon HOT 2
- Check if eventDate changes impact PyGBIF HOT 1
- Readthedocs maintainers HOT 4
- Download with taxonKey produces 401 check your number of active downloads. HOT 2
- Provide conversion utility that could create a SIMPLE_CSV format file from the more complete DWCA format download HOT 8
- ModuleNotFoundError: No module named 'requests_cache.core' HOT 10
- [DOCUMENTATION] GBIF_USER and GBIF_PWD missing but needed HOT 2
- Docs: invalid field and invalid page
- Circular Occurences?
- Lack of HTTP connection reuse makes repeated queries slow
- Update limit of characters statement for download queries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygbif.