-
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.
Merge pull request #14 from LocationMind/fix-buildings-poi
Add SQL folder to fix dev branch
- Loading branch information
Showing
4 changed files
with
269 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,166 @@ | ||
drop table ovt.tokyo_bld; | ||
create table ovt.tokyo_bld ( | ||
ogc_fid integer, | ||
wkb_geometry geometry(MULTIPOLYGON, 4326), | ||
id varchar, | ||
version integer, | ||
update_time timestamp with time zone, | ||
sources json, | ||
subtype varchar, | ||
names json, | ||
class varchar, | ||
level integer, | ||
has_parts boolean, | ||
height double precision, | ||
min_height double precision, | ||
num_floors integer, | ||
facade_color varchar, | ||
facade_material varchar, | ||
min_floor integer, | ||
roof_material varchar, | ||
roof_shape varchar, | ||
roof_direction double precision, | ||
roof_orientation varchar, | ||
roof_color varchar, | ||
area_name char(50) | ||
) | ||
; | ||
|
||
drop table ovt.hamamatsu_bld; | ||
create table ovt.hamamatsu_bld ( | ||
ogc_fid integer, | ||
wkb_geometry geometry(MULTIPOLYGON, 4326), | ||
id varchar, | ||
version integer, | ||
update_time timestamp with time zone, | ||
sources json, | ||
subtype varchar, | ||
names json, | ||
class varchar, | ||
level integer, | ||
has_parts boolean, | ||
height double precision, | ||
min_height double precision, | ||
num_floors integer, | ||
facade_color varchar, | ||
facade_material varchar, | ||
min_floor integer, | ||
roof_material varchar, | ||
roof_shape varchar, | ||
roof_direction double precision, | ||
roof_orientation varchar, | ||
roof_color varchar, | ||
area_name char(50)) | ||
; | ||
|
||
drop table ovt.tateyama_bld; | ||
create table ovt.tateyama_bld ( | ||
ogc_fid integer, | ||
wkb_geometry geometry(MULTIPOLYGON, 4326), | ||
id varchar, | ||
version integer, | ||
update_time timestamp with time zone, | ||
sources json, | ||
subtype varchar, | ||
names json, | ||
class varchar, | ||
level integer, | ||
has_parts boolean, | ||
height double precision, | ||
min_height double precision, | ||
num_floors integer, | ||
facade_color varchar, | ||
facade_material varchar, | ||
min_floor integer, | ||
roof_material varchar, | ||
roof_shape varchar, | ||
roof_direction double precision, | ||
roof_orientation varchar, | ||
roof_color varchar, | ||
area_name char(50) | ||
) | ||
; | ||
|
||
drop table ovt.kumamoto_bld; | ||
create table ovt.kumamoto_bld ( | ||
ogc_fid integer, | ||
wkb_geometry geometry(MULTIPOLYGON, 4326), | ||
id varchar, | ||
version integer, | ||
update_time timestamp with time zone, | ||
sources json, | ||
subtype varchar, | ||
names json, | ||
class varchar, | ||
level integer, | ||
has_parts boolean, | ||
height double precision, | ||
min_height double precision, | ||
num_floors integer, | ||
facade_color varchar, | ||
facade_material varchar, | ||
min_floor integer, | ||
roof_material varchar, | ||
roof_shape varchar, | ||
roof_direction double precision, | ||
roof_orientation varchar, | ||
roof_color varchar, | ||
area_name char(50) | ||
) | ||
; | ||
|
||
drop table ovt.higashi_hiroshima_bld; | ||
create table ovt.higashi_hiroshima_bld ( | ||
ogc_fid integer, | ||
wkb_geometry geometry(MULTIPOLYGON, 4326), | ||
id varchar, | ||
version integer, | ||
update_time timestamp with time zone, | ||
sources json, | ||
subtype varchar, | ||
names json, | ||
class varchar, | ||
level integer, | ||
has_parts boolean, | ||
height double precision, | ||
min_height double precision, | ||
num_floors integer, | ||
facade_color varchar, | ||
facade_material varchar, | ||
min_floor integer, | ||
roof_material varchar, | ||
roof_shape varchar, | ||
roof_direction double precision, | ||
roof_orientation varchar, | ||
roof_color varchar, | ||
area_name char(50) | ||
) | ||
; | ||
|
||
drop table ovt.morioka_bld; | ||
create table ovt.morioka_bld ( | ||
ogc_fid integer, | ||
wkb_geometry geometry(MULTIPOLYGON, 4326), | ||
id varchar, | ||
version integer, | ||
update_time timestamp with time zone, | ||
sources json, | ||
subtype varchar, | ||
names json, | ||
class varchar, | ||
level integer, | ||
has_parts boolean, | ||
height double precision, | ||
min_height double precision, | ||
num_floors integer, | ||
facade_color varchar, | ||
facade_material varchar, | ||
min_floor integer, | ||
roof_material varchar, | ||
roof_shape varchar, | ||
roof_direction double precision, | ||
roof_orientation varchar, | ||
roof_color varchar, | ||
area_name char(50) | ||
) | ||
; |
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,51 @@ | ||
# It will takes 25 minutes to process 5 areas | ||
# Initialize the command in seconds. | ||
SECONDS=0 | ||
|
||
# move to working directory | ||
SCRIPT_DIR=$(cd $(dirname $0); pwd) | ||
cd "${SCRIPT_DIR}" | ||
|
||
mkdir ./data/202405/overturemaps/ | ||
|
||
psql -U postgres -d postgres -c "create schema ovt;" | ||
|
||
psql -U postgres -d postgres -c "drop table if exists ovt.hamamatsu_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists ovt.tokyo_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists ovt.tateyama_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists ovt.kumamoto_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists ovt.higashi_hiroshima_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists ovt.morioka_bld;" | ||
|
||
psql -U postgres -d postgres -f ./create_tables.sql | ||
|
||
# Tokyo | ||
overturemaps download --bbox=139.74609375,35.67514744,139.83398438,35.74651226 -f geojson --type=building -o ./data/202405/overturemaps/tokyo.geojson | ||
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=postgres" -nln ovt.tokyo_bld -nlt multipolygon ./data/202405/overturemaps/tokyo.geojson | ||
|
||
# Hamamatsu | ||
overturemaps download --bbox=137.63671875,34.66935855,137.72460938,34.7416125 -f geojson --type=building -o ./data/202405/overturemaps/hamamatsu.geojson | ||
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=postgres" -nln ovt.hamamatsu_bld -nlt multipolygon ./data/202405/overturemaps/hamamatsu.geojson | ||
|
||
# Tateyama | ||
overturemaps download --bbox=139.83398438,34.95799531,139.921875,35.02999637 -f geojson --type=building -o ./data/202405/overturemaps/tateyama.geojson | ||
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=postgres" -nln ovt.tateyama_bld -nlt multipolygon ./data/202405/overturemaps/tateyama.geojson | ||
|
||
# Kumamoto | ||
overturemaps download --bbox=130.68726409,32.72948989,130.77515472,32.80174385 -f geojson --type=building -o ./data/202405/overturemaps/kumamoto.geojson | ||
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=postgres" -nln ovt.kumamoto_bld -nlt multipolygon ./data/202405/overturemaps/kumamoto.geojson | ||
|
||
# Higashi_hiroshima | ||
overturemaps download --bbox=132.69418348,34.38622724,132.7820741,34.45848119 -f geojson --type=building -o ./data/202405/overturemaps/higashi_hiroshima.geojson | ||
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=postgres" -nln ovt.higashi_hiroshima_bld -nlt multipolygon ./data/202405/overturemaps/higashi_hiroshima.geojson | ||
|
||
# Morioka | ||
overturemaps download --bbox=141.07765453,39.6823863,141.16554516,39.75375112 -f geojson --type=building -o ./data/202405/overturemaps/morioka.geojson | ||
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=postgres" -nln ovt.morioka_bld -nlt multipolygon ./data/202405/overturemaps/morioka.geojson | ||
|
||
|
||
# Display the measurement time. | ||
time=$SECONDS | ||
((sec=time%60, min=(time%3600)/60, hrs=time/3600)) | ||
timestamp=$(printf "%d:%02d:%02d" "$hrs" "$min" "$sec") | ||
echo "Processing time is $timestamp" |
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,28 @@ | ||
#!/bin/bash -e | ||
|
||
# Initialize the command in seconds. | ||
SECONDS=0 | ||
|
||
psql -U postgres -d postgres -c "create schema osm;" | ||
|
||
psql -U postgres -d postgres -c "drop table if exists osm.tokyo_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists osm.tateyama_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists osm.hamamatsu_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists osm.kumamoto_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists osm.higashi_hiroshima_bld;" | ||
psql -U postgres -d postgres -c "drop table if exists osm.morioka_bld;" | ||
|
||
psql -U postgres -d postgres -c "create table osm.tokyo_bld(area_id bigint, id bigint, geom geometry(MultiPolygon,4326));" | ||
psql -U postgres -d postgres -c "create table osm.tateyama_bld(area_id bigint, id bigint, geom geometry(MultiPolygon,4326));" | ||
psql -U postgres -d postgres -c "create table osm.hamamatsu_bld(area_id bigint, id bigint, geom geometry(MultiPolygon,4326));" | ||
psql -U postgres -d postgres -c "create table osm.kumamoto_bld(area_id bigint, id bigint, geom geometry(MultiPolygon,4326));" | ||
psql -U postgres -d postgres -c "create table osm.higashi_hiroshima_bld(area_id bigint, id bigint, geom geometry(MultiPolygon,4326));" | ||
psql -U postgres -d postgres -c "create table osm.morioka_bld(area_id bigint, id bigint, geom geometry(MultiPolygon,4326));" | ||
|
||
psql -U postgres -d postgres -c "\copy osm.tokyo_bld from './data/202405/osm/osm_building_tokyo.tsv' delimiter E'\t' csv;" | ||
psql -U postgres -d postgres -c "\copy osm.tateyama_bld from './data/202405/osm/osm_building_tateyama.tsv' delimiter E'\t' csv;" | ||
psql -U postgres -d postgres -c "\copy osm.hamamatsu_bld from './data/202405/osm/osm_building_hamamatsu.tsv' delimiter E'\t' csv;" | ||
psql -U postgres -d postgres -c "\copy osm.kumamoto_bld from './data/202405/osm/osm_building_kumamoto.tsv' delimiter E'\t' csv;" | ||
psql -U postgres -d postgres -c "\copy osm.higashi_hiroshima_bld from './data/202405/osm/osm_building_higashi_hiroshima.tsv' delimiter E'\t' csv;" | ||
psql -U postgres -d postgres -c "\copy osm.morioka_bld from './data/202405/osm/osm_building_morioka.tsv' delimiter E'\t' csv;" | ||
|
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,24 @@ | ||
# Buildings | ||
|
||
## Overture Maps | ||
|
||
Install a CLI tool to download Overture Maps data. | ||
|
||
``` | ||
pip install overturemaps | ||
``` | ||
|
||
Run the following code and it will download buildings in target areas from Overture Maps and import them into PostgreSQL. | ||
|
||
``` | ||
bash buildings/download_import_ovt.sql | ||
``` | ||
|
||
## OpenStreetMap | ||
|
||
This script just import tsv files into PostgreSQL. | ||
You need to extract data before running this script. | ||
|
||
``` | ||
bash building/import_osm_tsv.shcd . | ||
``` |