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

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Feb 25 18:49:47 CET 2016


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



More information about the R-sig-Geo mailing list