-
Notifications
You must be signed in to change notification settings - Fork 292
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
Plot handling of empty sf points objects #436
Comments
Thanks for the clear example, should work now! |
Thanks very much - that's done it. In retrospect, I should have just dropped in the new |
@edzer I posted an issue about leaflet not handing empty data frames here rstudio/leaflet#452 but there was a question about whether the issue lives in sf like here. |
Hi,
sf
is looking fantastic - really nice to use. I'm running some code that plots different levels of a factor from alternative data sources to compare them. Sometimes, one source or another doesn't have a particular level, so I get an empty subset.I've found that the points plotting throws an Error for empty dataframes. Both linestring and polygon have transparent handling mechanisms: you can plot an empty
sf
object provided you give limits and you canplot(xx, add=TRUE)
for an emptysf
object. But the behaviour for point features is inconsistent and throws an error.The error is generated by this line in
plot.sfc_POINT
:The preceding lines handle the case where
length(x)
is zero, but this one doesn't. The otherplot.sfc_
functions have an if statement that traps empty cases. Some demo code to throw the error.The text was updated successfully, but these errors were encountered: