#!/usr/bin/env python # coding: utf-8 # ## Geocoding and Isolines Services # # This example illustrates how to combine both the Geocoding and Isolines Data Services. # # _Note: You'll need [CARTO Account](https://carto.com/signup) credentials to reproduce this example._ # In[1]: from cartoframes.auth import set_default_credentials set_default_credentials('creds.json') # In[2]: from pandas import DataFrame df = 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 # 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 # In[5]: metadata # In[6]: from cartoframes.viz import Layer Layer(gdf) # 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() # 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)) ])