ArcGIS GeoAccessor Overlay Erase

938
11
03-13-2022 03:55 PM
TylerT
by
Occasional Contributor III

I have two SEDFs.  df_w has 3 polygons.  df_h has 2 polygons both within one of the df_w polygons.  Ultimately I need to cut holes in df_w with the df_h polygon.  The subject method is throwing an error.  I’m missing something about the functionality of the GeoAccessor overlay although it seems straightforward.  Anyway, any insight into the issue would be appreciated.  Thank you.  Tyler

holes_documentation.JPG

Polygons Visualized:

holes1.JPG

Method and Error:

holes_overlay_method.JPGholes_index_error.JPG

0 Kudos
11 Replies
DavidAnderson_1701
Occasional Contributor

This worked for me

`temp_df.spatial.overlay(temp_df_2,'erase')`

It appears the overlay function is not set up with key word arguments.

0 Kudos
TylerT
by
Occasional Contributor III

@DavidAnderson_1701 

hmm.  Removing the 'op=' did not do the trick.  Same result.  Would you mind posting a screenshot of your dataframes with the index in view.  I'm curious to how many features you have and if they share indices.  I am sensing overlay is trying to match index to index (from df1 to df2), but  not sure.  

Alternatively, try it with dataframes of different sizes, and different indices.  The reason I'm wondering is because when I run op='union' I get this error.
holes_index_union_error.JPG

Thank you. 

Tyler

0 Kudos
TylerT
by
Occasional Contributor III

@DavidAnderson_1701, circling back to see if you have screen shots for your jupiter lab notebook dataframe outputs.  Thx.  Tyler

0 Kudos
DavidAnderson_1701
Occasional Contributor

DavidAnderson_1701_0-1647465822585.png

DavidAnderson_1701_1-1647465916821.png

 

DavidAnderson_1701_2-1647465939597.png

Do the same process for df_h

then

DavidAnderson_1701_3-1647466023463.png

 which yields

DavidAnderson_1701_4-1647466047895.png

 

Short story is it worked for me.   Perhaps try recreating the spatial data frames.

 

 

0 Kudos
TylerT
by
Occasional Contributor III

@DavidAnderson_1701 Interesting.  Should the two holes be white?  What you have shown looks like the holes over the top of the second larger feature.  At least you didn't get errors like I got.  Let me study this and work on my SEDFs. 

Much appreciated.

Tyler

0 Kudos
DavidAnderson_1701
Occasional Contributor

Probably something to do with how I'm displaying the data.  I wrestled with how to get the dataframe to show the geometry.

The area values show that the erase did happen.

Not a very satisfying answer I know.  Saying it worked for me is an old programmer excuse/cop out.  You might double check that the dataframe geometries are indeed polygons using the spatial.area property.

Start a clean Jupyter project, try the code I show to see if that works. Isolate the problem code to just this little bit.

 

DavidAnderson_1701_0-1647467546464.png

DavidAnderson_1701_1-1647467565572.png

 

 

0 Kudos
TylerT
by
Occasional Contributor III

To display try: 

df.spatial

Example.

TylerT_0-1647468312573.png

I'll keep wrestling with it, but I'm still getting a positional index error.

Thanks for helping.

Tyler

 

0 Kudos
DavidAnderson_1701
Occasional Contributor

Could you post the full traceback stack text.  It might be informative to see exactly which module is throwing the error.  Is it a Python function?  Pandas?  Arcgis API?

 

0 Kudos
TylerT
by
Occasional Contributor III

@DavidAnderson_1701, I finally made SOME progress.  I switched machines and lo and behold, it worked.  No error.  Original machine has ArcGIS Pro 2.8.3 and the new machine has 2.9.1.  I'm wondering if there's a python module bug.  Do arcgis/arcpy modules get updated when ArcGIS Pro gets updated?   Thanks for all your help troubleshooting.  I'll try updating ArcGIS Pro and see what happens.

Side note: Jupyter displays holes oddly.  They look more like feature over feature, so I checked in ArcGIS Pro and the output feature looks just fine.

Jupyter output feature with holes:

jupyter_holes.jpg

Same SEDF exported to gdb fc and displayed in ArcGIS Pro:

arcgis_pro_holes.jpg

Cheers,

Tyler

0 Kudos