[R-sig-Geo] resolution of openmap() raster layers

Chris Reudenbach reudenbach at uni-marburg.de
Fri Feb 26 15:32:31 CET 2016


Agus,

Mapview is using leaflet as engine. Due to this you will have the 
control icons on the map because first of all it is designed for 
interactive mapping within RStudio/R.

I think there are two different approaches to save your maps:

If you want to have a dump of the mapviewobject (but including the 
graphical buttons) you'll find a descriptat stackoverflow
http://stackoverflow.com/questions/31336898/how-to-save-leaflet-in-rstudio-map-as-png-or-jpg-file


You may also use  the spplot function from mapview which is designed for 
basic static mapping and to make usable the adavantages of spplot.

Note even if you are dealing with the mapview map object the spplot 
function  uses the Openstreetmap package for retrieving  the background 
maps  (e.g. 
http://www.inside-r.org/packages/cran/OpenStreetMap/docs/openmap). You 
can use the spplot syntax for designing your maps. Up to now this static 
plotting function is still pretty  basic but you may have a try:
spplot(mapView(nica["POP2000"]),colorkey=FALSE,  lwd= 15, alpha.regions 
= 0.9,
map.type="stamen-watercolor" )

I think for using the spplot it is better to install the current stable 
from github:
library(devtools)
install_github("environmentalinformatics-marburg/mapview", ref = "master")


cheers chris


Am 26.02.2016 um 12:27 schrieb Agustin Lobo:
> Stunning!
> Can I remove the buttons for saving to a bmp file?
> What attribution should be used for publishing?
> Agus
>
> On Thu, Feb 25, 2016 at 7:42 PM, Chris Reudenbach
> <reudenbach at uni-marburg.de> wrote:
>> Hi,
>>
>> if you just want to map the data, mapview could be an option that among
>> others avoid the pixel stretching.
>>
>> require(mapview)
>> require(raster)
>> nica <- getData("GADM", country="NIC", level=0)
>>
>> mapview(nica)
>>
>> mapview(nica,zcol = "POP2000", color = "#FFA500", lwd= 5, alpha.regions =
>> 0.4)
>>
>>
>> cheers Chris
>>
>>
>>
>>
>> Am 25.02.2016 um 18:49 schrieb Barry Rowlingson:
>>> On Thu, Feb 25, 2016 at 5:11 PM, Agustin Lobo <alobolistas at gmail.com>
>>> wrote:
>>>> Is there any way to download the raster layers
>>>> of openmap() with an increased resolution?
>>>> I find the quality of the labels very low,
>>>> or am I doing something wrong? i.e.
>>>>
>>>> require(raster)
>>>> require(mapmisc)
>>>> nica <- getData("GADM", country="NIC", level=0)
>>>> nicabg <- openmap(nica, path="landscape")
>>>> plot(nicabg)
>>>    Map tiles from OpenStreetMap and other map tile providers are images
>>> designed to be shown at a fixed resolution. When you plot them in an R
>>> graphics window you could be stretching them so that each pixel in the
>>> original maps to 1.273 pixels on your screen. So some kind of
>>> interpolation or nearest neighbour replacement has to be done, and
>>> this makes text labels look bad. Other line work will look bad too.
>>>
>>>    If you try and download more map tiles at a higher resolution then
>>> you'll find the labels are now way too small, because what you've
>>> downloaded are map tiles designed for a higher zoom level on a web
>>> browser. Web map browsers have a fixed set of zoom values that
>>> correspond to the resolution of the map tiles. With an R window, you
>>> are free to choose odd zoom factors that give the ugly behaviour.
>>>
>>>    If you can resize your R window exactly right then you might get
>>> something that looks good!
>>>
>>>    The alternative is to build a background map yourself from
>>> OpenStreetMap *vector* data and some code and some styling. Or use a
>>> map tile provider that doesn't have text labels and add them to
>>> selected places with R graphics commands. Lines and polygons will
>>> still be stretched and a bit "jaggy" but our eyes don't notice this as
>>> much as badly scaled text.
>>>
>>> Barry
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list