You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, this is pretty weird, ogr2ogr is able to fix geometries, I have a file with an invalid geometry, but depending on how and what we do with it, the file can be fixed, and then it turns it back, some times there is warnings for invalid geometries and other times there is not.
Maybe here is more than issue.
Also... to trigger some warnings we need to convert two times with ogr2ogr + makevalid on the first conversion.
Something important here, doing things and converting several times and between SHP and GPKG will not trigger any warning.
The geometry is not valid.
Use makevalid still does not shows the error, but after run it shows
pipe@pipe-pc /tmp/tests $ ogr2ogr sample2.shp sample.shp -makevalid
pipe@pipe-pc /tmp/tests $ ogr2ogr sample3.shp sample2.shp
Warning 1: sample2.shp contains polygon(s) with rings with invalid winding order. Autocorrecting them, but that shapefile should be corrected using ogr2ogr for example.
The problem here is that, any conversion from sample2.shp will trigger this warning, and when is read, how GDAL already fixed something we only will see a valid geometry (I tested in R), but when we save it, and load again we still have the invalid geometry warning.
ogr2ogr sample2.gpkg sample.shp -makevalid
Warning 1: Feature id 0 not preserved
ogr2ogr sample3.gpkg sample2.gpkg
No idea what Warning 1: Feature id 0 not preserved!!
All works right? well no, transform to shp again and fill be bad again! but need to be converted at least one time:
pipe@pipe-pc /tmp/tests $ ogr2ogr sample3.shp sample3.gpkg
pipe@pipe-pc /tmp/tests $ ogr2ogr sample4.shp sample3.shp
Warning 1: sample3.shp contains polygon(s) with rings with invalid winding order. Autocorrecting them, but that shapefile should be corrected using ogr2ogr for example.
Thx!
Versions and provenance
GDAL 3.8.0, released 2023/11/06
Linux 64
Additional context
This issue is not exactly about makevalid fixing geometries, is the weird behaviors in the resultant files when we try to make them valid!
The text was updated successfully, but these errors were encountered:
Warning 1: sample2.shp contains polygon(s) with rings with invalid winding order. Autocorrecting them, but that shapefile should be corrected using ogr2ogr for example.
This was a bug that has been fixed in 3.8.1 (#8767)
No idea what Warning 1: Feature id 0 not preserved!!
The Shapefile driver starts numbering at 0, whereas the GPKG driver normally starts at 1.
The GPKG driver has been made more tolerant in 38c9e51 (master / 3.9.0dev)
@rouault Just to know, part of this issue is also the inconsistency of when was the warning print, was that fixed on #8767? Which is different from the warning it self.
What is the bug?
Hi, this is pretty weird, ogr2ogr is able to fix geometries, I have a file with an invalid geometry, but depending on how and what we do with it, the file can be fixed, and then it turns it back, some times there is warnings for invalid geometries and other times there is not.
Maybe here is more than issue.
Also... to trigger some warnings we need to convert two times with ogr2ogr + makevalid on the first conversion.
Steps to reproduce the issue
sample.zip
There will be several examples, for different weird aspects, the base is that the sample only has one geometry, and is a invalid one.
No warning on invalid geometries
GDAL tell us if a file has invalid geometries, but seems is not done if we parse this file directly:
Something important here, doing things and converting several times and between SHP and GPKG will not trigger any warning.
The geometry is not valid.
Use makevalid still does not shows the error, but after run it shows
pipe@pipe-pc /tmp/tests $ ogr2ogr sample2.shp sample.shp -makevalid pipe@pipe-pc /tmp/tests $ ogr2ogr sample3.shp sample2.shp Warning 1: sample2.shp contains polygon(s) with rings with invalid winding order. Autocorrecting them, but that shapefile should be corrected using ogr2ogr for example.
The problem here is that, any conversion from
sample2.shp
will trigger this warning, and when is read, how GDAL already fixed something we only will see a valid geometry (I tested in R), but when we save it, and load again we still have the invalid geometry warning.GPKG seems to works?
No idea what
Warning 1: Feature id 0 not preserved
!!All works right? well no, transform to shp again and fill be bad again! but need to be converted at least one time:
pipe@pipe-pc /tmp/tests $ ogr2ogr sample3.shp sample3.gpkg pipe@pipe-pc /tmp/tests $ ogr2ogr sample4.shp sample3.shp Warning 1: sample3.shp contains polygon(s) with rings with invalid winding order. Autocorrecting them, but that shapefile should be corrected using ogr2ogr for example.
Thx!
Versions and provenance
GDAL 3.8.0, released 2023/11/06
Linux 64
Additional context
This issue is not exactly about makevalid fixing geometries, is the weird behaviors in the resultant files when we try to make them valid!
The text was updated successfully, but these errors were encountered: