Select to view content in your preferred language

Does a GeoAccessor (SEDF) spatial join require arcpy?

04-27-2022 10:07 AM
Regular Contributor

I am using an conda environment with version 2.0.0 of the Python API installed, but not arcpy.  This is running on a JupyterHub deployment.

I am trying to do a spatial join of two SEDFs (point and polygons) by running the line:


points.spatial.join(polygons[['SHAPE']], how="left", op="intersects")


Unfortunately, get no positive intersections (the length of the output is the same as the points SEDF, and the index_right field is all NaN). 

If I run the exact same code on the same datasets in my ArcGIS Pro environment (arcpy is present) , using the same version of the Python API (2.0.0), I get a different result, the result I would expect (i.e. some points intersect the polygons). 

There is nothing in the API documentation saying the spatial join requires arcpy, so I am wondering if something else could be wrong with the JuypterHub environment, or is the documentation incorrect. 

Can anyone help verify?

0 Kudos
3 Replies
Occasional Contributor
from arcgis.features import GeoAccessor
import geopandas as gpd
import pandas as pd

gdf_pts = gpd.read_file(r'C:\temp\point.shp')
sdf_pts = pd.DataFrame.spatial.from_geodataframe(gdf_pts)

gdf_poly = gpd.read_file(r'C:\temp\polygon.shp')
sdf_poly = pd.DataFrame.spatial.from_geodataframe(gdf_poly )

sdf_pts.spatial.join(sdf_poly[['SHAPE']], how="left", op="intersects")

This seemed to work fine for me in jupyter notebooks, are your points and polys in the same projection? have you tried other featureclasses, shapefiles, etc?

0 Kudos
Regular Contributor

yes, everything is in the same projection - however I also do not have geopandas (and hence shapely) installed in the environment.  Just the ArcGIS Python API.  So possibly either shapely OR arcpy is required for intersections to work? 

0 Kudos
New Contributor III

Hi -
I'm currently encountering a similar problem and was wondering if you ever came up with a solution to your issue.


0 Kudos