xmc811/mapchina

Issues with converting sf to dataframe and plotting

Opened this issue · 0 comments

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