Select to view content in your preferred language

Invalid geometry in GPKG cannot be fixed, can't be copied to different format?

274
2
3 weeks ago
AlfredBaldenweck
MVP Regular Contributor

Hi all,

I have a geopackage containing a few feature classes I'm trying to copy to a file geodatabase. 

These are failing using Copy(), CopyFeatures(), and ExportFeatures().

It appears that this is because of one or more geometry errors; although I can pull the given table into my map and browse it, trying to scroll through gives me a "Shape Integrity Error".

Running CheckGeometry() gives me 306 errors, 15 of which are "Shape has a structural error! (-1) Operation Failed".

Running RepairGeometry() fails with 

ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.

So. How can I fix this?

0 Kudos
2 Replies
RTPL_AU
Honored Contributor

@AlfredBaldenweck 
It may be the easiest to just fix in QGIS.
The geometry checking tool gives outputs that show you where issues are or at least which geometry has the issues rather than just listing a object's ID.

You can also try to do the gpkg to fgdb in QGIS itself as a first step. Sometimes there is nothing to fix (from a QGIS perspective) and it is just an outlier capability used by the data creator that doesn't play nice with Pro.

EDIT:
Make sure to install the full FGDB library in QGIS.

On the flipside - many of the handy editing tools in QGIS are plugins not included in the default install.
New users don't know that and try to get by with the stock tools so I've also seen some pretty mangled geometry come out of it that no auto tool would have a chance at fixing. 
You then just have to sit down and fix/edit them in QGIS (hoping all shapes show up) before trying to export again; or bump it back to the data custodian/source to fix.

AlfredBaldenweck
MVP Regular Contributor

Well, I spun up Q and ran check geometry and it did indeed give me the errors, which is cool, but no built-in way to repair...

I gave converting in Q a shot and, to its credit, the output feature class in the new fGDB did load no problem. That being said, there are now 429 geometry errors and it seems 100 of the records were just exported with null geometry to prevent them breaking everything. 

 

Given that ogr2ogr is now removed and I have to rewrite my stuff to use gdal.VectorTranslate(), I'm going to leave this thread open while I experiment and see if that changes things. I think no matter what, I'll end up with features with bad geometry, but the main thing for me is making sure that I can get them converted in the first place.

Thanks

 

0 Kudos