According to the documentation here:
https://developers.arcgis.com/rest/services-reference/query-feature-service-layer-.htm
There's a parameter, returnCentroid. According to the documentation Notes:
Note:
The layer metadata returns supportsReturningGeometryCentroid in the advancedQueryCapabilities metadata object. The absence of the supportsReturningGeometryCentroid property means that the server does not support the returnCentroid parameter. Line and point data will return supportReturningGeometryCentroid as false.
Question: I'm trying to figure out how to make the server support the returnCentroid parameter, because in our case, the supportsReturningGeometryCentroid property does not exist. FYI: We're on 10.8 so I know this is supposed to be supported in our version.
Solved! Go to Solution.
so re-reading the documentation on this. Turns out it's not possible on my linear data... ugh..
Used to return the geometry centroid associated with each feature returned. If true, the result includes the geometry centroid. The default is false. Currently, this parameter is not supported for polygon data and is ignored for count and objectID queries. This parameter is only supported on layer-level queries.
The layer metadata returns supportsReturningGeometryCentroid in the advancedQueryCapabilities metadata object. The absence of the supportsReturningGeometryCentroid property means that the server does not support the returnCentroid parameter. Line and point data will return supportReturningGeometryCentroid as false.
The underlying service in question was published from the ArcMap engine, not ArcGIS PRO (if that matters).
That property would be contained within the larger advancedQueryCapabilities:
"advancedQueryCapabilities": {
"supportsPagination": true,
"supportsQueryWithDistance": true,
"supportsReturningQueryExtent": true,
"supportsStatistics": true,
"supportsOrderBy": true,
"supportsDistinct": true,
"supportsQueryWithResultType": true,
"supportsSqlExpression": true,
"supportsReturningGeometryCentroid": true
}
Do you see anything in that object?
What is the data source you're querying? Is it hosted, or a registered service on a server?
Thanks for the response. Data is hosted in a File Geodatabase on a back-end File system that is registered with a stand-alone (not federated) ArcGIS Server v10.8.1
Hm. I wonder if that's somehow related. I don't have experience with using file-based resources through a server, so I don't even have any layers to test this with.
Can you use the returnCentroid capability with other layers that are either Hosted Feature Layers or published from an Enterprise Geodatabase?
Thanks for the response Josh. I think I may have figured it out. I think(???) it ONLY works on Feature Services. Not on Map Services. I didn't even think of that as I just assumed all queries work on Map Services. I'm not sure if this would be a bug in the REST-based functionality, or it's as intended? I'm testing my theory today. Thanks.
Oh, that sounds like it would be the issue. There are a number of things that just don't see, to work the same against a map service vs a feature service. Post back how your test goes, I'm curious to hear!
OK, that was it. You have to setup the service as a "FeatureService" with Query capabilities turned on. Then, it looks like you can return the centroids. is it a Bug or a Feature??
A feature, I believe.
Though I'm of the mindset that anyone who wants my data should be able to get at it as easily as possible, I know there are situations in which tighter control over data access would be desirable.
so re-reading the documentation on this. Turns out it's not possible on my linear data... ugh..
Used to return the geometry centroid associated with each feature returned. If true, the result includes the geometry centroid. The default is false. Currently, this parameter is not supported for polygon data and is ignored for count and objectID queries. This parameter is only supported on layer-level queries.
The layer metadata returns supportsReturningGeometryCentroid in the advancedQueryCapabilities metadata object. The absence of the supportsReturningGeometryCentroid property means that the server does not support the returnCentroid parameter. Line and point data will return supportReturningGeometryCentroid as false.