Spatially Enabled Dataframe join not producing results

474
2
05-08-2024 10:25 AM
mistersig_cc
Emerging Contributor

I have a notebook server that has arcgis for python installed, version 1.9.1. I have a separate server and a local environment using the version of arcgis for python, version=2.1.0.4 & 2.2.0.2.

 

For some read I cannot get the spatial join to work. 

I have two layers one layer is coming from a feature service and the other returned from a batch geocoder.

The municipal layer I'm using FeatureLayer to grab it then using  pd.DataFrame.spatial.from_layer to turn it into a spatial dataframe. The second is from a batch geocoder that gets returned to as a featureset then transformed to sdf through one of the methods. I then try to go a spatial join but it doesn't return full matches only partial ones. 

The municipal layer is a mix of polygons and multi-polygons. The geocoded addresses are points. I have no clue why it's working on the older version of arcgis for python but not on the new one. In the code snippet below I have swapped out the muni_sdf and the geocode_results_sdf as the method caller and input with no real change in results. 

 

#batch geocoded addresses 
results_featureset = batch_geocode(address_list, geocoder=our_geocoder, location_type='rooftop', match_out_of_range = False, out_sr= 3435, as_featureset=True)

geocode_results_sdf = geocode_results.sdf

#muni layer 
municipality = 'layer url'
municipality_feat = FeatureLayer(municipality)
muni_sdf = pd.DataFrame.spatial.from_layer(municipality_feat)

spatial_relationship = 'within'  # Change spatial relationship to 'within' or 'intersect' with no change in results 
joined_sdf = muni_sdf.spatial.join(geocode_results_sdf , how="inner", op=spatial_relationship)

print(joined_sdf)  

 

 

 

0 Kudos
2 Replies
JohnEvans6
Regular Contributor

If you plop both spatial data frames on a map widget does the data look correct? Hard to do much without seeing the actual data.

0 Kudos
mistersig_cc
Emerging Contributor

I'm developing the main app outside of a notebook or pro. I'm using the notebook only to test to check my work so, in a sense yes it's correct in the notebook because it's the same code I'm using for the app I'm building. 

0 Kudos