Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add data import and update preparation
- Loading branch information
1 parent
38f3ef6
commit b7d3145
Showing
5 changed files
with
140 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
all: shapefiles import | ||
|
||
import: import-shapefiles.sh | ||
|
||
import-shapefiles.sh: {{ tgt_shapefile_shps }} | ||
@> import-shapefiles.sh | ||
@chmod +x import-shapefiles.sh | ||
{% for shapefile in shapefiles %} | ||
@echo 'shp2pgsql -dID -s 3857 -W UTF-8 -g the_geom {{ shapefile['tgt_shp'] }} {{ shapefile['name'] }}' >> import-shapefiles.sh | ||
{% endfor %} | ||
@echo './import-shapefiles.sh | psql -d <database>' | ||
|
||
shapefiles: shapefiles.tar.gz | ||
|
||
shapefiles.tar.gz: | ||
wget 'http://s3.amazonaws.com/{{ bucket }}/{{ datestamp }}/shapefiles.tar.gz' | ||
|
||
{{ tgt_shapefile_zips }}: shapefiles.tar.gz | ||
tar xzf shapefiles.tar.gz | ||
touch {{ tgt_shapefile_zips }} | ||
|
||
{% for shapefile in shapefiles %} | ||
{{ shapefile['tgt_shp'] }}: {{ shapefile['tgt_zip'] }} | ||
unzip -o {{ shapefile['tgt_zip'] }} | ||
test -e {{ shapefile['tgt_shp'] }} | ||
touch {{ shapefile['tgt_shp'] }} | ||
{% endfor %} | ||
|
||
clean: | ||
rm -rf shapefiles.tar.gz {{ tgt_shapefile_zips }} {{ tgt_shapefile_wildcards }} | ||
|
||
.PHONY: all shapefiles import clean |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
all: download shapefiles | ||
|
||
datestamp = $(shell date +%Y%m%d) | ||
|
||
upload: shapefiles | ||
aws s3 cp shapefiles.tar.gz s3://{{ bucket }}/$(datestamp)/shapefiles.tar.gz | ||
if aws s3 ls s3://{{ bucket }}/{{ datestamp }}/shapefiles.tar.gz; then echo 'shapefiles.tar.gz already exists for {{ datestamp }}'; exit 1; else exit 0; fi | ||
aws s3 cp shapefiles.tar.gz s3://{{ bucket }}/{{ datestamp }}/shapefiles.tar.gz | ||
|
||
shapefiles: shapefiles.tar.gz | ||
|
||
shapefiles.tar.gz: {{ proc_shapefile_zips }} | ||
tar czf shapefiles.tar.gz {{ proc_shapefile_zips }} | ||
shapefiles.tar.gz: {{ tgt_shapefile_zips }} | ||
tar czf shapefiles.tar.gz {{ tgt_shapefile_zips }} | ||
|
||
download: {{ shapefile_zips }} | ||
download: {{ src_shapefile_zips }} | ||
|
||
{% for shapefile in shapefiles %} | ||
{{ shapefile.name_zip }}: | ||
wget '{{ shapefile.url }}' -O {{ shapefile.name_zip }} | ||
{{ shapefile.src_zip }}: | ||
wget '{{ shapefile.url }}' -O {{ shapefile.src_zip }} | ||
{% endfor %} | ||
|
||
{% for shapefile in reproj_shapefiles %} | ||
{{ shapefile.name_shp }}: {{ shapefile.name_zip }} | ||
unzip -o {{ shapefile.name_zip }} | ||
touch {{ shapefile.name_shp }} | ||
{{ shapefile.src_shp }}: {{ shapefile.src_zip }} | ||
unzip -o {{ shapefile.src_zip }} | ||
touch {{ shapefile.src_shp }} | ||
|
||
{{ shapefile.reproj_shp }}: {{ shapefile.name_shp }} | ||
OGR_ENABLE_PARTIAL_REPROJECTION=1 ogr2ogr -wrapdateline -t_srs EPSG:3857 -lco encoding=utf8 {{ shapefile.reproj_shp }} {{ shapefile.name_shp }} | ||
{{ shapefile.tgt_shp }}: {{ shapefile.src_shp }} | ||
OGR_ENABLE_PARTIAL_REPROJECTION=1 ogr2ogr -wrapdateline -t_srs EPSG:3857 -lco encoding=utf8 {{ shapefile.tgt_shp }} {{ shapefile.src_shp }} | ||
{% if shapefile.tile %} | ||
python tile-shapefile.py {{ shapefile.reproj_shp }} tiled-{{ shapefile.reproj_shp }} | ||
rm -f {{ shapefile.reproj_shp_wildcard }} | ||
for i in tiled-{{ shapefile.reproj_shp_wildcard }}; do mv -f $$i `echo $$i | sed s/tiled-//`; done | ||
python tile-shapefile.py {{ shapefile.tgt_shp }} tiled-{{ shapefile.tgt_shp }} | ||
rm -f {{ shapefile.tgt_shp_wildcard }} | ||
for i in tiled-{{ shapefile.tgt_shp_wildcard }}; do mv -f $$i `echo $$i | sed s/tiled-//`; done | ||
{% endif %} | ||
|
||
{{ shapefile.reproj_zip }}: {{ shapefile.reproj_shp }} | ||
zip {{ shapefile.reproj_zip }} {{ shapefile.reproj_shp_wildcard }} | ||
{{ shapefile.tgt_zip }}: {{ shapefile.tgt_shp }} | ||
zip {{ shapefile.tgt_zip }} {{ shapefile.tgt_shp_wildcard }} | ||
|
||
{% endfor %} | ||
|
||
.PHONY: download upload shapefiles | ||
clean: | ||
rm -rf shapefiles.tar.gz {{ tgt_shapefile_zips }} {{ tgt_shapefile_wildcards }} {{ src_shapefile_zips }} {{ src_shapefile_wildcards }} | ||
|
||
.PHONY: all download upload shapefiles |
This file contains 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
This file contains 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