Custom markers to show tree health?

In an iNat project devoted to Western Hemlock decline and mortality, in a 100-acre forest, I wish to indicate both tree health status and DBH via color and size of map markers.

Here is an example of how I do this in leaflet:


My iNat project page currently looks like this:

suggesting that somehow (here, inadvertently) some control over markers is avaialble.

Any suggestions? Tutorials for me to read?

Thank you.

what you’re seeing in your second image is effectively 2 sets of markers rendered 2 different ways. the red markers are delivered from iNat’s servers as tiled images via iNaturalist’s API. the green markers are being rendered by the map itself using coordinates from observation data delivered from iNat. (probably that green set represents the n=30? most recently submitted observations in your project, while the red set should be all observations in the project, assuming they are mappable.)

if you want to create a map like what’s shown in your first image above, you need to start with a set of data that includes coordinates + health status + DBH. if the map can be static, then the easiest way to get that data is via iNaturalist’s standard CSV export. once you have that data, you can use just about any mapping tool to create the map as you like.

if the map needs to be dynamic, displaying new markers as you add new observations in iNaturalist to represent new trees, then you’ll need a way to get your dataset programmatically. since your example is hosted on shinyapps.io, i’ll assume that you’re familiar with R and that that would be your first choice of language to programmatically get your dataset.

the required data will come from iNaturalist API’s /v1/observations endpoint. each GET request from v1/observation can return up to 200 observations. so if your dataset won’t exceed 200 observations, then 1 request should be enough. otherwise, you’ll need to do some sort looping or iteration to get the whole dataset. (note that the iNat API isn’t really designed to give you more than 10,000 observations. so if you need to map more than 10,000 observations for some reason, then you probably need to do it some other way.)

there are lots of ways to get data via the API using R. if you already know what to do here, then great. there are also lots of discussions in the forum about getting data via R. for example: https://forum.inaturalist.org/t/using-r-to-extract-observations-of-a-specific-phenological-state/7007 and https://forum.inaturalist.org/t/inaturalist-visualization-what-introduced-species-are-in-my-place/12889. if you need more help, then say so, and i or someone else can provide more help here.

anyway, once you have your dataset, then just get the values that correspond to coordinates + tree health + DBH, and i assume you’ll be able to plop that in your existing R code to generate a map similar to your example.

not sure if it’ll be directly helpful here for your use case, but back in the day, i wrote a tutorial that describes mapping using the tiled markers: https://forum.inaturalist.org/t/in-pursuit-of-mappiness-part-1/21864. i’ve been meaning to write a follow-up tutorial about other ways of mapping, but i haven’t gotten there yet.

2 Likes

Thanks, @pisum. I guess my question was not clear, or - equally plausible - I do not quite understand your thoughtful reply. Thank you for taking the time to answer and offer suggestions.

My question: can I control marker shape, color, size within the iNaturalist map, so that when anyone visits https://www.inaturalist.org/projects/seward-park-western-hemlock-study they can see, in the default, iNat-hosted view, DBH and tree health as with the shiny leaflet app I put together?

A separate question: I’m afraid I don’t yet understand what I did that creates both red and green markers. All the markers were specified in the same upload of a single 116 line csv file.

within the project page, no. generally, no.

it’s possible to specify the color of the API tiles, but the color would apply to the whole set of observations, not for individual markers in the same set based on some variable. there’s no standard functionality designed to allow you to change the size of the markers in API tiles. you could do some sneaky things to change the size of the markers in the API tiles (so that different sets could have different sized markers), but the marker size would be the same within the same set, and it would be convoluted and imprecise procedure and probably not worth the effort.

the red and green are 2 different layers. the way they’re being delivered / rendered is completely different. you didn’t do anything to cause the page to display the two different layers. i just think that’s how the page displays observations.

traditional projects are sort of an old concept, and i think the design of the traditional project pages is relatively old. the green markers are probably how the page originally rendered observations on the map, but that way of rendering observations doesn’t scale very well (when you have a lot of observations). so probably at a later date, as number of observations exploded, they realized they needed a more scalable way to map observations. so they added the red markers. but they never removed the green markers for whatever reason. so that’s why you see the mix of the 2 different kinds of markers.

1 Like

Thanks, @pisum, for all that you explain here!

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.