Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Plotting sf objects in ggplot2 #5

Open
thomasjwood opened this issue Apr 17, 2017 · 1 comment
Open

Plotting sf objects in ggplot2 #5

thomasjwood opened this issue Apr 17, 2017 · 1 comment
Assignees
Labels

Comments

@thomasjwood
Copy link

wonderful package, hope you could figure out a problem I'm having fortifying your sf objects for plotting in ggplot2.

library(tilegramsR)
library(ggplot2)
data(sf_DKOS_CD_Hexmap_v1.1)
d2 <-  fortify(as(sf_DKOS_CD_Hexmap_v1.1, "Spatial"),
               region = "STATENAME")

ggplot() + 
  geom_polygon(aes(x = long, y = lat, group = group, fill = id),
               data = d2,
               color = "black") + 
  guides(fill = FALSE) 

which returns

image

i wonder--why are there those superfluous interior borders in CA, TX, WI, etc?

@bhaskarvk
Copy link
Owner

Looks like r-spatial/sf#275. For now , call the precision method before converting it into spatial.
On a sidenote if you build 'ggplot2' from GH repo (sf branch) devtools::install_github('tidyverse/ggplot2', ref='sf'), you will be able to use sf object as is, w/o needing to cast them to sp objects.

I'll keep this defect open for tracking purposes.

@bhaskarvk bhaskarvk self-assigned this Apr 17, 2017
@bhaskarvk bhaskarvk added the bug label Apr 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants