5

I'd like to combine about a dozen rasters into one raster that contains the "summed" cell values where overlaps occur. In doing so, I need to be able to retain cells that either have no data, or that do not overlap with any other rasters.

FYI, Cell values are stored in an integer field in each raster.

I have tried the Raster Calculator, however it doesn't seem to do well with the "No Data" cells- it only creates summed cells where rasters overlap.

I have also tried the "Cell Statistics" tool, however the output feature it generates doesn't have any data.

4
  • Welcome to GIS SE! Would you be able to edit your question to let us know which GIS software you are using, please?
    – PolyGeo
    Mar 19, 2015 at 6:47
  • 1
    If all values in all rasters are positive, assign 0s to NODATA for all of them and do cell statistics SUM. Assign NODATA to result with zeros.
    – FelixIP
    Mar 19, 2015 at 8:32
  • Nodata (or null) in rasters is treated one of three ways. Some tools allow you to ignore nodata cells. Raster Calculator isn't one of them - when looking at a cell stack (ie same pixel in however many rasters) and performing a math operation on said stack, if any one of the cells is nodata, the result is nodata. So you need to convert nodata to 0 or do the Con is null thing on each raster within your calculation. If you go 0 but have negative values, you won't know if 0 is the sum or nodata in the result.
    – Chris W
    Mar 20, 2015 at 0:47
  • Related thread on Geonet: geonet.esri.com/thread/30795
    – Chris W
    Mar 20, 2015 at 1:02

4 Answers 4

4

The above mentioned approach to use Con(IsNull("raster"), 0, "raster") to transform NoData values to zero is indeed very smart. Using this approach, make sure that the extent for every processed raster is as big as the biggest extent. This can be simplified by using a python script and by setting the environment variable arcpy.env.extent = your_biggest_extent.

Another, probably faster way is to use the function arcpy.CellStatistics. Using this function, you can provide a list of rasters to process (1st argument), the statistics type "SUM" (2nd argument), and whether NoData values should be ignored or not (3rd argument). In your case, ignore NoData values by checking the box or by passing "DATA" as third argument. Thus, I used: arcpy.sa.CellStatistics(in_raster_list, "SUM", "DATA")

enter image description here

2

As you mentiond, NO DATA is not a problem. Thus in order to overcome the overlapping issue, you should modify the tool's processing extent to UNION OF ALL INPUTS, within tool's environment settings. See image belowExample

EDIT: The solution above might create a trade off between NoData values in overlapping areas and the inclusion of none-overlapping areas. Thus another solution is suggested. Use the Mosaic to a new Raster tool - with sum operation for the overlapping cells of a raster. see image: Mosaic

2

Try to apply Con(IsNull("raster"), 0, "raster") to the raster that has "NoData" value.

To tell you in the detail, here is my explanation. First, You have to make sure that all rasters have the same extent as you desire (for instance, you can set the extent to the largest raster's extent). To change the extent of a raster, you can simply right-click on the raster layer, click Properties, go to Extent tab, and there you can set the raster's extent.

Second, simply use Raster Calculator. For example, I want to sum "raster 1" and "raster 2". I have set them have the same extent, yet raster 2 contains so many "NoData" cell. So my equation goes like this: "raster 1" + Con(IsNull("raster 2"), 0, "raster 2")

Con(IsNull) function changes "NoData" cell values to zero.

1
  • I think this answer is on the right track with Con, but not with altering the extent of a raster through its properties tab. Change the extent of a raster without altering cell size (or even with) and you're essentially resampling and changing the data. That may be necessary, but that's not the best way to go about it.
    – Chris W
    Mar 20, 2015 at 1:02
0

The above answers will not help if there is a difference between "NoData" and zero value. If you want to preserve those "NoData" cells and distinguish cells where no data was collected from those where data was collected and the answer is zero, use reclassify to replace NoData cells with a value that can't possibly occur anywhere else in the stack. For example, if the data values in the raster calculator input layers range from 0 - 1000, replace NoData with 900000. Any cell in the output that has a value higher than that has a "NoData" cell in at least one of the input rasters. Then you can change those back to no data in the output once again using reclassify tool.

Your Answer

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

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