I’m aware one can query the API using a bounding box - which would effectively search a rectangular area.
But ideally I’d like to search for observations only within a custom-defined shapefile area e.g. shown below. Is this possible, if I have the shapefile ready to go? I only want the API to return observations within the enclosed areas described by the shapefile.
Making enough bounding boxes to get a somewhat precise approximation would mean a huge amount of requests. Maybe do the opposite, one singular outer bounding box then write some script to check whether an observation within that bounding box has coordinates within your shapefile?
The traditional approach to check, AFAIK, is ray-casting (trace an horizontal line going through your point then count whether the number of times it intersects your shape is even or odd). I’m fairly certain R would have libraries for this (This Stack Exchange post might fit).
Yeah, that was my first thought. If you registered this as a place, the API request would be as simple as querying by place ID. It would also be worth checking if there are one or more existing places that are similar enough to your shapefile.
For the more general case of “I have a bunch of shapefiles and want to find all the observations within them,” and it isn’t practical to register them all as iNat places, then you could download and filter observations locally.
You don’t need to manually check every observation, though; this is the the kind of task that GIS tools are made for. I think there are some guides for this in the Tutorials section with either ArcGIS or QGIS. If not, I or others here could help get you started.
Okay… I’m back. I’ve now registered the place. But it comes back with 0 observations as occuring within the bounds of the shape. This isn’t true - there are lots of observations within the bounds. I wonder if iNat can’t handle the complex enclaves, or something??
Yes, they definitely don’t get added immediately. The other thing to keep in mind is that obscured observations or observations with large uncertainty circles won’t get indexed in your place, see details here.
thanks, that’s interesting. I guess I should do a little manual comparison of all the obs I think should be included in the shape/Place, versus how many appear through the server-side iNat Place filter. It may be that I want to be less conservative than blanket excluding all obs that even only very partially break the bounding box / Place boundaries. I can appreciate how that is handled is always going to be tricky, iNat sounds like it has a sensible default setting on that - thanks for making me aware of how it is handled .