Maps – tmap, leaflet, sf, spdplyr, cartography, etc.
- https://github.com/mdsumner/spbabel
- https://github.com/mdsumner/spdplyr
- https://github.com/edzer/sfr
- https://cran.r-project.org/web/packages/tmap/index.html
- https://github.com/Groupe-ElementR/cartography
… and the list goes on: see my blog post on the issue (kind of).
Some folks are putting ideas together on the topic.
U.S. spatial data: https://github.com/martinjhnhadley/statesRcontiguous
The easiest solution might be to teach only one method, possibly one that works with both choropleths and geocoded points.
Pinging @rCarto in case he might have some suggestions.
IMHO the packages you're mentionning are dealing with very different tasks (as the rspatial discussion makes it clear), using very different paradigms and operating at vastly different levels of maturity.
So I think in the context of an introductory workshop to R, it is important to focus on 1/ a more-or-less coherent paradigm 2/ stable solutions 3/ one of the steps of the workflow @tim-salabim identified.
My advice at this point would be to focus on the rgdal/sp tools to import and contain data, as this is definitely what's most mature at the time. sf is very, very promising but definitely lacks real-worl use-cases at the time, and doesn't allow mapping without converting back to a Spatial* class. Also, spdplyr fits in nicely here.
Then you have two great mapping packages IMHO, cartography and tmap. My personal opinion is that ggplot2 is not really the way forward for mapping, but I know a lot of people, including you, would disagree. The advantage of using ggplot is that students can learn and use a coherent syntax. Now tmap uses a syntax that is not so different, and offers in my opinion a much wider range of possibilities. cartography is also great, because it's made by great geographers, and also have documentation in French (I have to say documentation is definitely one of the cons of tmap at the moment).
I agree that the cited packages are different and unequally advanced.
More thinking aloud below. Basically, to me, there's three choices (leaving Leaflet out).
-
Tinkering with
ggplot2+ helpers.spbabelandspdplyrare ultra-interesting to me. I've briefly exchanged with @mdsumner on Twitter, and read his notes: he is making a lot of progress on releasing "tidy spatial" code. He has also releasedggpolypath, whichggspatialis based upon.All these tools are nice, but as far as I can tell, none of them are stable. They help
ggplot2deal with spatial data (as doesggaltby improving on coordinates handling), but they help "from the outside". Helping "from the inside" would mean altering/re-thinking many of theggplot2fundamentals (my blog notes contain some hints about that).I hope that, at some point, all these tools will get bundled together in some nice way. For now, the
ggplot2microverse hasggmapandgeom_map, and basic polygon fortifying (apparently with some bugs here and there). That's good enough for many, many basic cases of drawing maps. -
Keeping an eye on
sf. I hope forgeom_sfat some point. It's in the works, but it's at stage 1 out of 10 right now. -
cartographyandtmap. Both of them look like good choices. Thetmapsyntax has my preference, because it "feels" tidy. But again: at least 75% of thetmapvignette can be done inggplot2, and that's a plus if you are teaching a syntax with the hope that it will serve in many circumstances.
I can help you ggplot with sf already, if needed. It's good for learning if nothing else.
Hi @mdsumner
Thanks for offering to help.
If you look at the draft syllabus, there is a section on data visualization.
I would like to include a single exercise involving maps, ideally using GADM and involving both choropleths and a 'bubble map' or something like that.
My guess is that the exercise would start with ggplot2/ggmap and then switch to something more appropriate for spatial data.
Here are some candidates for the exercise:
- https://github.com/davben/arvig
- https://github.com/SciutoAlex/Historical-Travel-of-US-Secretary-State
Feel free to chime in if you have suggestions for the exercise :)
Cheers,
ƒ
P.S. @joelgombin and @rCarto are naturally welcome to submit ideas too!
geom_sf is already here in the dev ggplot2: https://github.com/tidyverse/ggplot2/tree/sf
and dev mapview and now leaflet also supports sf: https://github.com/rstudio/leaflet/pull/350
So it will be pretty easy to use, unless you need to teach before those updates are released to CRAN. I probably won't get to explore those links but feel free to ask specific questions.
https://github.com/tidyverse/ggplot2/tree/sf
This rocks, I'll explore and see if I can teach with that (the workshop starts in February).
This looks like a map that I'd be happy to reproduce with R:
https://visionscarto.net/global-nuclear-power-database
I'm posting some other suggestions in the other issues of this repo.
Well, I may have some ideas on how to reproduce this map. I'll let you know if I managed to.
Many thanks!
The conversation over at tim-salabim/rspatial/issues/9 is getting somewhere.
@edzer just posted a detailed text that links to
- http://r-spatial.org/
- http://rspatial.org/
and all the other relevant places to monitor.
The rspatial.org website (which still has a few work-in-progress missing sections) has nice examples of using spplot from sp/raster.
@edzer has also written a very nice list of sp demos:
- https://edzer.github.io/sp/
… and is continuing the work on sf – 2017 update:
- http://r-spatial.org/r/2017/01/12/newssf.html
Last thing: the new repo to watch for discussions is r-spatial/discuss.
Replaced by #30