1

I am trying to automate the downsampling of elevation (and other) data using open source software at command line in an automated workflow via use of windows batch files. Currently the workflow uses only gdal utilities via osgeo4w.

I am looking for a command line resample method that will ignore the nodata that is present in the input tiff file during calculations. I need this so that output provides data values at dataset edges. Majority/mode and mean downsample options are preferred, rather than a simple nearest neighbour. Something similar to the arcgis block majority and aggregate tools would be nice.

3
  • Does the gdalwarp utility not meet your needs?
    – GeoMonkey
    Commented Jan 30, 2017 at 16:34
  • To the best of my knowledge gdalwarp does not offer a way to ignore nodata.
    – ctlgeowp
    Commented Jan 30, 2017 at 17:05
  • 1
    If I've understood your problem correctly then from the documentation: -srcnodata value [value...]: Set nodata masking values for input bands (different values can be supplied for each band). If more than one value is supplied all values should be quoted to keep them together as a single operating system argument. Masked values will not be used in interpolation. Use a value of None to ignore intrinsic nodata settings on the source dataset.
    – GeoMonkey
    Commented Jan 30, 2017 at 17:11

1 Answer 1

1

Try gdalwarp. From the documentation:

-srcnodata value [value...]: Set nodata masking values for input bands (different values can be supplied for each band). If more than one value is supplied all values should be quoted to keep them together as a single operating system argument. Masked values will not be used in interpolation. Use a value of None to ignore intrinsic nodata settings on the source dataset.

8
  • Thanks, The warp option does not seem to ignore nodata in the manner that I would like (contrary to oblique ref in lit!) - i.e. when downsampling to a single data value for each (higher res) group of cells (say 10x10 pixels) denoting elevation at coastlines. In such instances the downsampled output return nodata at the coastline when using the -srcnodata option. I need data values within each 10x10 group at coasts to be present in the output, so ignoring nodata falling within these coastal 10x10 groups of cells, with calculations unaffected by the nodata. I hope this clarifies.
    – ctlgeowp
    Commented Feb 2, 2017 at 14:33
  • Any feedback on this question appreciated.
    – ctlgeowp
    Commented Feb 6, 2017 at 14:46
  • Yes, Ive been thinking about this. So, to be crystal clear here, you want to downsample an image (from high to lower resolution) using a window of a given size (i.e. 3x3 window) whilst ignoring no data values?
    – GeoMonkey
    Commented Feb 6, 2017 at 17:56
  • 1
    Thanks. I need to resample topography data from 100m to 1km spatial resolution. However, the method needs to ignore nodata in the calculation in order that 1km output returns data values at coastlines. Currently (when using gdalwarp) nodata is returned at coastlines because nodata is present in the 10x10 group of 100m resolution input cells, as well as valid data values. Consequently, when compared, the higher res input has extra data at coasts which the lower res output excludes. I need to include these data values in my output.
    – ctlgeowp
    Commented Feb 6, 2017 at 18:58
  • ESRI ArcGIS allows nodata values to be ignored in such a way, although irritatingly does not always allow this facility to be combined with use of the optimal resampling method for any given sort of data. However, in any case I need an open source command line solution if available.
    – ctlgeowp
    Commented Feb 6, 2017 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.