Unless there's something I don't see, our current overload for getindex(layer1, layer2) (used when calling layer1[layer2]) can only return exactly the same layer as layer1, which makes it a bit useless.
Calling _layers_are_compatible(layer1, layer2) means the overload only works when the two layers have the same size AND bounding coordinates. But then we return layer1 with the bounding coordinates of layer2, which are necessarily the same as layer[1].
I think this overload would be more useful if it allowed to subset a layer based on another layer if both have the same stride and the 2nd one is entirely contained in the first one, as in the example below.
l1, l2 = SimpleSDMPredictor(WorldClim, BioClim, 1:2)
l3 = SimpleSDMPredictor(WorldClim, BioClim, 1; left = -145.0, right = -50.0, bottom = 20.0, top = 75.0)
stride(l1) == stride(l3) # same stride
l4 = l1[l2] # works
l4 == l1 # but it's exactly the same
l5 = l1[l3] # doesn't work as layers have different sizes, but should work
l5 == l3 # should return true
Unless there's something I don't see, our current overload for
getindex(layer1, layer2
) (used when callinglayer1[layer2]
) can only return exactly the same layer aslayer1
, which makes it a bit useless.Calling
_layers_are_compatible(layer1, layer2)
means the overload only works when the two layers have the same size AND bounding coordinates. But then we returnlayer1
with the bounding coordinates oflayer2
, which are necessarily the same aslayer[1]
.I think this overload would be more useful if it allowed to subset a layer based on another layer if both have the same stride and the 2nd one is entirely contained in the first one, as in the example below.