Search code examples
rparallel-processingstackr-raster

How to retain RasterStack layer names when using ClusterR reclassify?


When I try to reclassify a RasterStack using ClusterR, the output contains names Layer.1, Layer.2, Layer.3 instead of the original stack layer names salinity, temp, depth. Here is the command that I am using:

stackr <- clusterR(stack, reclassify, args=list(rcl=cbind(NA, 0)))

How can I retain the original names in the output stack?

Edit: I just figured out that you can reassign the names from the original stack like this:

names(stackr) = names(stack)

However, is it guaranteed that the layers in the output stack are in the same order as the original after parallel-processing?


Solution

  • I figured it out. It's simply a matter of reassigning the names from the original stack.

    names(stackr) = names(stack)