1

Following the example under:

library(sp)
library(automap)

loadMeuse()
demo(meuse)
# Ordinary kriging
kr = autoKrige(log(zinc)~1, meuse, meuse.grid)
spplot(kr$krige_output,'var1.pred')

enter image description here

I get a plot with an interpolated map and a legend. The map and the legend have logarithmic vales. In many cases, a logarithmic scaled map is what I want. However, a logarithmic legend is not very useful.

I would like to replace the legend numbers to exp(numbers). More like this(GRASS GIS): enter image description here

How can I can keep the logarithmic color scaling and get a readable legend in R?

  • Check this answer. It could help you – aldo_tapia Oct 11 '17 at 14:47
  • Added map with legend – Martinyt Oct 11 '17 at 14:50
  • aldo_tapia: Thanks for your link. This is nearly what i want, but the style parameter did not have a logarithmic option. I have added a map with the kind of legend I want. – Martinyt Oct 12 '17 at 8:59
1

You could coerce to a raster class object and back-transform the values on the fly. This will not result in a new object in the R environment.

library(sp)
library(raster)
library(automap)
loadMeuse()
demo(meuse)

kr = autoKrige(log(zinc)~1, meuse, meuse.grid)
plot(exp(raster(kr$krige_output, 'var1.pred')))

Alternately, you could just add a new column to the SpatialPixelsDataFrame that contains the back-transformed values.

kr$krige_output$var.pred.exp <- exp(kr$krige_output$var1.pred)
spplot(kr$krige_output,'var.pred.exp') 
  • Thank you. I see now that I was unclear in my post. I have updated it. I still want the logarithmic color scaling, but with a readable legend. I added a map which I made in GRASS GIS which have an option to set logarithmic color scaling of a map, but keeping the values - and thus the legend non-logarithmic. I would like to do this, if possible, in R. – Martinyt Oct 12 '17 at 8:51

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.