mitchelloharawild / ggquiver

R package for quiver plots in 'ggplot2'
http://pkg.mitchelloharawild.com/ggquiver
50 stars 3 forks source link

geom_quiver does not work together with geom_sf #9

Closed RS-eco closed 2 years ago

RS-eco commented 2 years ago

I want to create a plot with geom_quiver() and underlie a map. This works in the given example, when using borders():

# Removing automatic scaling
ggplot(seals, aes(x=long, y=lat, u=delta_long, v=delta_lat)) +
  geom_quiver(vecsize=NULL) +
  borders("state")

but, I want to plot something similar using geom_sf() instead:

library(maps); library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
states <- sf::st_as_sf(map('usa', plot = FALSE, fill = TRUE))
ggplot() + geom_quiver(data=seals, aes(x=long, y=lat, u=delta_long, v=delta_lat), vecsize=NULL) + 
  geom_sf(data = states)
#> Error: $ operator is invalid for atomic vectors

Unfortunately, this throws up an error: $ operator is invalid for atomic vectors

mitchelloharawild commented 2 years ago

Thanks for the bug report, this is related to how the package handles coordinate systems.

mitchelloharawild commented 2 years ago

Fixed, thanks. I'll prepare a CRAN patch release shortly.

mitchelloharawild commented 2 years ago

On CRAN now as v0.3.2 (https://github.com/mitchelloharawild/ggquiver/releases/tag/v0.3.2)