Skip to main content
Question

Raster Test for nodata

  • November 5, 2015
  • 2 replies
  • 125 views

darkspatiallord
Supporter
Forum|alt.badge.img+8
I am tiling a raster dataset of elevation. if one of the tiles only has nodata values i want to remove that tile from the process

 

any ideas on the process?
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • November 5, 2015
Hi

 

 

You can use the RasterBandMinMaxExtractor and test if the resulting list values only contain nodata (e.g. using the ListRangeExtractor):

 

_band{}.min

 

_band{}.max

 

 

David

 


david_r
Celebrity
  • November 5, 2015
For reference, here is also a small Python snippet that will check the _band{} list to see if a raster only contains one value (e.g. all white or black) , it should be relatively easy to adapt to other criteria:

 

 

max_values = [int(x) for x in feature.getAttribute('_band{}.max')]
min_values = [int(x) for x in feature.getAttribute('_band{}.min')]
values = zip(max_values, min_values)
contents = sum([x[0]-x[1] for x in values])
if contents == 0:
    # No content, all min and max cell values are identical on every band
    feature.setAttribute('_raster_contents', 'EMPTY')
else:
    feature.setAttribute('_raster_contents', 'OK')

 

You probably shouldn't be using it as-is on your rasters unless you know for a fact that single-color tiles are invalid.

 

 

David