Open anoukville opened 2 years ago
You can create a RasterCollection from the mosaic and use getFieldValues to access the fields
Thanks for you answer. I made some tests using the RasterCollection. here is a part of my code :
def updatePixels(self, tlc, shape, props, **pixelBlocks):
#get the min anx max val of reference
test = RasterCollection(r'C:\testGDB\mosaicTest')
mintest = test.getFieldValues('minVal')
maxtest = test.getFieldValues('maxVal')
pix_array = np.asarray(pixelBlocks['raster_pixels'])
'''pixelBlocks rocessing'''
The mintest and maxtest variables return lists with all values in my mosaic
mintest
Out[54]: [-26, -24, -26, -22, -22, -21, 1, 1]
maxtest
Out[55]: [44, 0, 2, -1, 17, 2, 17, 20]
How to access correct list index from the pixelblock in process ? Rasters are located in different places, and the min and max value change from one location to another. I would like to apply my python RFT using the min and max value of the mosaic item zoomed on.
I don't think it tells you which image the block comes from.
What do you want to do with the min/max?
Rasters have a priority order thanks to the Zorder field in the mosaic. But in this case i don’t have overlapping raster. All raster are in different places. Min and max field are reference altitudes and i try to get these field values to make à dynamic remap with a colorscale. Min and max values for each raster have different ranges. I managed to do what i want using a user defined min and max parameters. But it is manual, i need to access the values in the mosaic field. As a result, when I zoom in one of the raster, the RFT displays the appropriate color scale ranging from the min and max value for the corresponding raster.
NB: I make also other tests for other python RFT process and the possibility to acess a numeric value inside a mosaic field would be very useful.
Le lun. 12 sept. 2022 à 20:58, Shengan Zhan @.***> a écrit :
I don't think it tells you which image the block comes from. How do you make sure you get the correct one when there is overlapping images?
What do you want to do with the min/max?
— Reply to this email directly, view it on GitHub https://github.com/Esri/raster-functions/issues/81#issuecomment-1244162881, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2SZSM7DIS45YARJCBZPOPTV554M5ANCNFSM6AAAAAAQIPRUZI . You are receiving this because you authored the thread.Message ID: @.***>
-- Anouk VILLE
How did you apply this to the current raster in the mosaic you are viewing?
I use a Rasterize Feature to access a value inside a feature table.
I made 2 versions of the RFT.
The first one takes as parameters one raster (the mosaic), and 2 numeric user defined min and max values. This version is manual and doesn't adapt to a level of zoom. But I try in this version to fin a way to replace the user defined min and max value with the mosaic fields.
The second one takes as parameters 3 rasters:
To generate the min and max constant value rasters, I use the Rasterize feature raster function on a feature layer containing the min and max field. It works and depending of the rasster zoomed on, the colorscale automatically adapt to the range defined by the min and max in the feature layer (I manually created the feature layer polygons for each raster). But this approach is not optimal, I am looking for another way to access these values.
On the home page I read an exemple which makes what I want (https://github.com/Esri/raster-functions):
"Fish Habitat Suitability FishHabitatSuitability.py returns a raster representing suitability of fish habitat at a user-specified ocean depth given two rasters representing water temperature and salinity. This function demonstrates how raster functions can be exploited in analytic workflows.
[FishHabitatSuitability.rft.xml](https://github.com/Esri/raster-functions/blob/master/functions/FishHabitatSuitability.rft.xml] is a grouping raster function template that accepts the temperature and salinity rasters (in that order). This template—when used in the Add Rasters to Mosaic Dataset tool with the Table raster type or as a processing template on a mosaic dataset—is capable of obtaining the value of the depth parameter from a specific field (StdZ, if available) in the table."
I tried to reproduce this example using the @Field.min and @Field.max but not working. I am loosing hope to find a solution
I tried to use as suggested a RasterCollection and make the intersection of the pixelblock object with the raster from the mosaic to access the values. Here is my updatePixel() function:
def updatePixels(self, tlc, shape, props, **pixelBlocks):
# Raster collection from an image mosaic service
RC=RasterCollection('https://....')
# pixelblock coordinates from x,y extend point geometry
point = arcpy.Point(props['extent'][0], props['extent'][1])
pointGeometry = arcpy.PointGeometry(point).projectAs(arcpy.SpatialReference(props['spatialReference']))
#Filter the Raster collection by geometry (intersecting the pixelblock)
filterRC = RC.filterByGeometry(pointGeometry)
# get min and max values for the intersected element
valmin= filterRC.getFieldValues('minVal')[0]
valmax= filterRC.getFieldValues("maxVal")[0]
pix_array = np.asarray(pixelBlocks['raster_pixels'])
# Numpy operations to remap values from valmin and valmax
bins = np.linspace(valmin, valmax, num=26)
pix_array = np.digitize(pix_array, bins,right=False)
pix_array = np.where(pix_array == 0, 1, pix_array)
pixelBlocks['output_pixels'] = pix_array.astype(props['pixelType'], copy=True)
return pixelBlocks
It seems to work at a certain level of zoom. But when zooming out, nothing is displayed
It would be best if you could provide a reproducible case so we can diagnose.
Ok, I will try to prepare some test data.
Hi, I made a simple Python RFT chained with another RFT template. I use a Rasterize Feature to access a value inside a feature table. Then I am able to apply my python RFT to a mosaic. But It is not optimal for me. I would like to directly use this numeric value stored in a field of my mosaic (this value can change from one raster to another inside the mosaic). I made lot of test but unsuccessful. Does someone has an idea on how to do that ?
thanks for your help.