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

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sun Feb 28 20:33:46 CET 2016


Please don't reply to an existing thread with a new topic!

On 28/02/16 18:30, Agustin Lobo wrote:
> I get an error at installing from github on MacOSX10.9.5 that I have reported
> to https://github.com/environmentalinformatics-marburg/mapview/issues
> and it is being dealt there.
> 
> With the cran version mapview_1.0.0, I have problems to select the
> type of map, I always get the OSM one. I've tried both
> nica <- getData("GADM", country="NIC", level=0)
> spplot(mapView(nica["ISO"]),colorkey=FALSE,
>        map.type="Thunderforest.Landscape")
> as in your example and
> spplot(mapView(nica["ISO"],map.types="Thunderforest.Landscape"),
>      colorkey=FALSE)
> 
> Note that mapView() selects the correct map:
> mapView(nica,map.types="Thunderforest.Landscape" )

Why raise this here again?

> 
> Also, it seems to me that the mapView() display is always projected
> (perhaps Pseudo Mercator epsg:3857 ?) even if the spatial object used
> in mapView() has another CRS.
> In other words
> mapView(nica)
> is displayed on Pseudo Mercator even if
> projection(nica)
> [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
> 
> Am I wrong?

The mapview docs at
http://environmentalinformatics-marburg.github.io/web-presentations/20150723_mapView.html
(linked from the github main page) say "Note that in order to render
properly, all layers need to be re-projected to leaflet’s underlying web
mercator projection".

Welcome to the world of web maps! leaflet, ggmap, RGoogleMaps all do
this; mapview builds on leaflet.

You probably also noted issue #13 which I filed a week before yours,
https://github.com/environmentalinformatics-marburg/mapview/issues/13
which discusses mapview support for other projections.

Even although there is a proj4leaflet extension, there is right now
hardly any tile server (backdrop) support for non-web mercator projections.

> 
> Finally, is there a way of including an scale bar? Actually, this
> option would be interesting even for interactive display.

Looks like leaflet has support for this but that the R leaflet package
doesn't -- http://leafletjs.com/reference.html#control-scale -- maybe
something you can contribute to leaflet and/or mapview?

> 
> Thanks
> Agus
> 
> On Fri, Feb 26, 2016 at 3:32 PM, Chris Reudenbach
> <reudenbach at uni-marburg.de> wrote:
>> 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
>>
>>
>> _______________________________________________
>> 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
> 

-- 
Edzer Pebesma
Institute for Geoinformatics  (ifgi),  University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/
Spatial Statistics Society http://www.spatialstatistics.info

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20160228/4cd44144/attachment.bin>


More information about the R-sig-Geo mailing list