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.
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")
I have shared the code that will resolve your issue in exporting the image of the desired cell size.
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.
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 here 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.
I hope this helps you. Please feel free to ping if you face any issues.