<?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 Clipping image server layer by iterating through rows in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595249#M73910</link>
    <description>&lt;P&gt;I am using python to try and iterate through a feature class to use the extent of each feature to update the extent in the Clip Raster tool. This is to get around the row/column limitation Esri places on its image servers. I have included the code below. It runs successfully but the raster values range from 0 to 0. I have tried it directly on the Image Server, and on my own image server layer made from the wider image layers, as shown below. The script works fine on a DTM layer downloaded and saved to my local drive. Additionally, running it as a standalone geoprocessing tool, with the image_server_layer as input, and one feature selected and set as the extent, provides the desired outcome!&lt;BR /&gt;&lt;BR /&gt;raster = r'&lt;A href="https://uk-gis.stantec.com/portal/sharing/servers/af25a795273440deb449b336543602be/services/WorldElevation/Terrain/ImageServer" target="_blank" rel="noopener"&gt;https://uk-gis.stantec.com/portal/sharing/servers/af25a795273440deb449b336543602be/services/WorldElevation/Terrain/ImageServer&lt;/A&gt;'&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor(sites, fields) as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;extent = row[1].extent&lt;BR /&gt;&lt;BR /&gt;# Create the image server layer&lt;BR /&gt;image_server_layer = arcpy.management.MakeImageServerLayer(raster, 'ImageSL', extent)&lt;BR /&gt;&lt;BR /&gt;# Define the output raster path&lt;BR /&gt;output_raster = out_loc + '\\' + row[0] + "_2025"&lt;BR /&gt;&lt;BR /&gt;# Ensure the extent values are correctly formatted&lt;BR /&gt;rectangle = f"{extent.XMin} {extent.YMin} {extent.XMax} {extent.YMax}"&lt;BR /&gt;&lt;BR /&gt;# Clip the raster based on the extent&lt;BR /&gt;arcpy.management.Clip(in_raster=image_server_layer, rectangle=rectangle,&lt;BR /&gt;out_raster=output_raster, in_template_dataset="",&lt;BR /&gt;nodata_value="255", clipping_geometry="NONE", maintain_clipping_extent="NO_MAINTAIN_EXTENT")&lt;BR /&gt;&lt;BR /&gt;print(f"Exported and clipped raster part for feature {row[0]}")&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Mar 2025 16:51:00 GMT</pubDate>
    <dc:creator>JackPrice</dc:creator>
    <dc:date>2025-03-13T16:51:00Z</dc:date>
    <item>
      <title>Clipping image server layer by iterating through rows</title>
      <link>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595249#M73910</link>
      <description>&lt;P&gt;I am using python to try and iterate through a feature class to use the extent of each feature to update the extent in the Clip Raster tool. This is to get around the row/column limitation Esri places on its image servers. I have included the code below. It runs successfully but the raster values range from 0 to 0. I have tried it directly on the Image Server, and on my own image server layer made from the wider image layers, as shown below. The script works fine on a DTM layer downloaded and saved to my local drive. Additionally, running it as a standalone geoprocessing tool, with the image_server_layer as input, and one feature selected and set as the extent, provides the desired outcome!&lt;BR /&gt;&lt;BR /&gt;raster = r'&lt;A href="https://uk-gis.stantec.com/portal/sharing/servers/af25a795273440deb449b336543602be/services/WorldElevation/Terrain/ImageServer" target="_blank" rel="noopener"&gt;https://uk-gis.stantec.com/portal/sharing/servers/af25a795273440deb449b336543602be/services/WorldElevation/Terrain/ImageServer&lt;/A&gt;'&lt;BR /&gt;&lt;BR /&gt;with arcpy.da.SearchCursor(sites, fields) as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;extent = row[1].extent&lt;BR /&gt;&lt;BR /&gt;# Create the image server layer&lt;BR /&gt;image_server_layer = arcpy.management.MakeImageServerLayer(raster, 'ImageSL', extent)&lt;BR /&gt;&lt;BR /&gt;# Define the output raster path&lt;BR /&gt;output_raster = out_loc + '\\' + row[0] + "_2025"&lt;BR /&gt;&lt;BR /&gt;# Ensure the extent values are correctly formatted&lt;BR /&gt;rectangle = f"{extent.XMin} {extent.YMin} {extent.XMax} {extent.YMax}"&lt;BR /&gt;&lt;BR /&gt;# Clip the raster based on the extent&lt;BR /&gt;arcpy.management.Clip(in_raster=image_server_layer, rectangle=rectangle,&lt;BR /&gt;out_raster=output_raster, in_template_dataset="",&lt;BR /&gt;nodata_value="255", clipping_geometry="NONE", maintain_clipping_extent="NO_MAINTAIN_EXTENT")&lt;BR /&gt;&lt;BR /&gt;print(f"Exported and clipped raster part for feature {row[0]}")&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 16:51:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595249#M73910</guid>
      <dc:creator>JackPrice</dc:creator>
      <dc:date>2025-03-13T16:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Clipping image server layer by iterating through rows</title>
      <link>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595286#M73911</link>
      <description>&lt;P&gt;It's a bit tricky to see what's going on without &lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;proper code formatting&lt;/A&gt; but it looks like you're rebuilding the IS layer every loop. Does the tool work correctly if you give each layer a new name every loop? Alternatively, can you hoist the layer out of the loop and build it without an extent? Or do you need to define a layer with a limited extent to ensure the clip works?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 17:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595286#M73911</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2025-03-13T17:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Clipping image server layer by iterating through rows</title>
      <link>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595300#M73912</link>
      <description>&lt;P&gt;Make sure extent coordinates are correct,&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;print&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;f"Extent: &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;rectangle&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Also maybe check the output_raster&lt;/P&gt;&lt;PRE&gt;output_raster_obj &lt;SPAN class=""&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class=""&gt;.&lt;/SPAN&gt;Raster&lt;SPAN class=""&gt;(&lt;/SPAN&gt;output_raster&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;print&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;f"Output raster for feature &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;row&lt;SPAN class=""&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;: &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;output_raster_obj&lt;SPAN class=""&gt;.&lt;/SPAN&gt;meanCellHeight&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;output_raster_obj&lt;SPAN class=""&gt;.&lt;/SPAN&gt;meanCellWidth&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;, &lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;output_raster_obj&lt;SPAN class=""&gt;.&lt;/SPAN&gt;extent&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Mar 2025 18:10:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clipping-image-server-layer-by-iterating-through/m-p/1595300#M73912</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-03-13T18:10:25Z</dc:date>
    </item>
  </channel>
</rss>

