GithubHelp home page GithubHelp logo

Comments (9)

shenganzhan avatar shenganzhan commented on May 26, 2024

You can create a RasterCollection from the mosaic and use getFieldValues to access the fields

from raster-functions.

resnow0892 avatar resnow0892 commented on May 26, 2024

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.

shenganzhan avatar shenganzhan commented on May 26, 2024

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.

resnow0892 avatar resnow0892 commented on May 26, 2024

from raster-functions.

shenganzhan avatar shenganzhan commented on May 26, 2024

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.

resnow0892 avatar resnow0892 commented on May 26, 2024

I made 2 versions of the RFT.

  1. 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.

  2. 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.

resnow0892 avatar resnow0892 commented on May 26, 2024

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.

shenganzhan avatar shenganzhan commented on May 26, 2024

It would be best if you could provide a reproducible case so we can diagnose.

from raster-functions.

resnow0892 avatar resnow0892 commented on May 26, 2024

Ok, I will try to prepare some test data.

from raster-functions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.