4/21/20172.5k
jerikso@digitalglobe.com
Public

Top 10 OSM item types over Lancaster-Lebanon, PA


DigitalGlobe (Required Remote Kernel)
Some of the data for this notebook was provided by the DigitalGlobe remote kernel. You will need access to this remote kernel to be able to make full use of this notebook.

!pip install python-geohash
!pip install --no-deps git+https://github.com/jeffreyeriksondg/gbdxtools.git@vector-aggregations
Requirement already satisfied: python-geohash in /anaconda/envs/juno/lib/python2.7/site-packages
Collecting git+https://github.com/jeffreyeriksondg/gbdxtools.git@vector-aggregations
  Cloning https://github.com/jeffreyeriksondg/gbdxtools.git (to vector-aggregations) to /tmp/pip-pAbvR6-build
  Requirement already satisfied (use --upgrade to upgrade): gbdxtools==0.11.3 from git+https://github.com/jeffreyeriksondg/gbdxtools.git@vector-aggregations in /anaconda/envs/juno/lib/python2.7/site-packages
import geohash
import gbdxtools
from gbdxtools.vectors import AggregationDef
bbox = geohash.bbox('dr1s')

center_x = (bbox['w'] + bbox['e']) / 2.0
center_y = (bbox['s'] + bbox['n']) / 2.0

gbdx = gbdxtools.Interface()

wkt_fmt = 'POLYGON(({w} {s}, {w} {n}, {e} {n}, {e} {s}, {w} {s}))'
wkt = wkt_fmt.format(**bbox)

agg = AggregationDef(agg_type='terms', value='item_type')
query = 'ingest_source:OSM'

result = gbdx.vectors.aggregate_query(wkt, agg, query)
print "Retrieved"
Retrieved
for bucket in result[0]['terms']:
    print '%s: %s' % (bucket['term'], bucket['count'])
Road: 4330
House: 2575
Building: 1866
Pedestrian: 643
Stream: 462
Shed: 417
Uncategorized: 357
Tower: 301
Parking: 272
Garage: 197