Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shp2pgsql Help with syntax!

Status
Not open for further replies.

SenTnel

Technical User
Dec 9, 2003
45
DO
Hi! New to postgres, im trying to import shapefiles into postgres 8.2 using shp2pgsql but so far have failed.

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:


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

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

Thanks!
 
Hi! Thanks! This is the table structure, and the way im trying to create the table (somenthing i don't understand is where do i specify the database and schema, it only says create table):

BEGIN;
CREATE TABLE "postgres" (gid serial PRIMARY KEY,
"street" varchar(40),
"to_left" int4,
"from_left" int4,
"to_right" int4,
"fom_right" int4,
"type" int4,
"yska" int4,
"colonia" varchar(40),
"observacio" varchar(40),
"clasesoc" varchar(1),
"hora" varchar(12),
"fecha" varchar(12),
"temp" varchar(40),
"from_right" int4,
"claseso" varchar(1),
"numero" int2,
"municipi0" varchar(30),
"clasificac" int2);
SELECT AddGeometryColumn('','postgres','the_geom','-1','MULTILINESTRING',2);



And this is the output im getting:



NOTICE: CREATE TABLE will create implicit sequence "postgres_gid_seq" for serial column "postgres.gid"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "postgres_pkey" for table "postgres"

ERROR: function addgeometrycolumn("unknown", "unknown", "unknown", "unknown", "unknown", integer) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You may need to add explicit type casts.
Character: 415


Suggestions? Thanks again!
 
To create a new database or schema you can issue the commands "CREATE DATABASE foo;" and "CREATE SCHEMA bar;", though I always find it easier to work in the "public" schema. If you want to use the database, you need to start the connection with the database name as a parameter (i.e. "psql foo") To use the schema, you prefix the tablename with it. (i.e. SELECT * FROM "bar"."table1";)

Have you created the function addgeometrycolumn, if so check which arguments it takes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top