You will learn: how to search for coffee shops, gas stations, restaurants, and other places around a location.
The ArcGIS World Geocoding Service can find addresses and places, convert addresses to coordinates, and perform batch geocoding. If you want to add POIs (Points of Interest) to your analytical workflows, you can search for places such as coffee shops, gas stations, or restaurants. To find places, use the geocode function and pass in a location and search category (e.g. "Coffee Shop").
You can then visualize the results on a map, manipulate the results in a Pandas
Dataframe, and more.
To learn more about the capabilities of the geocoding service, visit the REST API documentation.
In this tutorial, you will create a script to search and display different places around the Santa Monica Mountains area.
Go to Esri Juptyter Notebooks and click New > Python 3 to create a new notebook.
In each step below, type (or copy and paste) the commands into a new notebook cell and run the code by clicking run cell or pressing shift + Enter.
Add the following code to model a GIS portal and import the geocode function from the ArcGIS API for Python.
from arcgis.gis import GIS from arcgis.geocoding import geocode
Create an anonymous connection to ArcGIS Online.
gis = GIS()
geocode_fs = geocode(address=None, location=[-118.71511, 34.09042], category="Coffee shop", out_fields="Place_addr, PlaceName", max_locations=25, as_featureset=True)
geocode_df = geocode_fs.sdf geocode_df.head(2)
Create a map to display the results.
m = gis.map() # Wait for the map to load before setting the center and zoom level m.center = [34.09042, -118.71511] # `[latitude, longitude]` m.zoom = 11
Once the map has loaded, draw the results.
Your notebook should look something like this.
If you would like to translate a point to an address, or vis versa, please see the Search for an address tutorial.
The World Geocoding service can find many different types of places. Explore the Level 1, Level 2, and Level 3 Categories and pass them to the geocode function to search for additional places that you are interested in. Note that you can join categories to search for more than one at a time. For example:
category = "Coffee shop, Gas station, Food, Hotel"