Set the extent of an AGOL map or feature layer through Python

1091
2
Jump to solution
08-13-2020 01:17 PM
JulioGarrido
New Contributor III

I have a Crime map that gets updated every night with fresh data from our RMS system.  The raw data gets geocoded, washed of any specifics (e.g. officer, victim, etc.), and then uploaded to the County Sheriff's folder in AGOL. This is all done through Python.  Is there a way in Python to add the extent information onto the feature layer and/or to the online map itself?  I have the organization's extent coordinates (Top, Bottom, Left, Right) in decimal degrees.

Thank you in advance.

Julio G.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JudyMak
New Contributor II

Try this:

from arcgis.mapping import WebMap
from arcgis.gis import GIS
gis = GIS("home")
item = gis.content.get('258ce2e9584843ab8c0efe991844c672')
extent = [[-118.613114, 33.773435], [-118.00200, 32.215572]]

# extent format: 'top left', 'bottom right' bounding box in WGS 84 Auxiliary Mercator decimal degrees

item.update(item_properties={'extent': extent})

View solution in original post

2 Replies
JudyMak
New Contributor II

Try this:

from arcgis.mapping import WebMap
from arcgis.gis import GIS
gis = GIS("home")
item = gis.content.get('258ce2e9584843ab8c0efe991844c672')
extent = [[-118.613114, 33.773435], [-118.00200, 32.215572]]

# extent format: 'top left', 'bottom right' bounding box in WGS 84 Auxiliary Mercator decimal degrees

item.update(item_properties={'extent': extent})

JulioGarrido
New Contributor III

Hi Judy.

Sorry for the late reply.  I tried it and it worked like a charm.  Thank you so much.

Julio

0 Kudos