Hi Everyone,

I have a floating point elevation raster and a polygon shapefile representing vegetation classes. All I need to do is calculate the median elevation within each vegetation polygon. I thought the Zonal Statistics tool in Spatial Analyst would do this, but when i add my two layers, it removes the 'median' option from the 'Statistics type' field.

Is there a way to accurately calculate the median raster value based on polygons? Does my elevation raster have to be an integer for this to work?

I'm sorry if this has been addressed before, I'm still getting used to the new forum layout...

Thanks in advance!

Cheers,

Leah

I have a floating point elevation raster and a polygon shapefile representing vegetation classes. All I need to do is calculate the median elevation within each vegetation polygon. I thought the Zonal Statistics tool in Spatial Analyst would do this, but when i add my two layers, it removes the 'median' option from the 'Statistics type' field.

Is there a way to accurately calculate the median raster value based on polygons? Does my elevation raster have to be an integer for this to work?

I'm sorry if this has been addressed before, I'm still getting used to the new forum layout...

Thanks in advance!

Cheers,

Leah

Hi Leah,

It is true that some statistical functions are not available with floating data. These are; MEDIAN, MAJORITY, MINORITY and VARIETY. Those functions require a histogram and this is not present with floating data.

To avoid this you could convert your data to Integer. In order to reduce loss of precision you could multiply your raster with for instance 100 (e.g. express it in cm instead of m), perform the Zonal Statistics and divide the result with the same factor (e.g. 100). In Python this could look like:

Kind regards,