-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plotting points with geom_sf (simple features format) #2037
Comments
Could you help me about by making a very simple point dataset that I could include in a unit test? |
sure, |
It's more the opposite - I need a few lines of code to that create a dataset with ~4 points without any external dependencies |
does this works ? (I am not very familiar with dput)
|
A simple script version:
|
Yeah, the script version is much better, thanks. |
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[[1]], cities$geometry[[2]])),
sf::st_linestring(rbind(cities$geometry[[2]], cities$geometry[[3]]))
))
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:
|
Some additional context as well. It looks like shape is not currently supported by
|
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 ):
this gives:

I am a bit confused by the behaviour of aes in geom_sf, with
aes(size=cadmium)
I expected varying size of dots, instead it gives me varying size of line thickness of the circles.How do I change type and size of dots?
meuse_sf %>% ggplot() + geom_sf(aes(color=cadmium))
gives:line color of the circles changes, I want a fill....
meuse_sf %>% ggplot() + geom_sf(aes(fill=cadmium))
this gives:
more confusing, I still want a fill.... :-), how can I do that ?
The text was updated successfully, but these errors were encountered: