cartodb: Invalid geometries after export/import

Context

The dataset with all geometries as valid generates, a different number of, invalid geometries when importing it depending on the export format.

Steps to Reproduce

  1. Go to https://team.carto.com/u/saleiva/tables/chicago_census_tracts/public?redirected=true
  2. Export:
  1. Import all of them.
  2. Run the queries:
  • SELECT count(*) FROM chicago_census_tracts_csv where st_isvalidreason(the_geom) != 'Valid Geometry'
  • SELECT count(*) FROM chicago_census_tracts_shp where st_isvalidreason(the_geom) != 'Valid Geometry'
  • SELECT count(*) FROM chicago_census_tracts_gpkg where st_isvalidreason(the_geom) != 'Valid Geometry'

Current Result

Tables count for invalid geometries:

  • chicago_census_tracts_csv: 0
  • chicago_census_tracts_shp: 3
  • chicago_census_tracts_gpkg: 36

Expected result

I would expect to have all geometries as valid, independently of the export format.

Additional info

Using QGIS Geometry Checker Plugin I wasn’t able to detect invalid geometries from step 2 files. However, I was able to detect invalid geometries after exporting again the imported gpkg dataset at step 3.

cc @javisantana

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 53 (51 by maintainers)

Commits related to this issue

Most upvoted comments

I ran the following regression tests as well:

  • Import a non-trivial .carto file: OK
  • Duplicate a dataset (and add new data to it): OK
  • Create a table from a SQL query: OK
  • Create a sync table: OK
  • Force sync: OK
  • raster import: OK
  • Create a table with ogr2ogr 2.1.2+svn.37167-precise1: OK

Ready for production.

For the record, here’s a snippet showing how I got to debug our test case:

First, compile GDAL with debug symbols and open the resulting ogr2ogr with gdb:

wget http://download.osgeo.org/gdal/2.1.1/gdal-2.1.1.tar.gz
tar -xzf gdal-2.1.1.tar.gz
cd gdal-2.1.1
./configure --without-ld-shared --disable-shared --enable-static --with-ogdi=no --with-spatialite=yes --enable-debug
make
export GDAL_DATA=$(pwd)/data
gdb apps/ogr2ogr

Now we can set breakpoints as needed and execute the conversion of our test case:

b ogrct.cpp:859
...
r -f PostgreSQL PG:"host=localhost port=5432 user={DBUSER} dbname={DBNAME} password={PASSWORD}"  -t_srs EPSG:4326  pntexp.gpkg  -nln pnt_imp_dbg
...