This example illustrates how to combine both the Geocoding and Isolines Location Data Services.
Note: You'll need CARTO Account credentials to reproduce this example.
In [1]:
from cartoframes.auth import set_default_credentials
set_default_credentials('creds.json')
In [2]:
import pandas
df = pandas.DataFrame([
['Calle Serrano 15'],
['Calle de San Pedro 21'],
['Calle Gran Vía 46'],
['Paseo de la Castellana 200'],
['Calle Ntra. Sra. del Carmen 7'],
['Calle de San Germán 12'],
['Calle de Bravo Murillo 377'],
],
columns=['address']
)
df
Out[2]:
In [3]:
from cartoframes.data.services import Geocoding
gc = Geocoding()
gdf, metadata = gc.geocode(df, street='address', city={'value': 'Madrid'}, country={'value': 'Spain'})
In [4]:
gdf
Out[4]:
In [5]:
metadata
Out[5]:
In [6]:
from cartoframes.viz import Layer
Layer(gdf)
Out[6]:
In [7]:
from cartoframes.data.services import Isolines
iso_service = Isolines()
isochrones = iso_service.isochrones(gdf, [100, 200, 300], mode='walk', dry_run=True)
print('Available Quota: {0}'.format(iso_service.available_quota()))
print('Required Quota: {0}'.format(isochrones.metadata.get('required_quota')))
In [8]:
isochrones = iso_service.isochrones(gdf, [100, 200, 300], mode='walk')
isochrones.data.head()
Out[8]:
In [9]:
from cartoframes.viz import Map, Layer, basic_style
Map([
Layer(isochrones.data, basic_style(color='green', opacity='0.3')),
Layer(gdf, basic_style(size=3))
])
Out[9]: