Esri / raster-functions

A curated set of lightweight but powerful tools for on-the-fly image processing and raster analysis in ArcGIS.
Apache License 2.0
195 stars 81 forks source link

Zonal stats function #71

Open pucuz opened 3 years ago

pucuz commented 3 years ago

Hi, I'm seeing if you think this is possible. I want to create a raster function where I pass in a polygon and it returns the zonal stats average value of a value raster. I want the output raster but just the min or max of the output zone raster. I want this to function in ImageServer and I use the JS API to pass in a polygon feature set and it returns the resulting summary value. I currently have a raster function that successfully chains Rasterize Features and then Zonal Statistics functions to create the correct zone raster but not sure about the rest. Do I need a python raster function to get the output value?

shenganzhan commented 3 years ago

Hi, if I understand you correctly, you can try to use the ArgStatistics function on your zone raster to get the max/min zones. Then you can publish the function chain to your server.

pucuz commented 3 years ago

ArgStatistics looks like another potential way to get where I want to be but what I would like is for the output to be just a single value say average or sum of the pixels found in a polygon. I don't want to create an output raster, I just want to end up with a single value. I'm not sure that is even possible. Does the output of a raster function always have to be another raster?

pucuz commented 3 years ago

I think I might be able to get what I want from the statistics of the Zonal Statistics output raster. I just have to figure out how to get at those values from the JS API.

shenganzhan commented 3 years ago

Glad that you were able to find a right track. On the earlier question: raster function does always need to output a raster. If you write your own python raster function, you can hard code some other output but that's generally not recommended.