ifellows / ROSM

R access to high resolution raster maps using the OpenStreetMap protocol. Dozens of road, satellite, and topographic map servers are directly supported, including CloudMade, Mapnik, Bing, stamen, and MapQuest. Maps can be plotted using either base graphics, or ggplot2. This package is not affiliated with the OpenStreetMap.org mapping project.
11 stars 2 forks source link

Provide alpha levels for maps #1

Open MichaelChirico opened 5 years ago

MichaelChirico commented 5 years ago

It's pretty easy to adjust the alpha level of the map if it's being used as a background, e.g.

alpha_to_hex = function(pct) sprintf('%02X', round(255*pct))

# bg_map: an OpenStreetMap object from openmap()
alpha = .5
if (alpha < 1) {
  alpha_hex = alpha_to_hex(alpha)
  for (tile_i in seq_along(bg_map$tiles))
    bg_map$tiles[[tile_i]]$colorData =
      paste0(bg_map$tiles[[tile_i]]$colorData, alpha_hex)
}

I'm not familiar enough with the Java interface to know if this can work at a lower level, but this seems to work pretty well from what I've been playing with thus far.

I'll file a PR if this sounds useful.

ifellows commented 5 years ago

sounds like it could be useful. Feel free to add a pull request