-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert and import Japanese area information.
National Land Information Division offers areal information about Japan. This data is converted into PostGIS SQL and imported into the municipalities table.
- Loading branch information
1 parent
3e40b1c
commit 456c5b6
Showing
2 changed files
with
26 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
curl https://nlftp.mlit.go.jp/ksj/gml/data/N03/N03-2019/N03-190101_GML.zip --output municipalities.zip | ||
|
||
unzip -d municipalities municipalities.zip | ||
|
||
docker-compose run db shp2pgsql -I -s 4326:3857 municipalities/N03-19_190101.shp area_data > area_data.sql | ||
|
||
bin/rails db < area_data.sql | ||
|
||
rm municipalities.zip area_data.sql | ||
rm -Rf municipalities/ | ||
|
||
echo "INSERT INTO municipalities (name) \ | ||
SELECT DISTINCT(n03_004) AS name \ | ||
FROM area_data;" | bin/rails db < /dev/stdin | ||
|
||
echo "INSERT INTO municipality_areas (area, municipality_id) \ | ||
SELECT (ST_Dump(geom)).geom AS area, municipalities.id AS municipality_id \ | ||
FROM area_data \ | ||
INNER JOIN municipalities ON name = n03_004;" | bin/rails db < /dev/stdin | ||
|
||
echo "DROP TABLE area_data;" | bin/rails db < /dev/stdin |
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