[R-sig-Geo] Adding Scale bar in the Image

Roger Bivand Roger.Bivand at nhh.no
Thu May 1 18:45:51 CEST 2008

On Thu, 1 May 2008, PUJAN RAJ REGMI wrote:

> Dear List,
> I would be thankful if anybody give me an way-out that How should can i 
> add scale bar in the RGB color image. Actually i want to use this image 
> for other purpose where i should mention the scale of the image.

I think that a few more details might help. This example uses methods from 
the sp package. Setup:

coordinates(meuse.grid) <- c("x", "y")
gridded(meuse.grid) <- TRUE

With lattice graphics:

l1 <- list("SpatialPolygonsRescale", layout.scale.bar(),
  offset = c(180500,329800), scale = 500, fill=c("transparent","black"))
l2 = list("sp.text", c(180500,329900), "0")
l3 = list("sp.text", c(181000,329900), "500 m")
spplot(meuse.grid, "dist", col.regions=grey.colors(20),
  sp.layout=list(l1, l2, l3))

With base graphics:

image(meuse.grid, "dist", col=grey.colors(20))
SpatialPolygonsRescale(layout.scale.bar(), offset = c(180500, 329800),
  scale = 500, fill=c("transparent","black"), plot.grid=FALSE)
text(180500, 329900, "0")
text(181000, 329900, "500 m")

layout.scale.bar() can take an argument setting the height of the scale 
bar, relative to the initial length of unity.

If this doesn't help, could you give an example of your problem using this 
or another accessible data set?


> Thanking you in advance
> Pujan
> _________________________________________________________________
> Make i'm yours.  Create a custom banner to support your cause.
> MSN_Make_IM_Yours
> 	[[alternative HTML version deleted]]

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no

More information about the R-sig-Geo mailing list