Select to view content in your preferred language

Excluding "NoData" from raster percentile calculation.

3282
1
Jump to solution
07-16-2015 07:43 AM
anTonialcaraz
Frequent Contributor

Hi,

I'm trying to calculate percentiles out of a floating point raster. It works but it includes NoData in the calculation so I'm not getting what I need.

I wonder if someone knows how to exclude the "NoData" from the calculation.

Many thanks

env.workspace = r"D:\PROGRAMMES\LFP_Source_Rocks\ArcGIS\00_LFP_GLOBAL\00_UPWELLING\OUTPUT_Test.gdb"
raster = env.workspace + "\\" + "percentile"
array = arcpy.RasterToNumPyArray(raster)
array = scipy.sort(array)
per = 10
a = scipy.percentile(array,per)
print a
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

You have many options, depending on what your nodata values were converted to,

There is Release Notes — NumPy v1.9 Manual  if you are using Numpy 1.9 or your version supports  it

EDIT

these comments were for means...but whatever, there is a nan_stat for every equivalent o any stat but you can create masked arrays or use where functions to mask nodata values in a raster.

so check the details of how you created RasterToNumPyArray—Help | ArcGIS for Desktop and the option you used regarding nulls

View solution in original post

1 Reply
DanPatterson_Retired
MVP Emeritus

You have many options, depending on what your nodata values were converted to,

There is Release Notes — NumPy v1.9 Manual  if you are using Numpy 1.9 or your version supports  it

EDIT

these comments were for means...but whatever, there is a nan_stat for every equivalent o any stat but you can create masked arrays or use where functions to mask nodata values in a raster.

so check the details of how you created RasterToNumPyArray—Help | ArcGIS for Desktop and the option you used regarding nulls