[postgis-users] Can't Get a Shapefile from PostGIS Data

Bill Thoen bthoen at gisnet.com
Wed May 20 09:09:17 PDT 2009


Well, that didn't work exactly. This is what finally worked for me:

ogr2ogr -a_srs epsg:2232 \
  -f "ESRI Shapefile" mymap.shp \
  "PG:dbname=spatial1"  \
  -sql "select * from las_tiles"

But it wouldn't work with any reference to 'host' (neither the IP, 
'localhost', nor '127.0.0.1' worked) and the overwrite switch doesn't 
work if your shape file is not a directory. (I don't need to specify 
user and pw because of the way I have PG set up for local connections.) 
Seems to be some weirdness here, but I'm past that problem now looking 
forward to the next problem...

Thanks!
- Bill Thoen


Phil Bartie wrote:
> Hi Bill,
>  
> Hopefully something like this should do it....
>  
> ogr2ogr -overwrite -a_srs epsg:2232 -f "ESRI Shapefile" d:\mymap.shp 
> "PG:dbname
> =geo host=127.0.0.1 user=postgres password=pass123" -sql "select * 
> from layer"
>  
> Making adjustments for your username, password, and layer name.
>
> Ta,
> Phil
>  
>
>  
> On Wed, May 20, 2009 at 6:22 PM, Bill Thoen <bthoen at gisnet.com 
> <mailto:bthoen at gisnet.com>> wrote:
>
>     I must be overlooking something simple, but I can't seem to get a
>     PostGIS table into an ESRI shapefile. If I use pgsql2shp, I don't
>     get an SRS, but when I try ogr2ogr, nothing happens at all. No
>     error, but no data either. So what's wrong with this?
>
>     ogr2ogr -overwrite -a_srs epsg:2232 -f "ESRI Shapefile" lidar.shp
>     PG:dbname=spatial1 las_tiles
>
>     When I run this, the system prompt comes back almost immediately
>     (no delay to indicate any activity on the database), no file is
>     generated and no errors reported on screen or in the PG serverlog
>     file.
>
>     I'm using PostgreSQL 8.3.3 on Linux.
>
>     Any help would be much appreciated, 'cause I just don't see what's
>     wrong here.
>
>     TIA,
>     - Bill Thoen
>




More information about the postgis-users mailing list