3

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
    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. – John Powell Dec 7 '17 at 10:25
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, privacy policy and cookie policy

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