1

I am creating air quality maps using two approaches.

One of them gives slightly better results when validated against measurements but there are significant spatial gaps present in the output. Layer with gaps

The other approach gives a spatially continuous layer. Continuous layer

My goal is to combine the two layers by taking as much information as possible from the first layer and fill in the missing data with information from the second layer. I would like to avoid simply averaging the layers as this 1) does not retain the information from the more "valuable" layer, 2) leads to sharp breaks between the layers at some of the edges (as shown in the last picture where unnatural squares appear).

Merged layer

Is there any more sophisticated method to combine data in this way?

For example by assigning weights to the border data to combine it gradually.

Ultimately I would like to accomplish this in R.

1 Answer 1

1

Just for visual purpose, you can create a linear model to adjust data. Sample data:

library(RStoolbox)
library(raster)

data(lsat)

hq <- lsat[[2]]
lq <- lsat[[3]]

hq[1:(88970/2)] <- NA

plot(mosaic(hq,lq, fun = mean))

enter image description here

Mosaic doesn't 'look good', so adjust data of continuous layer with lm:

df <- as.data.frame(stack(hq,lq))

names(df) <- c('y','x')

lm_model <- lm(y~x,df)
coefficients(lm_model)

## (Intercept)           x 
## 14.7880063   0.5354473 

lq2 <- calc(lq, fun = function(x) x*0.5354473 + 14.7880063)

lq2 <- mask(lq2, mask = is.na(hq), maskvalue = 0)

plot(mosaic(hq,lq2, fun = mean))

enter image description here

I used mask to obtain a layer with data from continuous layer where the first layer has no values.

2
  • Thank you for your answer. I have also thought of linear regression but it still doesn't resolve the main issue. I need to resolve the problem at the edges between the two layers where the values "jump".
    – Janina
    Commented May 23, 2018 at 10:45
  • gis.stackexchange.com/questions/181011/… this approach could be useful
    – aldo_tapia
    Commented May 23, 2018 at 20:38

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.