<?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: Sentinel-2 pixel size change after export_image method (10 m to 2 m) in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1204934#M7657</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.raster import ImageryLayer
gis = GIS("your_org")

sentinel = gis.content.get('fd61b9e0c69c4e14bebd50a9a968348c')
sentinel

imagery_layer = ImageryLayer(sentinel.url, gis=gis)
imagery_layer

tile = imagery_layer.filter_by("OBJECTID=5412567")

m = gis.map()
m

m.add_layer(tile)

m.zoom_to_layer(tile)

m.extent

tile.extent = m.extent

tile

#find out the image size you should use to export image at cell size 10
xmin=tile.extent['xmin']
ymin=tile.extent['ymin']
xmax=tile.extent['xmax']
ymax=tile.extent['ymax']
cell_size=10

width = xmax - xmin
height = ymax - ymin

size_x = width/cell_size
size_y = height/cell_size

tile.export_image(size=[size_x, size_y],
                  bbox=tile.extent,
                  export_format="tiff",
                  save_folder=r"C:\Users\pri10421\Pictures\Saved Pictures",
                  save_file="myras34.tif")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/248235"&gt;@RobertJost&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I have shared the code that will resolve your issue in exporting the image of the desired cell size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Users can't control the cell size by hardcoding since it depends on the image size and the area/extent. You need to provide the calculated image width and height in order to export the image for a particular extent at the desired cell size. Then pass this calculated image width, height in the export_image size parameter. In addition, please note that there is a limitation for exporting an image with max 4000, 4000 size. This means any image beyond this size will not export successfully.&lt;/P&gt;&lt;P&gt;Now the export_image method also has a f parameter. In that parameter, you could pass 'image' value for saving the image directly to the local machine. However, in some cases you will see a 505 error, or a corrupted tiff file saved if the service does not allow exporting beyond a specific heap size. There is a heap size parameter which is controllable for only services that you own. For this reason, you may see that the export_image method fails to export an image beyond a specific size for example, 40MB in case of sentinel2 views (my observation). You can read &lt;A href="https://enterprise.arcgis.com/en/server/10.8/publish-services/linux/geoprocessing-service-settings-advanced.htm" target="_self"&gt;here&lt;/A&gt; how to control the heap size for exporting an image of large size. For such case, you could remove the f parameter and run the export_image method. A json output will be produced with a url that can be directly copied into the browser for downloading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps you. Please feel free to ping if you face any issues.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2022 11:27:48 GMT</pubDate>
    <dc:creator>PriyankaTuteja</dc:creator>
    <dc:date>2022-08-22T11:27:48Z</dc:date>
    <item>
      <title>Sentinel-2 pixel size change after export_image method (10 m to 2 m)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1202223#M7638</link>
      <description>&lt;P&gt;the output raster from the attached code snippet has a pixel size of 2 m but the source imagery is 10 m. I included a screen shot of the output raster rendered in natural color. Changing the "pixel_type" parameter didn't change the output. Can anyone explain this and offer a solution? Couldn't find an explanation in the API documentation.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="s2_code.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48485i17E9D029451C7AA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="s2_code.png" alt="s2_code.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="s2_raster.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/48484i39C00EDB6840BBF3/image-size/large?v=v2&amp;amp;px=999" role="button" title="s2_raster.png" alt="s2_raster.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2022 22:06:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1202223#M7638</guid>
      <dc:creator>RobertJost</dc:creator>
      <dc:date>2022-08-11T22:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sentinel-2 pixel size change after export_image method (10 m to 2 m)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1203602#M7647</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/248235"&gt;@RobertJost&lt;/a&gt;&amp;nbsp;What is the arcgis python api version?&amp;nbsp;&lt;/P&gt;&lt;P&gt;To find out run the following commands: import arcgis; arcgis.__version__&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 05:14:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1203602#M7647</guid>
      <dc:creator>PriyankaTuteja</dc:creator>
      <dc:date>2022-08-17T05:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sentinel-2 pixel size change after export_image method (10 m to 2 m)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1203730#M7648</link>
      <description>&lt;P&gt;I'm running version 1.9.1&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 14:21:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1203730#M7648</guid>
      <dc:creator>RobertJost</dc:creator>
      <dc:date>2022-08-17T14:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sentinel-2 pixel size change after export_image method (10 m to 2 m)</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1204934#M7657</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.raster import ImageryLayer
gis = GIS("your_org")

sentinel = gis.content.get('fd61b9e0c69c4e14bebd50a9a968348c')
sentinel

imagery_layer = ImageryLayer(sentinel.url, gis=gis)
imagery_layer

tile = imagery_layer.filter_by("OBJECTID=5412567")

m = gis.map()
m

m.add_layer(tile)

m.zoom_to_layer(tile)

m.extent

tile.extent = m.extent

tile

#find out the image size you should use to export image at cell size 10
xmin=tile.extent['xmin']
ymin=tile.extent['ymin']
xmax=tile.extent['xmax']
ymax=tile.extent['ymax']
cell_size=10

width = xmax - xmin
height = ymax - ymin

size_x = width/cell_size
size_y = height/cell_size

tile.export_image(size=[size_x, size_y],
                  bbox=tile.extent,
                  export_format="tiff",
                  save_folder=r"C:\Users\pri10421\Pictures\Saved Pictures",
                  save_file="myras34.tif")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/248235"&gt;@RobertJost&lt;/a&gt;&lt;/P&gt;&lt;P&gt;I have shared the code that will resolve your issue in exporting the image of the desired cell size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Users can't control the cell size by hardcoding since it depends on the image size and the area/extent. You need to provide the calculated image width and height in order to export the image for a particular extent at the desired cell size. Then pass this calculated image width, height in the export_image size parameter. In addition, please note that there is a limitation for exporting an image with max 4000, 4000 size. This means any image beyond this size will not export successfully.&lt;/P&gt;&lt;P&gt;Now the export_image method also has a f parameter. In that parameter, you could pass 'image' value for saving the image directly to the local machine. However, in some cases you will see a 505 error, or a corrupted tiff file saved if the service does not allow exporting beyond a specific heap size. There is a heap size parameter which is controllable for only services that you own. For this reason, you may see that the export_image method fails to export an image beyond a specific size for example, 40MB in case of sentinel2 views (my observation). You can read &lt;A href="https://enterprise.arcgis.com/en/server/10.8/publish-services/linux/geoprocessing-service-settings-advanced.htm" target="_self"&gt;here&lt;/A&gt; how to control the heap size for exporting an image of large size. For such case, you could remove the f parameter and run the export_image method. A json output will be produced with a url that can be directly copied into the browser for downloading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps you. Please feel free to ping if you face any issues.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 11:27:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/sentinel-2-pixel-size-change-after-export-image/m-p/1204934#M7657</guid>
      <dc:creator>PriyankaTuteja</dc:creator>
      <dc:date>2022-08-22T11:27:48Z</dc:date>
    </item>
  </channel>
</rss>

