[R-sig-Geo] Scaling the scale bar

Edzer Pebesma edzer.pebesma at uni-muenster.de
Thu Feb 27 15:38:28 CET 2014


Alex, thanks for the reproducible example -- please try:

 bb = bbox(States)
 Scale  <- list("SpatialPolygonsRescale",
           layout.scale.bar(),
           offset = c(bb[1,1] + 20000, bb[2,1] + 20000),
           scale  = 100000,
           fill   = c("white", "black"))
 l4 = list("sp.text", c(bb[1,1] + 20000, bb[2,1] + 10000), "0")
 l5 = list("sp.text", c(bb[1,1] + 120000, bb[2,1] + 10000), "100 km")
 spplot(States, "GEN", sp.layout = list(Scale, l4, l5))

For the next time, send a clean script (without the > and + in it), and
remember that as path separator "\\" only works on some operating
systems, "/" on all (I believe).

On 02/27/2014 12:18 PM, Alexander Sommer wrote:
> Dear list members,
> 
> I have got the feeling, that I missed something substantial about /layout.scale.bar/.
> 
> For example (not a pretty one, but might clarify my point)
> 
>> URL      <- "http://www.geodatenzentrum.de/auftrag1/archiv/vektor/vg250_ebenen/2012/vg250_2012-01-01.utm32s.shape.ebenen.zip"
>> td       <- tempdir()
>> setwd(td)
>> temp     <- tempfile(fileext = ".zip")
>> download.file(URL, temp)
>> unzip(temp)
>> dir_temp <- paste(tempdir(),
> +                   "\\vg250_0101.utm32s.shape.ebenen",
> +                   "\\vg250_ebenen",
> +                   sep = "")
>>
>> require(rgdal)
>> States <- readOGR(dsn      = dir_temp,
> +                   layer    = "vg250_bld",
> +                   encoding = "UTF8")
>> Scale  <- list("SpatialPolygonsRescale",
> +           layout.scale.bar(),
> +           offset = c(mean(States at bbox[1, ]), mean(States at bbox[2, ])),
> +           scale  = 0.1 * mean(States at bbox),
> +           fill   = c("white", "black"))
>>
>> spplot(States, "GEN", sp.layout = Scale)
> 
> draws a map of Germany’s States. Now, I would like to change the scale bar, so that it shows a distance of 100 kilometers. How can I assure that the length of the scale bar on the map corresponds with 100 kilometers in reality? (It might be too obvious or some other reason I do not get it. It feels already like the dumbest question to myself. So, my apologies in advance.)
> 
> Cheers,
> 
> Alex
> 
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany. Phone: +49 251
83 33081 http://ifgi.uni-muenster.de GPG key ID 0xAC227795

-------------- 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/20140227/93c6f064/attachment.bin>


More information about the R-sig-Geo mailing list