In [1]:
from cartoframes.auth import set_default_credentials
set_default_credentials('creds.json')
In [2]:
from cartoframes.data.services import Geocoding
gc = Geocoding()
print(gc.available_quota())
In [3]:
from pandas import DataFrame
bike_rental_stores_df = DataFrame([
['Matadero Madrid. Bicycle hire', 'Paseo de la Chopera , 14'],
['Bikes Rental Point in Juan Carlos I Park', 'Vía Dublín, s/n'],
['Fun&Bikes', 'Avenida de Manzanares, 164'],
['Mi Bike Río', 'Calle Aniceto Marinas, 26'],
['Bravo Bike', 'Calle Juan Álvarez Mendizábal, 19'],
['27 Bikes', 'Calle del Alcalde Sainz de Baranda, 16'],
['Bike Spain Tour', 'Plaza de la Villa, 1'],
['Biobike Pasillo Verde', 'Paseo de Juan Antonio Vallejo - Nájero Botas, 55'],
['Bike Tour Trixi Madrid', 'Calle de los Jardines, 12'],
['Otero Ciclos ', 'Calle de Segovia, 18-20'],
['Rent & Roll', 'Calle de Felipe IV, 10'],
['Pangea', 'Paseo de las Yeserías, 15']],
columns=['name', 'address']
)
bike_rental_stores_df
Out[3]:
In [4]:
bike_rental_stores_data, bike_rental_stores_metadata = gc.geocode(
bike_rental_stores_df,
street='address',
city={'value': 'Madrid'},
country={'value': 'Spain'})
In [5]:
bike_rental_stores_data
Out[5]:
In [6]:
from cartoframes.data.services import Isolines
iso_service = Isolines()
isodistances = iso_service.isodistances(
bike_rental_stores_data,
[100, 200, 300],
mode='walk',
dry_run=True,
exclusive=True)
print('Available Quota: {0}'.format(iso_service.available_quota()))
print('Required Quota: {0}'.format(isodistances.metadata.get('required_quota')))
In [7]:
isodistances_data, isodistances_metadata = iso_service.isodistances(
bike_rental_stores_data,
[100, 200, 300],
mode='walk',
exclusive=True)
In [8]:
isodistances_data.head()
Out[8]:
In [9]:
# isodistances_data['geometry'] = isodistances_data['__carto_geometry']
In [10]:
from cartoframes.viz import Map, Layer
Map(
Layer(isodistances_data)
)
Out[10]: