Skip to content
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

Issues with converting sf to dataframe and plotting #10

Open
bbarker505 opened this issue Jul 27, 2023 · 0 comments
Open

Issues with converting sf to dataframe and plotting #10

bbarker505 opened this issue Jul 27, 2023 · 0 comments

Comments

@bbarker505
Copy link

Hi,
I just wanted to let you know about an issue that I found and couldn't resolve. For consistency with the rest of my code, I was attempting to convert your "mapchina::china" object to a dataframe using the following code. However, when I plot the results, the polygon lines are not all correct (some lines are connecting to the wrong places).

china_df <- mapchina::china %>%
group_by(Code_Province) %>%
summarise(geometry = st_union(geometry)) %>%
sf_to_df(fill = TRUE) %>%
rename("long" = x, "lat" = y, "group" = sfg_id)

ggplot(china_df, aes(x=long, y=lat)) +
geom_path(aes(group=group), color="gray20", lwd = 0.35)

Best,
Brittany

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant