Not able to project map with ggplot2

Hey R gurus,

I'm bringing together multiple layers of remote sensing and gridded data to make maps in high latitude locations. I'm not having success with using projections within ggplot2 and at this point am thoroughly confused so figured it's time to post here ....
I think I'm misunderstanding how this all fits together and probably need to reproject the data or use more specific parameters.
For this example I just used "volcano" as a fake dataset in the approximate geographic area I'm making maps for (northern Canada).

library(ggplot2)
library(reshape2)
v <- melt(volcano)

# Altering volcano data to have approx lat and lon range of my data
v$Var1 <- (v$Var1 /10) - 130
v$Var2 <- (v$Var2 /10) + 65
colnames(v) <- c("long","lat","topo")

# This works
ggplot() + 
  geom_tile(data = v, aes(x = long, y = lat, fill = topo)) +
  labs(fill = "Elevation (m)") + xlab(NULL) + ylab(NULL) +
  coord_quickmap(xlim = c(-129.9, -121.3), 
                 ylim = c(65.1, 71.1)) 

# Now trying to map with some projection
g <- ggplot() + 
  geom_tile(data = v, aes(x = long, y = lat, fill = topo)) +
  labs(fill = "Elevation (m)") + xlab(NULL) + ylab(NULL) 
# Anything I try seems to freeze and not plot...
g +
  # coord_map("orthographic")
  # coord_map("ortho", orientation = c(90, 0, 0))
  coord_map("conic", lat0 = 65)

Hi @ach,
I don't think you are doing anything wrong - your code runs fine on my machine but the re-projection is SLOW.
help(coord_map) says that "considerable computation" is required. On my machine it takes ~ 11 seconds:

Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz 2.21 GHz, 16 Gb RAM.

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

YMMV!

Thanks @DavoWW. Coming back to it I'm able to get my example to run today as well at least...just over 11 seconds.
My info:
Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz, 1896 Mhz, 16 Gb RAM

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

However it's been ploughing away with my real dataset for over 15 minutes and no idea when it'll finish, so I think I'll have to find another way around this projection issue. (Or just switch to another program for this mapping)
Cheers!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.