From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | GPS Blaster <gps(dot)blaster(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: shp2pgsql Help with sintax! |
Date: | 2007-07-22 13:58:22 |
Message-ID: | 20070722135822.GA58595@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2007-07-22 15:35:44 | Re: Foreign key constraint question |
Previous Message | Sergey Konoplev | 2007-07-22 12:27:32 | Re: Foreign key constraint question |