3

I need to resample a binary image of linear features like roads, rivers to a coarser resolution, conceptually combining multiple pixels into a single one. 1 indicates presence of the linear feature, and 0 otherwise.

To this end, I was wondering if there is an existing function for resampling a raster such that if any one of the smaller pixel is a one, the output resampled cell is one (, and zero otherwise)? In other words, I want the resampled cell to be the maximum of its constituent cells.

In ArcToolbox, the resample tool only have: NEAREST, BILINEAR, CUBIC, and MAJORITY. None fits the above need.

Is there a way to do this in ArcGIS (or other environments like PostGIS)?

  • Are you after a raster where if any merged cells contain 1 the result is 1? Taking this in another direction, can you re-rasterize the lines with the required resolution? I can only think of 1 way to do this (guaranteed) but it's very messy.. perchance is the new pixel size a multiple of the existing pixel size? – Michael Stimson May 29 '15 at 0:02
  • Yes, both input and resampled rasters are binary. pixels are 1 and 0's only. – tinlyx May 29 '15 at 0:08
  • 1
    Set 0 as null (for speed), do raster to point at low resolution then point to raster with the desired resolution.. you will need to manipulate your environment settings for this operation (cellsize, snap raster, output NoData value...) cell assignment is MAXIMUM – Michael Stimson May 29 '15 at 0:12
  • @MichaelMiles-Stimson That seems a good idea. Please post it as an answer with the specifics if you will. – tinlyx May 29 '15 at 0:16
  • 1
    Give it a try and see if it meets your requirements, then you can post it with your experience. If you treat your binary as a float then resample to the new size then use Con(Resample > 0, 1, 0) that should work too... try them both and see. I'm a bit busy to be doing anything more than comments at the moment. – Michael Stimson May 29 '15 at 0:23
2

This is a (partial) solution I have found so far. There is an "aggregate" tool under spatial analyst which allows one to combine multiple cells into one. It has options to use the SUM, MEAN, MEDIAN, MAXIMUM, MINIMUM of the collection of smaller cells.

This seems to work (and work only) for cases where the target resolution is an exact multiple of the original resolution.

  • 1
    +1 This is a good answer. For a different target resolution one would first need to resample the original raster--perhaps to a slightly smaller cellsize--to make the target resolution an integral multiple, and then proceed either with the "Aggregate" tool or with Block statistics. An alternative method would aggregate using a mean and then--if desired--postprocess that with a thresholding operation. That would be a little more flexible. – whuber May 29 '15 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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