grantmcdermott / grantmcdermott/tinyplot
Support `sf` objects for maps?
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 427
- Forks
- 25
- Avg merge
- 22h 54m
- Merged PRs (30d)
- 28
Description
Hi @grantmcdermott, @vincentarelbundock and @zeileis, I'm just wondering whether support for sf objects is on the roadmap. ggplot2 can be quite slow when drawing maps with several elements (say all the US counties + fill by variable + points). To clarify, creating the map is not slow but printing it can easily take 15-20 seconds or more and I'm wondering if a base plot would be faster for this.
A complete support would probably be complicated, but here's a very simple example:
library(ggplot2)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
ggplot(nc) +
geom_sf(aes(fill = AREA))

nc[, "AREA", drop = FALSE] |>
plot()

Being able to do plt(~ AREA, fill = "by", type = "map") would be great (contrarily to the syntax for density plots, we'd only need to have one variable in the formula here).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied R examples and review the plt() entry point, especially formula handling and the fill and type arguments. Compare the requested sf map workflow with the existing base plotting path; done would mean a defined scope for sf support and a working way to use one formula variable with fill="by" and type="map".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100