ropensci / osmplotr

Data visualisation using OpenStreetMap objects
https://docs.ropensci.org/osmplotr
132 stars 21 forks source link

tidyverse and SF experiments #36

Closed richardbeare closed 1 year ago

richardbeare commented 6 years ago

Hi, This isn't intended to be a ready-to-use pull request - more to let you have a look at what I've been testing.

The original problem that lead me to think about this was using multiple mappings for single object types - e.g. roads might have a group membership, corresponding to colour, and a continuous measure, such as traffic load, speed limit, etc, that should be displayed as either size or transparency. In principle an easy problem in ggplot2.

So, I've done some playing around with the more "traditional" ggplot2 approach. It turns out that the stars have aligned and most of the pieces are already in place. These are:

  1. a geom_sf in the development version of ggplot2
  2. lots of tidyverse verbs supported by the sf package, and the fact that sf uses special data frames.

There are two files in this PR - a Rmd and the supporting R code. No nice formatting or thorough testing, just a demo of ideas.

Notes - the ggplot2 support for sf is preliminary, and there are issues around where things like xlim get set. These are different to how osmplotr is currently set up, and may be annoying.

sf gives lots of warnings about the assumptions it makes. I haven't attempted to turn them off.

Enjoy!

mpadge commented 6 years ago

This looks fabulous! I'm away from "normal" work duties this week, but will definitely check it out as soon as i return next week. Thanks in advance