<?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: Setting layer scale and symbology in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650129#M50592</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm running into a similar problem. I'm attempting to create a map with two layers, one of which is visible at scales greater than 1:500000, the other being visible at scales less than 1:500000. I had attempted to define a function to conditionally set the visibility of the layer based on the dataframe's current scale, but am lost on how to update the visibility parameters of the layers on a change of scale within the map. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def closeVisible(scale):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if scale &amp;lt; 500000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return True
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False

def farVisible(scale)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if scale &amp;gt; 500000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return True
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would define the visibility of the layers like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;layer1.visible = closeVisible(dataframe.scale)
layer2.visible = farVisible(dataframe.scale)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;At 10.0, this requires a bit of extra logic but it is possible.&amp;nbsp; You would need to add your layer file multiple times, uniquely name each layer and then check the data frame scale and turn on/off layers.... &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure I understand what you mean by "check the data frame scale and turn on/off layers." Are you indicating that this should be done statically, as coded above? Is there another way to do this? Ideally, every time dataframe.scale changed, the layer visibility would be redefined using the listed functions. Any help is greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: I should have mentioned in my initial post that dataframe.scale is being changed by zooming in and out of the map within ArcMap. Is there anything in the ArcPy library or other available Python libraries that interfaces with the programs scale setting function? My function definition won't work because visible is strictly a boolean type and is set by the function only once, after which I'm assuming the function instance is tossed into cyber-limbo. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then end goal is to be able to script the creation of a raster layer every day with a maximum and minimum scale setting-- a simple task I'm assuming with 10.1. Is the ArcPy module from 10.1 available for download aside from installing the full 10.1 beta?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:34:23 GMT</pubDate>
    <dc:creator>williamangle</dc:creator>
    <dc:date>2021-12-12T03:34:23Z</dc:date>
    <item>
      <title>Setting layer scale and symbology</title>
      <link>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650126#M50589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible to set the visible scale of a layer using ArcPy? What i'm aiming to do is apply the symbology from one layer to a number of other layers but vary the scale at which each layer is visible using Arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, we have 5 feature classes essentially showing the same data at different resolutions e.g 1m,10m, 100m. I want to create a layer file for one feature class, then using arcpy assign this symbology to create layer files for the other feature classes but at the same time alter the display scale depening on the resolution&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 07:32:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650126#M50589</guid>
      <dc:creator>MichaelHarrop</dc:creator>
      <dc:date>2012-03-02T07:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Setting layer scale and symbology</title>
      <link>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650127#M50590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;At 10.0, this requires a bit of extra logic but it is possible.&amp;nbsp; You would need to add your layer file multiple times, uniquely name each layer and then check the data frame scale and turn on/off layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At 10.1, we've exposed the layer scale min/max properties on the Layer object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 13:49:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650127#M50590</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-03-05T13:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Setting layer scale and symbology</title>
      <link>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650128#M50591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We think we have a way around, we are goingto create a dummy layer file for each of the required scales, then set up a tool to changethe data source, apply the symbology, rename the layer file and save as a new mxd which we then use to create map services&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However our main issue is changing the datasource, the dummy layers point to a file geodatabase with but with the links broken and we are attempting to use this to change the source to SDE&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument(r"J:\users\harromi\replacesource\dummy.mxd")
sdepath = r"Z:\webapp\mapservices\Maps\connection-files\DEV\GISCO-DEV-direct-giscoread.sde"
for lyr in arcpy.mapping.ListBrokenDataSources(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.dataSource == r"H:\MyDocuments\ArcGIS\Default.gdb\Export_Output":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(sdepath, "SDE_WORKSPACE", "GISCOVIEW.STAT_LIFEXF_NUTS2_2006_8_01M", True)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.name = "LifeEX"
mxd.saveACopy(r"H:\MyDocuments\ArcGIS\Untitled6.mxd")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Similar code works when updating the source to a another fgdb feature but won't work for SDE&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650128#M50591</guid>
      <dc:creator>MichaelHarrop</dc:creator>
      <dc:date>2021-12-12T03:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Setting layer scale and symbology</title>
      <link>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650129#M50592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm running into a similar problem. I'm attempting to create a map with two layers, one of which is visible at scales greater than 1:500000, the other being visible at scales less than 1:500000. I had attempted to define a function to conditionally set the visibility of the layer based on the dataframe's current scale, but am lost on how to update the visibility parameters of the layers on a change of scale within the map. For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def closeVisible(scale):
&amp;nbsp;&amp;nbsp;&amp;nbsp; if scale &amp;lt; 500000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return True
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False

def farVisible(scale)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if scale &amp;gt; 500000:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return True
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would define the visibility of the layers like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;layer1.visible = closeVisible(dataframe.scale)
layer2.visible = farVisible(dataframe.scale)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;At 10.0, this requires a bit of extra logic but it is possible.&amp;nbsp; You would need to add your layer file multiple times, uniquely name each layer and then check the data frame scale and turn on/off layers.... &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure I understand what you mean by "check the data frame scale and turn on/off layers." Are you indicating that this should be done statically, as coded above? Is there another way to do this? Ideally, every time dataframe.scale changed, the layer visibility would be redefined using the listed functions. Any help is greatly appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: I should have mentioned in my initial post that dataframe.scale is being changed by zooming in and out of the map within ArcMap. Is there anything in the ArcPy library or other available Python libraries that interfaces with the programs scale setting function? My function definition won't work because visible is strictly a boolean type and is set by the function only once, after which I'm assuming the function instance is tossed into cyber-limbo. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then end goal is to be able to script the creation of a raster layer every day with a maximum and minimum scale setting-- a simple task I'm assuming with 10.1. Is the ArcPy module from 10.1 available for download aside from installing the full 10.1 beta?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:34:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/setting-layer-scale-and-symbology/m-p/650129#M50592</guid>
      <dc:creator>williamangle</dc:creator>
      <dc:date>2021-12-12T03:34:23Z</dc:date>
    </item>
  </channel>
</rss>

