Guest User

Untitled

a guest
Dec 18th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. psql -c "SELECT Loader_Generate_Nation_Script('debbie')" -d geocoder -tA > /gisdata/nation_script_load.sh
  2.  
  3. update tiger.loader_platform set declare_sect=
  4. UNZIPTOOL=”/usr/bin/unzip”
  5. WGETTOOL="/usr/bin/wget"
  6. export PGBIN=”/usr/lib/postgresql/9.3/bin”
  7. export PGPORT=5432
  8. export PGHOST=localhost
  9. export PGUSER=postgres
  10. export PGPASSWORD= my_password
  11. export PGDATABASE=test1
  12. PSQL=${PGBIN}/psql
  13. SHP2PGSQL=${PGBIN}/shp2pgsql';
  14.  
  15. psql -d test1 -A -t -c "SELECT Loader_Generate_Nation_Script('sh')"
  16.  
  17. TMPDIR="/gisdata/temp/"
  18. UNZIPTOOL=unzip
  19. WGETTOOL="/usr/bin/wget"
  20. export PGBIN=/usr/lib/postgresql/9.4/bin
  21. export PGPORT=5432
  22. export PGHOST=localhost
  23. export PGUSER=postgres
  24. export PGPASSWORD=yourpasswordhere
  25. export PGDATABASE=geocoder
  26. PSQL=${PGBIN}/psql
  27. SHP2PGSQL=${PGBIN}/shp2pgsql
  28. cd /gisdata
  29.  
  30. cd /gisdata
  31. wget ftp://ftp2.census.gov/geo/tiger/TIGER2015/STATE/ --no-parent --relative --recursive --level=1 --accept=zip --mirror --reject=html
  32. cd /gisdata/ftp2.census.gov/geo/tiger/TIGER2015/STATE
  33. rm -f ${TMPDIR}/*.*
  34. ${PSQL} -c "DROP SCHEMA IF EXISTS tiger_staging CASCADE;"
  35. ${PSQL} -c "CREATE SCHEMA tiger_staging;"
  36. for z in tl_*state.zip ; do $UNZIPTOOL -o -d $TMPDIR $z; done
  37. for z in */tl_*state.zip ; do $UNZIPTOOL -o -d $TMPDIR $z; done
  38. cd $TMPDIR;
  39.  
  40. ${PSQL} -c "CREATE TABLE tiger_data.state_all(CONSTRAINT pk_state_all PRIMARY KEY (statefp),CONSTRAINT uidx_state_all_stusps UNIQUE (stusps), CONSTRAINT uidx_state_all_gid UNIQUE (gid) ) INHERITS(tiger.state); "
  41. ${SHP2PGSQL} -D -c -s 4269 -g the_geom -W "latin1" tl_2015_us_state.dbf tiger_staging.state | ${PSQL}
  42. ${PSQL} -c "SELECT loader_load_staged_data(lower('state'), lower('state_all')); "
  43. ${PSQL} -c "CREATE INDEX tiger_data_state_all_the_geom_gist ON tiger_data.state_all USING gist(the_geom);"
  44. ${PSQL} -c "VACUUM ANALYZE tiger_data.state_all"
  45. cd /gisdata
  46. wget ftp://ftp2.census.gov/geo/tiger/TIGER2015/COUNTY/ --no-parent --relative --recursive --level=1 --accept=zip --mirror --reject=html
  47. cd /gisdata/ftp2.census.gov/geo/tiger/TIGER2015/COUNTY
  48. rm -f ${TMPDIR}/*.*
  49. ${PSQL} -c "DROP SCHEMA IF EXISTS tiger_staging CASCADE;"
  50. ${PSQL} -c "CREATE SCHEMA tiger_staging;"
  51. for z in tl_*county.zip ; do $UNZIPTOOL -o -d $TMPDIR $z; done
  52. for z in */tl_*county.zip ; do $UNZIPTOOL -o -d $TMPDIR $z; done
  53. cd $TMPDIR;
  54.  
  55. ${PSQL} -c "CREATE TABLE tiger_data.county_all(CONSTRAINT pk_tiger_data_county_all PRIMARY KEY (cntyidfp),CONSTRAINT uidx_tiger_data_county_all_gid UNIQUE (gid) ) INHERITS(tiger.county); "
  56. ${SHP2PGSQL} -D -c -s 4269 -g the_geom -W "latin1" tl_2015_us_county.dbf tiger_staging.county | ${PSQL}
  57. ${PSQL} -c "ALTER TABLE tiger_staging.county RENAME geoid TO cntyidfp; SELECT loader_load_staged_data(lower('county'), lower('county_all'));"
  58. ${PSQL} -c "CREATE INDEX tiger_data_county_the_geom_gist ON tiger_data.county_all USING gist(the_geom);"
  59. ${PSQL} -c "CREATE UNIQUE INDEX uidx_tiger_data_county_all_statefp_countyfp ON tiger_data.county_all USING btree(statefp,countyfp);"
  60. ${PSQL} -c "CREATE TABLE tiger_data.county_all_lookup ( CONSTRAINT pk_county_all_lookup PRIMARY KEY (st_code, co_code)) INHERITS (tiger.county_lookup);"
  61. ${PSQL} -c "VACUUM ANALYZE tiger_data.county_all;"
  62. ${PSQL} -c "INSERT INTO tiger_data.county_all_lookup(st_code, state, co_code, name) SELECT CAST(s.statefp as integer), s.abbrev, CAST(c.countyfp as integer), c.name FROM tiger_data.county_all As c INNER JOIN state_lookup As s ON s.statefp = c.statefp;"
  63. ${PSQL} -c "VACUUM ANALYZE tiger_data.county_all_lookup;"
  64.  
  65. SELECT Loader_Generate_Nation_Script('debbie');
  66.  
  67. text loader_generate_nation_script(text os);
  68.  
  69. psql -d geocoder -A -t
  70. -c "SELECT Loader_Generate_Nation_Script('sh')" > /gisdata/nation_script_load.sh
Add Comment
Please, Sign In to add comment