File: mapasp.R

package info (click to toggle)
r-cran-sp 1%3A0.9-66-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,696 kB
  • ctags: 123
  • sloc: ansic: 1,475; sh: 6; makefile: 5
file content (12 lines) | stat: -rw-r--r-- 477 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
mapasp <- function(data, xlim = bbox(data)[1,], ylim = bbox(data)[2,]) {
	# calculates aspect ratio for levelplot of geographic data,
	# using proportial units (compare eqscplot)
	if (!is(data, "Spatial"))
		stop("cannot extract coordinates bounding box from data")
	if (!(is.na(proj4string(data)) || is.projected(data)))
		return( (diff(ylim)/diff(xlim)) / cos((mean(ylim) * pi)/180))
	if (is.R() && version$major >= 2)
		return("iso")
	else
		return(diff(ylim)/diff(xlim))
}