Import Shapefiles (SHP) into Postgis
06/04/2009 // No comment // Category: My Everything // Thẻ: gis, gis, import, postgis, programming, shapefile, shp, shp2pgsql.Follow these steps to start importing ESRI Shapefiles into Postgis database
1. Generate SQL from the shapefile using shp2pgsql
shp2pgsql -W UTF-8 <file_name.shp> <schema>.<table_name> > <filename.sql>
ex:
shp2pgsql –W UTF-8 world.shp public.world > world.sql
2. Open the generated sql file, append “WITH OIDS” before “;” of the CREATE TABLE statement
3. Now import the sql file into Postgis, using psql command
psql -h <host_name> -U <user_name> -d <db_name> -f <file_name.sql>
ex:
psql -h 127.0.0.1 -U postgres -d world -f world.sql
4.Use Query tool available in PgAdmin3
CREATE INDEX <index_name> ON <table_name> USING gist (<spatial_attribute>);
VACUUM ANALYZE <table_name>
ex:
CREATE INDEX world_the_geom_gist ON world USING gist (the_geom);
VACUUM ANALYZE world
Leave a Reply
Recent Posts
Recent Comments
- car on Google App Engine & cron jobs
- Rodrigo Marangon on Mod_python + Apache 2 + Slackware Error
- gabriel on Install packages for PEAR in XAMPP (Ubuntu Linux)
- mod_python on Apache 2 | Miscellaneous musings in beta on Mod_python + Apache 2 + Slackware Error
- Gilberto Ramos on Get back your Alt+Ctrl+Backspace in Karmic
Blogroll
car: nice engine, i'll try to pimp my ride
Rodrigo Marangon: Thanks for sharing! It was very helpful. Another way to make mod_python work is replacing the ...
gabriel: just the info that I was looking for... tnx ...
Gilberto Ramos: very useful! i was looking for this..!
Venkat Mantirraju: This is an excellent guide. Thanks a lot for your effort and time in making ...
How to clear DNS cache in Mac (Tiger, Leopard, Snow Leopard)
31/07/2010
Validation with Jquery
26/07/2010
Add your Google Apps email to Palm Pre
19/07/2010
Install packages for PEAR in XAMPP (Ubuntu Linux)
17/03/2010
Skype on Ubuntu Lucid Lynx 10.04
17/03/2010
Eclipse 3.5 Galileo on Ubuntu Jaunty 9.04
| 12 comments
Google App Engine & cron jobs
| 4 comments
vmware-tools on Slackware 12.1
| 3 comments
Django, Mod-Python & CouchDB
| 2 comments
Mapnik installation on Slackware 12.1
| 2 comments
- © 2009 Tech Mix. All rights reserved.
- WPLine 1.0 designed by Hutek - A member of Vietnam Wordpress Commnunity.
- Powered by Wordpress. Work fine on almost popular browsers.


