Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ogr2ogr -f "PostgreSQL" PG:"host=* port=* dbname=* user=* password=*" RoFRS_v201701.gml -overwrite -progress --config PG_USE_COPY YES
- Geometry: Polygon
- Feature Count: 2130752
- Extent: (134111.801000, 11510.471300) - (655988.124900, 657600.687500)
- Layer SRS WKT:
- (unknown)
- OBJECTID: Integer (0.0)
- PROB_4BAND: String (8.0)
- SUITABILITY: String (25.0)
- PUB_DATE: Integer (0.0)
- RISK_FOR_INSURANCE_SOP: String (3.0)
- SHAPE_Length: Real (0.0)
- SHAPE_Area: Real (0.0)
- ogrinfo PG:"host=* port=* dbname=* user=* password=*" -sql "CREATE EXTENSION postgis;"
- ogr2ogr -f "PostgreSQL" PG:"host=* port=* dbname=* user=* password=*" RoFRS_v201701.gml -overwrite -progress -oo GML_ATTRIBUTES_TO_OGR_FIELDS=YES
- - Ensures the geom column contains geometry of plain,
- ST_MultiPolygon and not the variant with additional dimensions
- -- Run the queries below to check the type of geometry currently stored
- -- in the geom column
- -- SELECT DISTINCT ST_GeometryType(geom) FROM schema.table; -- We want ST_MultiPolygon
- -- SELECT DISTINCT ST_NDims(geom) FROM schema.table; -- We want 2
- -- If the above reports > 2 dimensions, you can force it to 2d by:
- -- Adding an additional column called geom_2d of the correct type and projection
- ALTER TABLE schema.table
- ADD COLUMN geom_2d geometry(MultiPolygon,27700);
- -- UPDATing that new column by passing the original geometry through the ST_Force2D
- -- PostGIS function
- UPDATE schema.table SET geom_2d = ST_Force2D(geom);
- -- Dropping the original geometry
- ALTER TABLE schema.table DROP COLUMN geom;
- -- Renaming the new column to geom
- ALTER TABLE schema.table RENAME COLUMN geom_2d TO geom;
- -- Clean up any duplicate vertices and other geometry problems
- DELETE FROM schema.table WHERE ST_Area(geom) = 0.0;
- UPDATE schema.table
- SET geom = ST_Multi(ST_Buffer(geom, 0.0))
- WHERE NOT ST_IsValid(geom);
- -- And adding a spatial index to the new column
- CREATE INDEX sidx_table_geom
- ON schema.table
- USING gist
- (geom);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement