Learn how to find an address, business, or place with the geocoding service.
You can perform place geocoding with the geocoding service. Place geocoding is the process of searching for addresses for businesses, administrative locations, and geographic features. You can search for the name of a place and/or you can provide categories to filter the results.
In this tutorial, you use the geocode function to find places around the Santa Monica mountains area.
Prerequisites
The ArcGIS API for Python tutorials use Jupyter Notebooks to execute Python code. If you are new to this environment, please see the guide to install the API and use notebooks locally.
Steps
Import modules and log in
- 
Import the
arcgis.gismodule. This module is the entry point into the GIS and provides the functionality to manage GIS content, users, and groups. Additionally, import thegeocodeclass from thearcgis.geocodingmodule, which provides types and functions for geocoding, batch geocoding and reverse geocoding.Use dark colors for code blocks from arcgis.gis import GIS from arcgis.geocoding import geocode - 
Use the
GISclass to log in anonymously to ArcGIS Online. Since the results are not stored, you do not need credentials to call the geocoding service.Use dark colors for code blocks from arcgis.gis import GIS from arcgis.geocoding import geocode gis = GIS() 
Find coffee shops near a point
- 
Pass the relevant parameters into the geocode function and get a FeatureSet as the result. Use the
location,category,out, and_fields maxparameters to request the names, addresses, and locations of 25 coffee shops near a point in the Santa Monica Mountains. Set the_location asparameter to_featureset trueto return the results as a feature set so that they can be easily added to a map.Use dark colors for code blocks from arcgis.gis import GIS from arcgis.geocoding import geocode gis = GIS() geocoded_features = geocode( address=None, location=[-118.71511, 34.09042], category="Coffee shop", out_fields="Place_addr, PlaceName", max_locations=25, as_featureset=True, ) 
Review the results
- 
Use the
sdfproperty of aFeatureto convert the feature set into a spatial data frame and render the first two locations.Set Use dark colors for code blocks from arcgis.gis import GIS from arcgis.geocoding import geocode gis = GIS() geocoded_features = geocode( address=None, location=[-118.71511, 34.09042], category="Coffee shop", out_fields="Place_addr, PlaceName", max_locations=25, as_featureset=True, ) geocoded_df = geocoded_features.sdf geocoded_df.head(2) 
Map the results
- Use the 
mapmethod of theGISclass to create a MapView. 
geocoded_df = geocoded_features.sdf
geocoded_df.head(2)
m = gis.map()
m
- Once the map has loaded, use the 
centerandzoomproperties set the map extent and use thedrawmethod to add the results to the map. 
m = gis.map()
m
m.center = [34.09042, -118.71511]
m.zoom = 11
m.draw(geocoded_features)
You should see the results displayed as graphic points on the map.
- 
Optional: Use the
exportmethod to export the current state of the map widget to a static HTML file which can be viewed in any web browser._to _html Use dark colors for code blocks from os import path, getcwd export_dir = path.join(getcwd(), "home") if not path.isdir(export_dir): os.mkdir(export_dir) export_path = path.join(export_dir, "find-place-addresses.html") m.export_to_html(export_path, title="Find place addresses") 
What's next?
Learn how to use additional functionality in these tutorials:
