pgsql2shp command...need help

Paul Spencer pspencer at DMSOLUTIONS.CA
Wed Mar 9 20:40:36 EST 2005


wokar,

pgsql2shp is distributed with the postgis extension to postgres.  When
you have a properly configured postgis database, you can create geometry
columns in your tables and they represent real geometries.  Your table
has no 'geometry' column so the utility doesn't know how to create a
shape file for it ... so it just created the attribute table.

I will assume you have two columns that represent the latitude and
longitude.  You need to review the postgis documentation on adding
postgis support into your database.  There are several steps, including
(but not limited to) running the contents of postgis.sql and
spatial_ref_sys.sql.  If you haven't done this yet, you will have to.

Once you have spatial support installed, you can then create a new
geometry column in your table (again, the postgis documentation has the
necessary steps).

Once you have created the geometry column, you can put real geometries
in using an sql statement like:

update hotspots set the_geom=GeometryFromText( "POINT(" ||
longitude::STRING || " " || latitude::STRING || ")", -1);

which will create a POINT geometry from your lon/lat fields.  Note the
syntax may be wrong and you may have to change it depending on how you
are storing the lon/lat values.

Once you have the_geom populated, you can run pgsql2shp :)

Cheers

Paul

w m wrote:
> Hi,
> Im trying to use the pgsql2shp command to convert a very small table from pgadmin
>
> My database is called montreal and the table is called hotspots
>
> in the root dierectory i do the following.
>
>  i get the following error
>
> -bash-2.05b$ pgsql2shp Montreal Hotspots
> Initializing... No geometry column found.
> The DBF file will be created but not the shx or shp files.
> Done.
> Dumping: XX [4 rows].
>
> What am I doing wrong????
> where is the geometry column supposed to be?
> and where does this newly created DBF file reside?
> Thanks
>
> wokar
>
>
>
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

--
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+



More information about the mapserver-users mailing list