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

Errors when plotting sfs (without crs - may be issue) #2199

Closed
Robinlovelace opened this issue Jul 11, 2017 · 6 comments
Closed

Errors when plotting sfs (without crs - may be issue) #2199

Robinlovelace opened this issue Jul 11, 2017 · 6 comments
Labels
bug an unexpected problem or unintended behavior layers 📈

Comments

@Robinlovelace
Copy link

Robinlovelace commented Jul 11, 2017

devtools::install_github("tidyverse/ggplot2", ref = "sf")
library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
library(ggplot2)
point_sfc = st_sf(st_sfc(st_point(c(1, 1))))
ggplot() + geom_sf(data = point_sfc) + coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 
  1.4))
#> Error in if (st_is_longlat(crs)) bb = trim_bb(bb, margin): missing value where TRUE/FALSE needed
@Robinlovelace
Copy link
Author

And when plotting multiple points:

library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
library(ggplot2)
point_sfc = st_sf(st_sfc(st_point(c(1, 1)), st_point(c(1, 2))))
ggplot() + geom_sf(data = point_sfc) + coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 
  1.4))
#> Error in if (st_is_longlat(crs)) bb = trim_bb(bb, margin): missing value where TRUE/FALSE needed

@Robinlovelace
Copy link
Author

Robinlovelace commented Jul 11, 2017

And (unexpectedly) MULTIPOINTs:

devtools::install_github("tidyverse/ggplot2", ref = "sf")
#> Skipping install of 'ggplot2' from a github remote, the SHA1 (1d6dd5c2) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
library(ggplot2)
point_sfc = st_sf(st_sfc(st_multipoint(rbind(c(1, 0.6), c(1.4, 1.1)))))
ggplot() + geom_sf(data = point_sfc) + coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 
  1.4))
#> Error in if (st_is_longlat(crs)) bb = trim_bb(bb, margin): missing value where TRUE/FALSE needed

@Robinlovelace
Copy link
Author

Demo of how these could look and to show reproducibility with base plot:

library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
x = st_sf(st_sfc(st_point(c(1, 1))))
plot(x)

x = st_sf(st_sfc(st_point(c(1, 1)), st_point(c(1, 2))))
plot(x)

x = st_sf(st_sfc(st_linestring(rbind(c(0.8, 1), c(0.8, 1.2), c(1, 1.2)))))
plot(x)

@Robinlovelace Robinlovelace changed the title Error when plotting a single sf point Errors when plotting sfs (without crs - may be issue) Jul 11, 2017
@hadley
Copy link
Member

hadley commented Jul 13, 2017

@edzer this error appears to be coming from inside st_graticule(). Can you take a look please?

@hadley hadley added bug an unexpected problem or unintended behavior layers 📈 labels Jul 13, 2017
edzer added a commit to r-spatial/sf that referenced this issue Jul 13, 2017
@edzer
Copy link
Contributor

edzer commented Jul 13, 2017

@Robinlovelace pls check it out

@Robinlovelace
Copy link
Author

Works like charm - thanks for the fast fix:

devtools::install_github("tidyverse/ggplot2", ref = "sf")
#> Skipping install of 'ggplot2' from a github remote, the SHA1 (1d6dd5c2) has not changed since last install.
#>   Use `force = TRUE` to force installation
devtools::install_github("r-spatial/sfr")
#> Skipping install of 'sf' from a github remote, the SHA1 (707704eb) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
library(ggplot2)
p1 = st_sf(st_sfc(st_point(c(1, 1))))
ggplot() + geom_sf(data = p1) + coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 1.4))

p2 = st_sf(st_sfc(st_point(c(1, 1)), st_point(c(1, 2))))
ggplot() + geom_sf(data = p2) + coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 1.4))

mp = st_sf(st_sfc(st_multipoint(rbind(c(1, 0.6), c(1.4, 1.1)))))
ggplot() + geom_sf(data = mp) + coord_sf(xlim = c(0.6, 1.6), ylim = c(0.4, 1.4))

@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior layers 📈
Projects
None yet
Development

No branches or pull requests

3 participants