Different results returned using intersects geometry filter

461
1
01-03-2023 08:16 AM
Labels (1)
tmichael_wpjwa
New Contributor III

I have been working on an ArcGIS Notebook to count points within polygons.  A simplified example is the following:

tmichael_wpjwa_0-1672761337822.png

In this image the polygon and red dots are features in a hosted feature layer in ArcGIS Online.  The blue dots are coming from an ArcGIS Enterprise / ArcGIS Server feature service.

When I perform an intersection query for points that intersect the polygon using the hosted feature layer, I get the correct result (12).  To do this I am using the following:

 

 

feature_geom = polygon.features[0].geometry
feature_sr = polygon.features[0].geometry['spatialReference']['wkid']
polygon_filter = intersects(feature_geom, feature_sr)
svc_query = point_lyr.query(geometry_filter=polygon_filter)
print(len(svc_query))

 

 

 

However, when I perform the same query to get the number of points from ArcGIS Enterprise/ArcGIS Server within the same polygon, I get an incorrect result (10).  To do this I am using the following:

 

 

# Connect to ArcGIS Enterprise
gis2 = GIS(url=gis2_URL, username=gis2_username, password=gis2_password)

# Feature layer
water_network_url = "https://<url>/FeatureServer"
water_network_featurelayer = FeatureLayerCollection(water_network_url, gis=gis2)
water_network_layers = water_network_featurelayer.layers
service_connection = water_network_layers[0]

# Query
feature_geom = polygon.features[0].geometry
feature_sr = polygon.features[0].geometry['spatialReference']['wkid']
polygon_filter = intersects(feature_geom, feature_sr)
svc_query2 = service_connection.query(geometry_filter=polygon_filter)
print(len(svc_query2))

 

 

 

Are there any issues with how I'm referencing the ArcGIS Enterprise layer that would cause this issue?  Or is there anything else to consider that might be causing the incorrect result?

0 Kudos
1 Reply
cpeng_esri
Esri Contributor

Hi @tmichael_wpjwa Thanks for reporting this issue. We will start investigating once we have further details. Since it could be related to the inconsistence of input data, or the difference of precision/spatialRef/storage format for hosted feature layer and a service on the server. Can you please provide us the geometry json of the polygon, and the two points (red and blue) layer URL or server endpoint? You can simple type:

`print(feature_geom)` or `feature_geom.arcpy` (if you are using arcpy)

`print(point_lyr)`

`print(service_connection)` or print(service_connection.url)` depending on your version.

Looking forward to your response, thanks!

0 Kudos