Mass Shape File Load into PostGIS
from Paul Ramsey
I needed some test data to do some performance investigations, and had to load 235 shape files, all of identical schema. Here’s what I did.
First, get the table schema into the database, by loading a small file, and then deleting the data. We delete the data so we can loop through all the files later without worrying about duplicating the data from the initial file.
shp2pgsql -s 3005 -i -D lwssvict.shp lwss | psql mydatabase
psql -c “delete from lwss” mydatabase
Then use the shell to loop through all the shape files and append them into the table.
foreach f (*.shp)
foreach? shp2pgsql -s 3005 -i -D $f -a lwss | psql mydatabase
end
Note the “-a” switch to tell shp2pgsql we are in append mode, rather than the default create mode. Add a spatial index, and we’re done.
psql -c “create index lwss_gix on lwss using gist (the_geom)” mydatabase
Seven hundred thousand line segments, ready to play!
psql -c “select count(*) from lwss” mydatabase
count
——–
755373
(1 row)
PS:前一段时间用PersonalGeodatabase比较多,现在觉得,可能postgis和ArcGIS的personalgeodatabase其实是没有太大理念上差异的,可能关键是Postgis对栅格数据没有一整套很好的处理方法。
Related posts:
About this entry
You’re currently reading “Mass Shape File Load into PostGIS,” an entry on Geoinformatics
- Published:
- 5.19.07 / 11下午
- Tags:
- PostGIS
Ajax ArcGIS China Dreams Flex Geography Geoinformatics GeoRSS GIS Google Hardware Harvard Historical Geography History Jquery Life Linux Love Map MapServer NASA Neo-Confucianism OGC OpenGIS OpenSource OSGeo PHP Politics PostGIS PostgreSQL PROJ4 Python R RS Song SVG Ubuntu Web WebGIS Wordpress
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.















赵 博 (Bo Zhao),
参与或主持的项目
No comments
Jump to comment form | comments rss [?] | trackback uri [?]