Repair Geometry in ArcPy on .shps?

657
5
06-14-2019 01:48 PM
WendyDorman
New Contributor

I'm trying to run Repair Geometries on shapefiles using ArcPy in Spyder. The tool description states that it can be run on .shps but the code provided by Esri requires you to first run Check Geometry and then Repair Geometry, and the table output from Check doesn't appear to be correct for Repair. Does anyone have ideas for code that would apply to .shps not in a .gdb?

0 Kudos
5 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Do you have an example of a check geometry that you think is not right?

And check doesn't need to be run before repair, unless you are curious

Repair Geometry—Data Management toolbox | ArcGIS Desktop 

you could also copy the shapefile to a gdb, check/repair there, then export to a shapefile if you want to ensure that the shapefile complies with esri's implementation.

WendyDorman
New Contributor

Running Check Geometry outside of a gdb doesn't produce the correct table.

This should result in a table called checkGeometryResult for the Repair Geometry tool to work through. When I run these tools in sequence in ArcPro (on .shps outside of a .gdb) if produces the same incorrect table and I cannot input it into the Repair Geometry tool. Any other ideas for how to repair the geometries but also know which ones are repaired and why? Or how to tweak this to run in a folder instead of gdb? I think this tool works great so I’d like to run this tool instead of using geopandas or Q’s function, but am having trouble with the coding for it.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

What is in the 'incorrect table'? and does your script error out or just not do anything?

0 Kudos
WendyDorman
New Contributor

It doesn't error, it thinks it worked. It makes this in a folder it generates called info:

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

That looks like an arcinfo table.  If the destination for the output table is a folder, that is what you get, if it is into a gdb, then you get a geodatabase table, otherwise, you have to add *dbf to the output filename to get a dbase table