I have a time-enabled MODIS NPP imagery layer for CONUS hosted in our ArcGIS Server. I need to query the tiles resides within the mosaic dataset using some attribute table properties including the time. Then I need to resample the selected tiles into different pixel size and save them as another Imagery layer or a single file.
I used
arcgis.raster.ImageryLayer.set_filter()
function to filter out and lock the necessary tiles as follows.
npp_layer.set_filter(where="((hor=8 OR hor=9) AND ver=5) AND Category=1", time=[datetime(2014,1,1),datetime(2014,12,31)], lock_rasters=True, clear_filters=False)
resampled_layer = copy_raster(npp_layer, output_cellsize=2000, resampling_method='NEAREST', output_name='resampled_npp')
Then used above
arcgis.raster.analytics.copy_raster()
function to resample the selected tiles in the imagery layer and save them as new layer. But "set_filter" filtered and locked rasters are not identified by the "copy_raster" function, so the resampling is applied to all the tiles across all the years. It makes a spatially and temporally incorrect result.
I see a
arcgis.raster.functions.resample()
function, but it does not have a "output_pixel_size" parameter, so it becomes useless in my case. I tried using "arcgis.raster.ImageryLayer.filter_by" and "arcgis.raster.ImageryLayer.mosaic_by" functions for filtering as well, but with no success.
Following is my complete code :
import arcgis
from arcgis.gis import GIS
from arcgis.raster import ImageryLayer
from arcgis.raster.functions import *
from arcgis.raster.analytics import *
from datetime import datetime
gis = GIS('https://arcgis.<domain>/portal', '<user_name>', 'password')
img_svc_url = 'https://arcsrv-prd-02.<domain>:6443/arcgis/rest/services/ANLN-ImageServices/annual_npp/ImageServer'
npp_layer = ImageryLayer(img_svc_url)
npp_layer.set_filter(where="((hor=8 OR hor=9) AND ver=5) AND Category=1", time=[datetime(2014,1,1),datetime(2014,12,31)], lock_rasters=True, clear_filters=False)
resampled_layer = copy_raster(npp_layer, output_cellsize=2000, resampling_method='NEAREST', output_name='resampled_npp')
print(new_ras_layer.properties)
mymap = gis.map("Los Angeles, US", zoomlevel=6)
mymap.add_layer(resampled_layer)
mymap
This filtering and resampling work fine with ArcGIS Pro with Image Server Raster Analysis, but I can't figure it out how to do it with Python API. I am using ArcGIS Server 10.5, ArcGIS Python API 1.2.4, ArcMap 10.5 and ArcGIS Pro products. I am new to ArcGIS Python API, appreciate any help to solve this problem.
Update: There are Imagery layer resampling issues even with ArcGIS Pro. I see that some resampling algorithms like "bilinear" and "nearest neighbor" work, but "average" and "majority" do not work.