Skip to main content
added 128 characters in body
Source Link

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")

However, when saving the figure, it does not change extent to the newly added layer. I get the original extent of the map.

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")

However, when saving the figure, it does not change extent to the newly added layer. I get the original extent of the map.

deleted 22 characters in body; edited tags; edited title
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Adding data to existing .aprx layout and zooming to extent of new data using ArcPy with ArcGIS Pro

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Thanks in advance!

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")

Adding data to existing .aprx layout and zooming to extent of new data

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Thanks in advance!

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")

Adding data to existing .aprx layout and zooming to extent of new data using ArcPy with ArcGIS Pro

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")
Source Link

Adding data to existing .aprx layout and zooming to extent of new data

I need to add data to an existing .aprx layout and zoom to the newly added data extent. Then, I need to export layout with new data as a JPEG.

This workflow is not clear online. My data is not in a .gdb, they are shapefile (or can be .kml files).

Thanks in advance!

Currently, I am at:

# Read in project
aprx = arcpy.mp.ArcGISProject("path/to/project.aprx")
m = aprx.listMaps()[0]
fc = "path/to/poly.shp"
# add layer
# lyr = arcpy.management.MakeFeatureLayer(fc, os.path.basename(fc)[:-4])
lyr = m.addDataFromPath(fc)
lyt = aprx.listLayouts("Layout")[0]
# Set extent to layer, then save!
m.defaultCamera.setExtent(arcpy.Describe(lyr).extent)
lyt.exportToJPEG("./temp.jpg")