Skip to content

Regression: geom_sf() is now too aggressive in removing rows #3536

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

Closed
clauswilke opened this issue Sep 22, 2019 · 5 comments · Fixed by #3546
Closed

Regression: geom_sf() is now too aggressive in removing rows #3536

clauswilke opened this issue Sep 22, 2019 · 5 comments · Fixed by #3546
Milestone

Comments

@clauswilke
Copy link
Member

I just encountered this problem where geom_sf() removes polygons that are plotted without outline. This is a regression in current ggplot2 master. I assume it's due to #3491.

cc @yutannihilation

library(ggplot2)
library(sf)
#> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0

# make outline of the world in robinson coordinates
lats <- c(90:-90, -90:90, 90)
longs <- c(rep(c(180, -180), each = 181), 180)

robin_outline <- 
  list(cbind(longs, lats)) %>%
  st_polygon() %>%
  st_sfc(crs = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs") %>% 
  st_sf() %>%
  st_transform(crs = "+proj=robin +lat_0=0 +lon_0=0 +x0=0 +y0=0")

# plot with line
ggplot(robin_outline) +
  geom_sf(fill = "#56B4E950", color = "black")

# plot without line
ggplot(robin_outline) +
  geom_sf(fill = "#56B4E950", color = NA)
#> Warning: Removed 1 rows containing missing values (geom_sf).

Created on 2019-09-22 by the reprex package (v0.3.0)

@yutannihilation
Copy link
Member

Opps..., I think your analysis is correct. Sorry for the regression. Then, we probably need to define a handle_na() that handle NAs differently depending on the type of geometry.

@clauswilke
Copy link
Member Author

It seems to me that the true, real, underlying issue is that grid is overly conservative with checking input and doesn't gracefully degrade with missing or NA input in many cases.

@thomasp85 Any chance that we can get grid to be more tolerant to missing input, so we don't have to constantly code circles around grid's limitations?

Just one of many such examples:

library(grid)

grid.points(numeric(0), numeric(0))
#> Error in unit(x, default.units): 'x' and 'units' must have length > 0

Created on 2019-09-22 by the reprex package (v0.3.0)

@thomasp85
Copy link
Member

I won’t rule that out but the call is ultimately Paul’s — I’ll talk with him about it

@yutannihilation
Copy link
Member

yutannihilation commented Sep 23, 2019

#3537 is an attempt to fix this. But, I think I don't figure out what to do when the data is of mixed types of geometries. Any ideas...?

(edit: Sorry, I misunderstood about the process of when missing values are removed)

@lock
Copy link

lock bot commented May 5, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants