dbTalk Databases Forums  

[SQL] OT - load a shp file

mailing.database.pgsql-sql mailing.database.pgsql-sql


Discuss [SQL] OT - load a shp file in the mailing.database.pgsql-sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Fabiani
 
Posts: n/a

Default [SQL] OT - load a shp file - 12-01-2010 , 12:06 AM






Hi,
How do I load a Census shp file into an exist database? I believe I have
postGIS install and now I want to load the US counties shp file.

the following does not appear to work
shp2pgsql -s 4269 -I -W latin1 tl_2008_us_county.shp 2008_us_county | psql

Plus I don't know what it does!

Johnf

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #2  
Old   
Lee Hachadoorian
 
Posts: n/a

Default Re: [SQL] OT - load a shp file - 12-01-2010 , 03:13 AM






John,

Would probably be useful to see the results of the command, but a couple
of things are immediately obvious.

First, Postgres requires identifiers to start with a letter or
underscore. You are attempting to create a table named 2008_us_county,
which is not a legal identifier. Also, unless you want this in the
public schema, make sure to use the schema-qualified table name.

Second, the docs specify that the shapefile be passed in without the
..shp extension.

Third, since you're not specifying the database explicitly, make sure
that the default makes sense (psql assumes a default of your user name
or reads it from the PGDATABASE environment variable). The examples in
the shp2pgsql docs all explicitly specify a target database with, e.g.
… | psql -d my_db

If you fix all of this and it still isn't working, I would direct the
output to a file, look at it to make sure it makes sense, then try to
pass the file to psql.

If you would prefer, there are also a couple of GUIs that can control
shp2pgsql. I've had success with the SPIT (Shapefile to PostGIS Import
Tool) plugin for Quantum GIS (http://qgis.org/). For Windows only you
can use the Shp2PgSQL Graphical Loader (a plugin for pgAdmin III)
available at http://postgis.refractions.net/download/windows/.

Finally, a better list for PostGIS support is
postgis-users (AT) postgis (DOT) refractions.net.

--Lee

On 12/01/2010 01:06 AM, John Fabiani wrote:
Quote:
Hi,
How do I load a Census shp file into an exist database? I believe I have
postGIS install and now I want to load the US counties shp file.

the following does not appear to work
shp2pgsql -s 4269 -I -W latin1 tl_2008_us_county.shp 2008_us_county | psql

Plus I don't know what it does!

Johnf


--
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center


--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #3  
Old   
John Fabiani
 
Posts: n/a

Default Re: [SQL] OT - load a shp file - 12-01-2010 , 08:29 AM



On Wednesday, December 01, 2010 01:13:52 am Lee Hachadoorian wrote:
Quote:
John,

Would probably be useful to see the results of the command, but a couple
of things are immediately obvious.

First, Postgres requires identifiers to start with a letter or
underscore. You are attempting to create a table named 2008_us_county,
which is not a legal identifier. Also, unless you want this in the
public schema, make sure to use the schema-qualified table name.

Second, the docs specify that the shapefile be passed in without the
.shp extension.

Third, since you're not specifying the database explicitly, make sure
that the default makes sense (psql assumes a default of your user name
or reads it from the PGDATABASE environment variable). The examples in
the shp2pgsql docs all explicitly specify a target database with, e.g.
… | psql -d my_db

If you fix all of this and it still isn't working, I would direct the
output to a file, look at it to make sure it makes sense, then try to
pass the file to psql.

If you would prefer, there are also a couple of GUIs that can control
shp2pgsql. I've had success with the SPIT (Shapefile to PostGIS Import
Tool) plugin for Quantum GIS (http://qgis.org/). For Windows only you
can use the Shp2PgSQL Graphical Loader (a plugin for pgAdmin III)
available at http://postgis.refractions.net/download/windows/.

Finally, a better list for PostGIS support is
postgis-users (AT) postgis (DOT) refractions.net.

--Lee

On 12/01/2010 01:06 AM, John Fabiani wrote:
Hi,
How do I load a Census shp file into an exist database? I believe I have
postGIS install and now I want to load the US counties shp file.

the following does not appear to work
shp2pgsql -s 4269 -I -W latin1 tl_2008_us_county.shp 2008_us_county |
psql

Plus I don't know what it does!

Johnf
thanks for the help. Your response already has taught me a few things and I
haven't even tried to fix the issues.

Johnf

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.