Comments (9)
You can create a RasterCollection from the mosaic and use getFieldValues to access the fields
from raster-functions.
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.
from raster-functions.
I don't think it tells you which image the block comes from.
What do you want to do with the min/max?
from raster-functions.
from raster-functions.
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.
from raster-functions.
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:
- the mosaic
- a min constant value raster
- a max constant value raster
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
from raster-functions.
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
from raster-functions.
It would be best if you could provide a reproducible case so we can diagnose.
from raster-functions.
Ok, I will try to prepare some test data.
from raster-functions.
Related Issues (20)
- aspect-slope raster function problems HOT 1
- can not import scikit-image in ArcGIS Pro 1.4 HOT 4
- Slope-Aspect Customized Slope Values HOT 1
- Add support for non c-contiguous arrays in the python raster function HOT 1
- How to use code HOT 3
- Write Wiki to have instructions for ArcGIS Pro instead or in addition to ArcMap HOT 2
- Add Section to Wiki on Writing RFTs to Process Collections of Imagery HOT 4
- How reference many Rasters to other rasters (Warb) HOT 1
- Implement FMask based cloud filtering
- Add error catching to pixel percentile calculations
- Hillshade.py in ArcGIS Pro HOT 4
- Python extension packages missing
- Zonal stats function HOT 4
- How to write YOLO or U-Net Deep Learning code which is integrated with RasterFrames? HOT 5
- Hyperlinks Missing for select Raster Functions and Templates HOT 1
- Deploy Raster function on server HOT 4
- error running Clip raster function using Foreach loop HOT 2
- Difficulties with publishing a rft with a python raster function from Pro to ArcGIS server 10.9.1 HOT 1
- Issue with XGBoost loading a pretrained model in a custom raster function HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raster-functions.