Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
plotting points with geom_sf (simple features format) #2037
copied from r-spatial/sf#88
HI, I tried point and line geometry with (the experimental) 'geom_sf' for plotting maps (in simple features format ):
I am a bit confused by the behaviour of aes in geom_sf, with
line color of the circles changes, I want a fill....
more confusing, I still want a fill.... :-), how can I do that ?
referenced this issue
Feb 11, 2017
does this works ? (I am not very familiar with dput)
A simple script version:
Here's a minimal reprex:
cities <- tibble::tribble( ~ lon, ~ lat, ~ name, ~ pop, 5.121420, 52.09074, "Utrecht", 311367, 6.566502, 53.21938, "Groningen", 189991, 4.895168, 52.37022, "Amsterdam", 779808 ) %>% sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) lines_sfc <- sf::st_sfc(list( sf::st_linestring(rbind(cities$geometry[], cities$geometry[])), sf::st_linestring(rbind(cities$geometry[], cities$geometry[])) )) lines <- sf::st_sf( id = 1:2, size = c(10,50), geometry = lines_sfc, crs = 4326 ) ggplot() + geom_sf(aes(size = pop), data = cities) + geom_sf(aes(colour = size), data = lines)
The problem is that the geom needs to learn what legend to use from the data, but there's currently no way to pass this information between the two function calls. The documentation for Geom notes: