HOW TO
Image services stored on an end user's ArcGIS Enterprise stack can be resampled by specifying the area of interest (AOI) from a feature class. The process can be tedious when it involves large imagery services, so using the Arcpy module with the Resample_management() function is helpful.
The following steps describe how to use the ArcPy module to resample image services of an area of interest with the Resample_management() function.
import arcpy, ArcGIS from arcgis.gis import GIS
input_fishnet = r"<Location to AOI>" gis = GIS(url ="<Portal URL>", username="<Portal_Username>",password="<Portal_Password>", verify_cert=False) resample_output=r"<Location of the output images>"
for row in arcpy.da.SearchCursor(input_fishnet, ["SHAPE@", "OID"]): extent = row[0].extent name= row[1] update_name=str(name) update_extent=str(extent).replace(" ",",") imagery = arcgis.raster.ImageryLayer("*REST endpoint of the imagery service*",gis=gis) AOI=imagery.export_image(bbox=update_extent,export_format="tiff",bbox_sr=2913,f="image",save_folder=r"*Location of the Output Folder*", save_file=update_name+".tif")
arcpy.Resample_management(AOI,resample_output+update_name+"_resampled.tif",4,"BILINEAR")
The following shows the full script:
import arcpy, arcgis from arcgis.gis import GIS input_fishnet = r"C:\Temp" gis = GIS(url ="https://test.esri.com/portal", username="username",password="password", verify_cert=False) resample_output=r"C:\Temp" for row in arcpy.da.SearchCursor(input_fishnet, ["SHAPE@", "OID"]): extent = row[0].extent name= row[1] update_name=str(name) update_extent=str(extent).replace(" ",",") imagery =arcgis.raster.ImageryLayer("https://test.esri.com/portal/rest/services/Test",gis=gis) AOI=imagery.export_image(bbox=update_extent,export_format="tiff",bbox_sr=2913,f="image",save_folder=r"C:\Temp",save_file=update_name+".tif") arcpy.Resample_management(AOI,resample_output+update_name+"_resampled.tif",4,"BILINEAR")
Article ID: 000020154
Get help from ArcGIS experts
Download the Esri Support App