Giter Club home page Giter Club logo

Comments (11)

sckott avatar sckott commented on May 31, 2024

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.

stijnvanhoey avatar stijnvanhoey commented on May 31, 2024

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.

sckott avatar sckott commented on May 31, 2024

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.

juanpac96 avatar juanpac96 commented on May 31, 2024

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:
image

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.

sckott avatar sckott commented on May 31, 2024

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.

sckott avatar sckott commented on May 31, 2024

I'll have a look at the notebook

from pygbif.

juanpac96 avatar juanpac96 commented on May 31, 2024

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.

sckott avatar sckott commented on May 31, 2024

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.

sckott avatar sckott commented on May 31, 2024

@juanpac96 so it looks like you figured out the mapping issue - given your comment in #58 (comment) ?

from pygbif.

juanpac96 avatar juanpac96 commented on May 31, 2024

Yes, I finally I did it. with download requests, I get it and found the solution to my issue.
image

from pygbif.

sckott avatar sckott commented on May 31, 2024

Great, nice work

from pygbif.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.