This is the completed solution for the Search and geocode ArcGIS DevLab. ArcGIS DevLabs are short introductory tutorials to guide you through the three phases of building geospatial apps: Data, Design, Develop
from arcgis.gis import *
from arcgis.geocoding import geocode, reverse_geocode
from arcgis.geometry import Point
dev_gis = GIS()
dev_gis
geocode_result = geocode(address="Hollywood sign", as_featureset=True)
len(geocode_result.features)
2
map1 = dev_gis.map("Los Angeles, CA", zoomlevel=11)
map1
map1.draw(geocode_result)
map1.clear_graphics()
location = {'Y':34.13419,
'X':-118.29636,
'spatialReference':{
'wkid':4326}
}
unknown_pt = Point(location)
address = reverse_geocode(unknown_pt)
address
{'address': {'AddNum': '', 'Addr_type': 'StreetName', 'Address': 'Vista del Valle Dr', 'Block': '', 'City': 'Los Angeles', 'CountryCode': 'USA', 'District': '', 'LongLabel': 'Vista del Valle Dr, Los Angeles, CA, 90027, USA', 'Match_addr': 'Vista del Valle Dr, Los Angeles, California, 90027', 'MetroArea': 'Los Angeles Metro Area', 'Neighborhood': 'Los Feliz', 'PlaceName': '', 'Postal': '90027', 'PostalExt': '', 'Region': 'California', 'Sector': '', 'ShortLabel': 'Vista del Valle Dr', 'Subregion': 'Los Angeles', 'Territory': '', 'Type': ''}, 'location': {'spatialReference': {'latestWkid': 4326, 'wkid': 4326}, 'x': -118.29641724469197, 'y': 34.13381075391577}}