lets_plot.geo_data.geocode

lets_plot.geo_data.geocode(level=None, names=None, countries=None, states=None, counties=None, scope=None) lets_plot.geo_data.geocoder.NamesGeocoder

Create a NamesGeocoder. Allow to refine ambiguous request with where() method, scope that limits area of geocoding or with parents.

Parameters
level{‘country’, ‘state’, ‘county’, ‘city’}

The level of administrative division. Autodetection by default.

nameslist or str

Names of objects to be geocoded. For ‘state’ level: ‘US-48’ returns continental part of United States (48 states) in a compact form.

countrieslist

Parent countries. Should have same size as names. Can contain strings or Geocoder objects.

stateslist

Parent states. Should have same size as names. Can contain strings or Geocoder objects.

countieslist

Parent counties. Should have same size as names. Can contain strings or Geocoder objects.

scopestr or Geocoder

Limits area of geocoding. If parent country is set then error will be generated. If type is a string - geoobject should have geocoded scope in parents. If type is a Geocoder - geoobject should have geocoded scope in parents. Scope should contain only one entry.

Returns
NamesGeocoder

Geocoder object specification.

Examples

1from IPython.display import display
2from lets_plot import *
3from lets_plot.geo_data import *
4LetsPlot.setup_html()
5states = geocode('state').scope('Italy').get_boundaries(6)
6display(states.head())
7ggplot() + geom_map(data=states)
The geodata is provided by © OpenStreetMap contributors and is made available here under the Open Database License (ODbL).
state found name geometry
0 Sicily Sicily MULTIPOLYGON (((12.59033 35.51434, 12.59033 35...
1 Molise Molise MULTIPOLYGON (((15.13916 41.93498, 15.13916 41...
2 Tuscany Tuscany MULTIPOLYGON (((11.09619 42.24479, 11.09619 42...
3 Umbria Umbria MULTIPOLYGON (((12.45850 42.39101, 12.43652 42...
4 Emilia-Romagna Emilia-Romagna MULTIPOLYGON (((12.41455 43.88206, 12.43652 43...

 1from IPython.display import display
 2from lets_plot import *
 3from lets_plot.geo_data import *
 4LetsPlot.setup_html()
 5states = geocode(level='state', scope='US').get_geocodes()
 6display(states.head())
 7names = ['York'] * len(states.state)
 8cities = geocode(names=names, states=states.state).ignore_not_found().get_centroids()
 9display(cities.head())
10ggplot() + \
11    geom_livemap() + \
12    geom_point(data=cities, tooltips=layer_tooltips().line('@{found name}'))
id state found name centroid position limit
0 60759 Vermont Vermont [-72.772353529363, 43.8718488067389] [-73.4377402067184, 42.7269606292248, -71.4653... [-73.4377402067184, 42.7269606292248, -71.4653...
1 61315 Massachusetts Massachusetts [-72.0964509339039, 42.1913791447878] [-73.5082098841667, 41.4945808053017, -69.9292... [-73.5082098841667, 41.2393619120121, -69.9292...
2 61320 New York New York [-76.0912327538441, 42.8993669897318] [-79.7619438171387, 40.7823456823826, -73.2414... [-79.7619438171387, 40.4960802197456, -71.8561...
3 63512 Maine Maine [-69.1608471741827, 45.2623642981052] [-71.0841688513756, 43.0649779736996, -66.9498... [-71.0841688513756, 42.9808665812016, -66.9498...
4 67213 New Hampshire New Hampshire [-71.5517876605831, 44.0015134960413] [-72.5572353601456, 42.6972283422947, -70.7018... [-72.5572353601456, 42.6972283422947, -70.7018...
city found name state geometry
0 York New York New York POINT (-73.86737 40.68470)
1 York York Maine POINT (-70.67917 43.17851)
2 York Little York Illinois POINT (-90.74261 41.01002)
3 York York Nebraska POINT (-97.59012 40.86006)
4 York York North Dakota POINT (-99.57356 48.31308)