-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 724f972
Showing
3 changed files
with
54 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 @@ | ||
data/ |
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 @@ | ||
import csv | ||
import json | ||
from pathlib import Path | ||
|
||
from shapely.geometry import shape | ||
from shapely.prepared import prep | ||
|
||
|
||
|
||
def load_india_shape(): | ||
data = json.loads(Path('data/india-composite.geojson').read_text()) | ||
geom = data['features'][0]['geometry'] | ||
return prep(shape(geom)) | ||
|
||
|
||
if __name__ == '__main__': | ||
india_shape = load_india_shape() | ||
|
||
with open(f'data/ms_roads_india.geojsonl', 'w') as outf: | ||
with open(f'data/AsiaSouth-Full.tsv', 'r') as f: | ||
reader = csv.reader(f, delimiter='\t') | ||
for r in reader: | ||
feat = json.loads(r[1]) | ||
geom = feat['geometry'] | ||
s = shape(geom) | ||
if not india_shape.intersects(s): | ||
continue | ||
outf.write(r[1]) | ||
outf.write('\n') | ||
|
||
|
||
|
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,21 @@ | ||
#!/bin/sh | ||
|
||
mkdir data | ||
|
||
wget -O data/india-composite.geojson https://raw.githubusercontent.com/datameet/maps/master/Country/india-composite.geojson | ||
|
||
wget -O data/roads.zip https://usaminedroads.blob.core.windows.net/road-detections/AsiaSouth-Full.zip | ||
|
||
cd data | ||
unzip roads.zip | ||
cd - | ||
|
||
pip install shapely | ||
python clip_roads.py | ||
|
||
cat data/AsiaSouth-Full.tsv | grep "^IND" | cut -f2 > data/ms_roads_india.geojsonl | ||
|
||
tippecanoe -P -zg -o data/ms_roads_india.mbtiles --drop-densest-as-needed --extend-zooms-if-still-dropping -l ms_roads_india -n ms_roads_india -A '<a href="https://github.com/microsoft/RoadDetections" target="_blank" rel="noopener noreferrer">MS Roads</a> - <a href="https://opendatacommons.org/licenses/odbl/" target="_blank" rel="noopener noreferrer">ODbl</a>' data/ms_roads_india.geojsonl | ||
|
||
pmtiles convert data/ms_roads_india.mbtiles data/ms_roads_india.pmtiles | ||
|