0

How do I plot a background map from a .tif file and then add points on top of the map from a different dataframe? Since there are quite a lot of points I would also like to add a second colour gradient for improved visibility, and this is where I am running into the problem. According to here ggplot prevents this on purpose, but can be worked around using the new_scale_colour function. But this seems to not work unfortunately and also seems a little bit hacky. Are there any better solutions? I also tried to convert the .tif file to a df directly but since its quite big I'd rather not do that.

This is the solution I have right now which uses gplot from rasterVis.

gplot(map) + geom_tile(aes(fill = value)) +
  facet_wrap(~ variable) +
  scale_fill_gradient(low = 'white', high = 'darkgray') +
  coord_equal()+
  new_scale_color()+
  geom_point(data=df, aes(x=Location_E, y=Location_N))+
  scale_fill_gradient(low="lightblue", high="blue")

Looking forward to your replies.

Nui
  • 101
  • 1
  • 6

0 Answers0