Skip to content

Some useful Scripts

Pascal Dihé edited this page Aug 19, 2015 · 8 revisions

Import geometries from shape file (DOS)

Import geometries from a .shp file with ogr2ogr into a temporary table.

ogr2ogr.exe -progress --config PG_USE_COPY YES -f PostgreSQL PG:"host=127.0.0.1 port=55433 db
name=switchon password=$password user=switchon" -lco DIM=2 F:\work\GeodataImport\EcrFEC_sqlite\EcrFEC_sqlite.shp EcrFEC
_sqlite -sql "select PK_UID from EcrFEC_sqlite" -overwrite -lco OVERWRITE=YES -t_srs "EPSG:4326" -a_srs "EPSG:4326" -lco
 SCHEMA=import_tables -lco GEOMETRY_NAME=geom -lco FID=id -nln geosearch_import -gt 100 -nlt PROMOTE_TO_MULTI

Import geometries from CLC shape file (UNIX)

Import geometries from a Corine Landcover .shp file with ogr2ogr into a temporary table.

ogr2ogr -progress --config PG_USE_COPY YES -f PostgreSQL PG:"host=127.0.0.1 port=5432 dbname=switchon password=$password user=switchon" clc00_c111.shp -overwrite -lco OVERWRITE=YES -t_srs "EPSG:4326" -a_srs "EPSG:4326" -lco SCHEMA=import_tables -lco GEOMETRY_NAME=geom -nln geosearch_import -gt 100

Import geometries from temporary table.

psql switchon switchon -c "INSERT INTO public.geom_search(resource, geo_field) SELECT $resource, ST_Envelope(geom) FROM import_tables.geosearch_import;"
Clone this wiki locally