Search Postgresql Archives

Re: shp2pgsql Help with sintax!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 17, 2007 at 09:46:42AM -0700, GPS Blaster wrote:
> Hi! New to postgres, im trying to import shapefiles into postgres 8.2
> using shp2pgsql but so far have failed.

What have you tried and how did it fail?

You might get more help using PostGIS on postgis-users.

http://postgis.refractions.net/mailman/listinfo/postgis-users

> I tryed using the -p option just to prepare / create the tables then
> insert the data, but no luck, please help me writing the correct
> syntax to acomplish for the following:

Do want to create the table and import the data in separate steps?
shp2pgsql's -p option will create the table without importing the
data.

> Shapefile named  "callesnac.shp"
> Database "postgres" (postgres default installation)
> Schema "sky"
> 
> Need:
> 
> Create table "callesnac"
> Add column "gid"  integer / not null default / next val
> Add column "clasificac_vias"  varchar

shp2pgsql should create the gid serial column automatically.  Is
clasificac_vias in the data or is that a new column that you need
to add?

The following command will create the table without importing any
data:

shp2pgsql -p callesnac.shp sky.callesnac | psql postgres

If you need to add another column then you could connect to the
database and execute the following statement:

ALTER TABLE sky.callesnac ADD COLUMN clasificac_vias varchar;

> import / insert all the data from "callesnac.shp" into 
> callesnac table.

shp2pgsql -aD callesnac.shp sky.callesnac | psql postgres

The -a option means "append."  The -D option isn't required; it
just tells shp2pgsql to use COPY instead of INSERT.  COPY should
be faster when importing large data sets.

You could create the table and import the data in a single step,
then add the new column afterwards:

shp2pgsql -D callesnac.shp sky.callesnac | psql postgres
psql -d postgres -c 'ALTER TABLE sky.callesnac ADD COLUMN clasificac_vias varchar;'

You might need to use shp2pgsql's -s option to set the SRID, and
you can use the -g option to specify a geometry column name other
than the default of "the_geom".

If this doesn't help then please post the commands you're running
and explain how the results differ from what you'd like.  If you're
getting errors then please post the exact text of the error messages.

-- 
Michael Fuhr


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux