solution_070c.py

#!/usr/bin/python3
# ====================================================================
# OSMNX - geocoding / geolocation
# from: pygis.io/docs/d_access_osm.html
# --------------------------------------------------------------------
# to install osmnx: pip install osmnx
# to install osmnx: pip install folium
# ====================================================================

import osmnx as ox
import folium


## original code
## define a place to be in New York City instead of the
## entire world to reduce computational and memory costs.
## place = 'Manhattan, New York, USA'

place = 'Pasadena, CA, USA'

# acquire some cafe points within Manhattan
 
tags = {'amenity': 'cafe'}
cafe = ox.geometries_from_place(place,tags=tags)

##print(cafe.head())

# subset the first cafes (0 to 19)

cafe_points = cafe[cafe.geom_type == 'Point'][:20]


print(f'Type: {type(cafe_points)}')

print('--------------------------------------------')
i = 0
for caf in cafe_points:
   print(f'[{i:2}] {caf}')
   if i > 10: break
   i += 1

print('--------------------------------------------')
i = 0
for b in cafe_points['brand']:
    print(f'[{i:2}] {b}')
    if i > 10: break
    i += 1

print('--------------------------------------------')
print(cafe_points['brand'][0])