Created
November 27, 2012 14:28
-
-
Save jatorre/4154502 to your computer and use it in GitHub Desktop.
Combine multiple Census files into single shpefile using PostGIS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir tmpfolder; | |
cd tmpfolder; | |
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_01_tract.zip"; | |
unzip tl_2012_01_tract.zip; | |
shp2pgsql -s4326 -p tl_2012_01_tract.shp census | psql -hlocalhost -Upostgres -dcensus; | |
rm -rf tl_2012_01_tract.*; | |
for i in {1..9} :; | |
do | |
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_0${i}_tract.zip"; | |
unzip tl_2012_0${i}_tract.zip | |
shp2pgsql -s4326 -a tl_2012_0${i}_tract.shp census | psql -hlocalhost -Upostgres -dcensus; | |
sleep 1; | |
done; | |
for i in {10..78} :; | |
do | |
wget "http://www2.census.gov/geo/tiger/TIGER2012/TRACT/tl_2012_${i}_tract.zip"; | |
unzip tl_2012_${i}_tract.zip | |
shp2pgsql -s4326 -a tl_2012_${i}_tract.shp census | psql -hlocalhost -Upostgres -dcensus; | |
sleep 1; | |
done; | |
cd ..; | |
rm -rf tmpfolder; | |
pgsql2shp -ftl_2012 -hlocalhost -upostgres census census; | |
tl_2012.zip tl_2012.*; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment