4

this is related to one of my questions here Invalid Geometry in PostGIS but Valid in FGDB

If I could, I want to repair geometry while I am importing my data to PostGIS. So I wrote this code below on OSgeo4W Shell

ogr2ogr -overwrite -progress -f "PostgreSQL" PG:"host=localhost port=5432 dbname=test user=test password=test" D:\FGDB_Edit\OCEAN.gdb -lco GEOMETRY_NAME=shape -t_srs EPSG:3857 -nln ocean_repair -dialect sqlite -sql "select ST_MakeValid(Shape) as geometry, * from ocean_boundary"

and it gives me this error enter image description here

have you experienced this before? and have any solutions?

1
  • 1
    I believe the problem is that ST_MakeValid(shape) as geometry is being interpreted as shape -- hence column "shape" specified more than once -- despite the geometry alias. Try replacing * with a select list without the geometry column -- you don't need the invalid one anyway. Dec 7, 2017 at 10:25

1 Answer 1

2

so basically your whole code will be like this

ogr2ogr -overwrite -progress -f "PostgreSQL" PG:"host=localhost port=5432 dbname=yourdb user=yourid password=pw" inputGDBpath -lco GEOMETRY_NAME=shape -t_srs EPSG:3857 -nln whatever_the_layer_name -dialect sqlite -sql "select ST_MakeValid(shape) as geometry, OBJECTID_1, objectid, sc1class_c, sc2class_c, sc3class_c, sc4class_c, Shape_Leng, polygon_id, feature_type, display_id, language_code, name, display_class, coverage_indicator, iso_country_code, ver_cnt, region, nccode, bk_nccode, id, scalerank, featurecla, Shape_Length, Shape_Area from ocean_boundary"

OBJECTID_1, objectid, sc1class_c, sc2class_c, sc3class_c, sc4class_c, Shape_Leng, polygon_id, feature_type, display_id, language_code, name, display_class, coverage_indicator, iso_country_code, ver_cnt, region, nccode, bk_nccode, id, scalerank, featurecla, Shape_Length, Shape_Area these are the field in my feature class except "shape" field

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.