[API-users] Clipping occurrence data to a country

Matthew Blissett mblissett at gbif.org
Wed Jan 9 14:22:06 CET 2019


Hi Adriaan,

Could you give an example?

Just visually, the map tile looks fine when flipping between 
https://api.gbif.org/v2/map/occurrence/density/6/65/13@2x.png?srs=EPSG:4326&bin=square&squareSize=32&taxonKey=6&style=green.poly 
and 
https://api.gbif.org/v2/map/occurrence/density/6/65/13@2x.png?srs=EPSG:4326&bin=square&squareSize=32&taxonKey=6&country=NL&style=green.poly

Zooming in one step to the top right (which is only Dutch territory) and 
comparing the vector tiles with and without the country mask:

https://api.gbif.org/v2/map/occurrence/density/7/131/26.mvt?srs=EPSG:4326&bin=square&squareSize=32&taxonKey=6

https://api.gbif.org/v2/map/occurrence/density/7/131/26.mvt?srs=EPSG:4326&bin=square&squareSize=32&taxonKey=6&country=NL

These are byte-for-byte identical.

I don't see a problem in EPSG:3575 either, e.g. with 
https://api.gbif.org/v2/map/occurrence/density/5/15/23@2x.png?srs=EPSG:3575&bin=square&squareSize=32&taxonKey=6&country=NL&style=green.poly

Note that close to borders, GBIF's processing assumes the source data is 
correct as we know our map isn't perfect. An observation in Westerwoldse 
Aa on the border of Netherlands and Germany could be accepted with 
either country=NL or country=DE, and would show accordingly if the map 
is clipped to NL or DE.


For the other approach, I don't have EPSG:3575-format vector tiles with 
country borders, but in any case it's difficult to work with vector 
tiles for any further processing — if you wanted a polygon, you'd need 
to reconstruct it from the lines which are cut off at the edges of the 
tiles. I recommend you use a different source of map data, e.g. from 
http://www.naturalearthdata.com/ . Many GIS libraries (including 
Javascript ones for display) should be able to work with that data, for 
example in GeoJSON format: 
https://github.com/nvkelso/natural-earth-vector/tree/master/geojson (if 
10m resolution is sufficient).

Cheers,

Matt Blissett

On 08/01/2019 22:19, Adriaan van Os wrote:
> I noticed that e.g. "&country=NL" limits occurrence data even within 
> the specified country. That is, for that country, I get less 
> occurrence data than without the "&country=NL"
>
> Is this caused by wrong data, by data with the wrong (or no) country 
> identifier attached ?
>
> Anyway, I now seek another solution, which is to clip the occurrence 
> data to the specified country on the map. However, how do I get map 
> data tiles with country borders ? I use EPSG:3575.
>
> Regards,
>
> Adriaan van Os
> _______________________________________________
> API-users mailing list
> API-users at lists.gbif.org
> https://lists.gbif.org/mailman/listinfo/api-users


More information about the API-users mailing list