[postgis-users] Select statement possible with Pgsql2shp?

John Deck jdeck at socrates.Berkeley.EDU
Mon Feb 3 07:32:29 PST 2003

I'm looking for advice on how to use pgsql2shp by passing in select
statements dynamically.  I've seen references to a "-s " option on this
list but it doesn't seem to be an option for the current version of

What I'm trying to do:

I am building an application with postgis/mapserver that dynamically
creates thematic maps based on us_county.  This app accepts county names
and values via an web-service XML request, then creates a map with the
appropriate shading by county and returns the URL to a PNG file. I have
run into several limitations on the mapserver end (generally having to
do with mapfile restrictions and what I see as a somewhat inefficient
process for describing map parameters) so I have turned to postgis in
the hopes of being able to export a shape file based on dynamic
parameters and then simply use a nicely formatted, exported shapefile
from mapserver.

Currently, I am able to create a view or a new table on the fly and then
use pgsql2shp to export the contents of this into a shapefile and then
view that table with mapserver.  However, I would far prefer to (1) pass
in SQL expressions to pgsql2shp dynamically, or (2) create a temporary
table and then call pgsql2shp by executing a external shell command as I
don't want to give the app permission to write permanent tables.  #1 I
haven't figured out yet and #2 doesn't work since the pgsql2shp command
can't see the temporary table since it executes externally.

Any bright ideas?

John Deck
Berkeley Natural History Museums Informatics Coordinator
(510) 643-3191

More information about the postgis-users mailing list