[Qgis-developer] Exporting shape files to postgis

John C. Tull jctull at gmail.com
Sat Jan 23 12:36:24 EST 2010


I believe the question was how to go from shapefile to pgsql. If so, my preferred method is to do this from the Terminal.

Assuming you have a postgis enabled database called 'postgis', and you are importing data with epsg code 26911, this will work:

shp2pgsql -d -I -s 26911 my_shape.shp my_shape | psql -d postgis

The -d command is only needed if you are overwriting an existing table (replacing it), although it won't hurt if the table does not already exist. The -I command creates an index on the geometry column, so it will speed data access. The -s specifies the epsg code so the table will have an associated CRS. Then you have the shapefile and the name for the table in your pgsql database. Finally, this is piped to the psql command where you specify your database.

Cheers,
John

On Jan 23, 2010, at 8:29 AM, Martin Spott wrote:

> Lutfi Oduncuoglu wrote:
> 
>> I know how import shape files from postgis, but i could not find any
>> valuable document about how to export shape files to postgis. Can you help
>> me about this?
> 
> If I were you, then I'd use the 'pgsql2shp' command that comes with
> PostGIS. Try this one:
> 
>  # ~> pgsql2shp --help
> 
> and read it's output,
> 
> 	Martin.
> -- 
> Unix _IS_ user friendly - it's just selective about who its friends are !
> --------------------------------------------------------------------------
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the Qgis-developer mailing list