Add species count to UTFGrid data responses

I’m a member of my local chapter of the California Native Plant Society and am looking into creating a Plant Atlas for our county (kind of like San Diego has).

The idea of a plant atlas is to show areas with less species diversity and encourage folks to go out and increase coverage in those areas. I have a mockup of an atlas that looks like this:

This shows native plant observation density using the iNaturalist grid tile service: https://tiles.inaturalist.org/v1/grid/{z}/{x}/{y}.png?verifiable=true&place_id=962&project_id=calflora-native-plants-of-california&style=geotilegrid&tile_size=256

I would love to be able to also show how many species are in each black box, on a live map as users zoom in and out. The black boxes are zoom level 12 XYZ tiles, so a request for one box’s UTFGrid data would be https://tiles.inaturalist.org/v1/points/12/701/1634.grid.json?verifiable=true&place_id=962&project_id=calflora-native-plants-of-california&style=geotilegrid&tile_size=256&quality_grade=research,

which returns a list of observations that look like this today:

My feature request is for this response to include speciesCount: 234 in the response for the tile, maybe as an X-header if it’s requested via ?speciesCount=true or in the JSON response as a new property. As far as I am aware there is no other way to do this for live observations, unless I do hundreds of observations requests with bounding boxes for each black rectangle, which would quickly exceed API limits. Even if a taxonId: 53359 was returned for each observation, from what I can tell, UTFGrid tiles don’t return all the observations in a given tile, they cap at around 500 for a 256x256 tile (correct me if I’m wrong).

the results in a UTFGrid are cells, not observations. each cell can provide the latest observation (or other first observation, depending on sort). so if each observation existed within its own cell, you could get up to 32x32=1024 unique observations in a grid-styled iNat UTFGrid.

(technically, the iNat UTFGrids return 64x64 cells, but the the grid-style tiles represent data in a 32x32 grid. getting the bottom-right cell from each 2x2 block is the right way to parse stuff for data purposes.)

you can look at https://jumear.github.io/stirfry/iNat_UTFGrid_data_interpreter, which might help you to visualize the results of a UTFGrid a bit more easily.

it might be interesting to see a cellSpeciesCount along with each cellCount, but i suspect it would be of limited usefulness and would take a relatively large amount of processing power to get such information.

it might also be worth pointing out that the cells in a UTFGrid are not equal area in terms of square meters. so although you can use them to sort of visualize density, as iNaturalist does in its own maps and as i do in my own custom UTFGrid-based visualizations, i probably wouldn’t use them as the basis for any serious data anaylsis.

2 Likes