Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zonal stats function #71

Open
pucuz opened this issue Sep 7, 2021 · 4 comments
Open

Zonal stats function #71

pucuz opened this issue Sep 7, 2021 · 4 comments

Comments

@pucuz
Copy link

pucuz commented Sep 7, 2021

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
Copy link
Contributor

shenganzhan commented Sep 7, 2021

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
Copy link
Author

pucuz commented Sep 7, 2021

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
Copy link
Author

pucuz commented Sep 7, 2021

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants