I'm attempting to pull a json response of Point records that fall within an arbitrarily defined polygon from an ArcGIS REST endpoint (MapServer). The endpoint supports JSON response and querying. Everything is in EPSG 4326, nothing weird.
I'm trying to query it by esriGeometryPolygon.
It is a simple 4-sided polygon built clockwise. Coords are in Y,X format.
My ring looks like this:
I figure the "spatialReference" element defaults to 4326 for json though couldn't find that explicitly stated in documentation. However, adding the spatialReference property makes no difference.
I am wrapping this all in a GET call that looks like this (the server is not internet accessible so I'm making it generic):
When I go to this area on the service, there are definitely features within the polygon. However, they will not return via this query. So I figure I'm doing something wrong in structuring my request. Even on the REST querying documentation there are no examples showing how to clearly return record properties from a MapServer service based on a Polygon object.
Do you have a corresponding feature service? I don't know that spatial queries work on Map Image services. Or at least, I've not been able to do so.
I'd recommend going to the query? endpoint of the service when dealing with these. Then looking at the query being set when you press the query button, either in dev tools or the url formed.
So, I had taken coordinate pairs I was using with the esriGeometryEnvelope object (YX) and followed the same YX order with the esriGeometryPolygon.
When flipping the pairs to XY, it worked.
Not sure why that should be the case, but if different pair order for different geometry objects in the same API is a thing, I feel like someone on the QA side of the house might've missed something...
So, @jcarlson - yes it does definitely work
And thank you @DavidPike yes that is where I started on this before moving to python
Ah, good! I know that spatial filters don't work in Dashboards for whatever reason. I hardly ever use them, but good to know that spatial query parameters will still work.
Just as FYI: both map service (aka map image layer) and feature service query operations follow the same specs. That is why you can add a feature layer in your web map off a map service or a feature service. When you add a feature layer off a map service, Editing is the only capability you won't have.
here is an example of a map service query request with polygon spatial filter: