<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set a map view scale in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638777#M74563</link>
    <description>&lt;P&gt;I need to set up the extent and scale for publishing the map so anytime I add the map service to a web map the content is already in place. Is there a better approach for that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will execute the py script from the command line later on without opening ArcGIS Pro&lt;/P&gt;</description>
    <pubDate>Mon, 04 Aug 2025 13:52:49 GMT</pubDate>
    <dc:creator>Sfortunatamente</dc:creator>
    <dc:date>2025-08-04T13:52:49Z</dc:date>
    <item>
      <title>Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638753#M74558</link>
      <description>&lt;P&gt;Hi, it should be pretty simple, I know but I'm stuck. I have one layer, I grab the extent of it and set the defaultCamera extent based on that value. This is my "pan to layer". Now I need to zoom in to a, let's say, 1:1000 scale. How can I do that?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 11:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638753#M74558</guid>
      <dc:creator>Sfortunatamente</dc:creator>
      <dc:date>2025-08-04T11:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638758#M74559</link>
      <description>&lt;P&gt;Set the scale property of camera.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/camera-class.htm" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/camera-class.htm&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject('CURRENT')
layout = aprx.listLayouts()[0]
map_frame = layout.listElements('MAPFRAME_ELEMENT')[0]
map_frame.camera.scale = 1000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 13:44:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638758#M74559</guid>
      <dc:creator>Marshal</dc:creator>
      <dc:date>2025-08-04T13:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638759#M74560</link>
      <description>&lt;P&gt;Thanks. I still do not get it. I do not have any layouts, just a simple map frame. I get an empty list:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;lyt = aprx.listLayouts()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 12:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638759#M74560</guid>
      <dc:creator>Sfortunatamente</dc:creator>
      <dc:date>2025-08-04T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638774#M74562</link>
      <description>&lt;P&gt;If you are not using a map frame in a layout then you must use aprx.activeView &amp;gt; MapView.camera.scale.&amp;nbsp; &lt;U&gt;&lt;STRONG&gt;But&lt;/STRONG&gt; &lt;/U&gt;it is only intended for use while ArcGIS Pro is open (e.g. script tools, python window, etc.).&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/mapview-class.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;That said, why would you need to set the scale on a map if you aren't exporting it?&amp;nbsp; If you are exporting it, why wouldn't you use a layout?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 13:44:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638774#M74562</guid>
      <dc:creator>Marshal</dc:creator>
      <dc:date>2025-08-04T13:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638777#M74563</link>
      <description>&lt;P&gt;I need to set up the extent and scale for publishing the map so anytime I add the map service to a web map the content is already in place. Is there a better approach for that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will execute the py script from the command line later on without opening ArcGIS Pro&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 13:52:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638777#M74563</guid>
      <dc:creator>Sfortunatamente</dc:creator>
      <dc:date>2025-08-04T13:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638808#M74564</link>
      <description>&lt;P&gt;You are publishing the layers in the map as a map service?&amp;nbsp; The scale and extent of the map used for publishing has no impact on the resulting map service.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 14:51:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638808#M74564</guid>
      <dc:creator>Marshal</dc:creator>
      <dc:date>2025-08-04T14:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638837#M74566</link>
      <description>&lt;P&gt;Set the extent to the layer&lt;BR /&gt;mf.camera.setExtent(mf.getLayerExtent(lyr, True, True))&lt;/P&gt;&lt;LI-CODE lang="c"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")

# Get map and layer
m = aprx.listMaps("Layers1")[0]
lyr = m.listLayers("CCSO.CCSO.CCAP")[0]

# Get layout elements
lyt = aprx.listLayouts("Layout1")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "Map Frame")[0]

# First set the extent to the layer
mf.camera.setExtent(mf.getLayerExtent(lyr, True, True))

# Then set the target scale (1:1000 in your case)
target_scale = 1000  # Changed to 1000 as per your question
mf.camera.scale = target_scale

# Update the map's default camera if needed
m.defaultCamera = mf.camera&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 15:39:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638837#M74566</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-08-04T15:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Set a map view scale</title>
      <link>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638838#M74567</link>
      <description>&lt;P&gt;You're right. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 16:00:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-a-map-view-scale/m-p/1638838#M74567</guid>
      <dc:creator>Sfortunatamente</dc:creator>
      <dc:date>2025-08-04T16:00:05Z</dc:date>
    </item>
  </channel>
</rss>

