-
Notifications
You must be signed in to change notification settings - Fork 10
/
build_neighborhood.sh
executable file
·36 lines (30 loc) · 1.36 KB
/
build_neighborhood.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
NAME=$1
WOEID=$2
DBNAME=osm # you need to have planet.osm (or some relevant portion) imported
DBPORT=5433
#GRASS_LOCATION=/home/sderle/grass/Global/PERMANENT
GRASS_LOCATION=/mnt/places/melissa/grass/Global/PERMANENT
export GRASS_BATCH_JOB=$GRASS_LOCATION/neighborhood.$$
if [ ! -r data/names.txt -o ! -r data/suburbs.txt ]; then
echo "data/names.txt (tab separated file mapping woe_id to name) is missing, or"
echo "data/suburbs.txt (tab separated file mapping parent_id, name, type, woe_id) is missing"
exit 1
fi
if [ ! -r data/photos_$WOEID.txt ]; then
grep ^$WOEID data/suburbs.txt | cut -f4 | xargs python geocrawlr.py >data/photos_$WOEID.txt
fi
BBOX=`python outliers.py data/photos_$WOEID.txt`
if [ ! -r data/blocks_$WOEID.json ]; then
pgsql2shp -f tmp$WOEID.shp -p $DBPORT $DBNAME \
"select osm_id, way from planet_osm_line where way && 'BOX($BBOX)'::box2d and (highway is not null or waterway is not null)" \
|| exit 1
sed -e "s/WOEID/$WOEID/g" >$GRASS_BATCH_JOB <<End
v.in.ogr -e --o --v dsn=. layer=tmpWOEID output=blocks_WOEID type=boundary
v.out.ogr in=blocks_WOEID dsn=data/blocks_WOEID.json format=GeoJSON type=area
End
chmod +x $GRASS_BATCH_JOB
grass -text $GRASS_LOCATION
rm -f $GRASS_BATCH_JOB
rm tmp$WOEID.*
fi
python blockr.py data/names.txt data/blocks_$WOEID.json data/photos_$WOEID.txt > data/$NAME.json