File: Class-SpatialPointsDataFrame.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 (22 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
setClass("SpatialPointsDataFrame",
	representation("SpatialPoints", data = "data.frame", coords.nrs = "numeric"),
	prototype = list(bbox = matrix(NA), proj4string = CRS(as.character(NA)),
		coords = matrix(NA), data = data.frame(), 
		coords.nrs = numeric(0)),
	validity = function(object) {
		#if (!inherits(object@data, "data.frame"))
		#	stop("data should be of class data.frame")
		if (nrow(object@coords) < 1)
			stop("no points set: too few rows")
		if (ncol(object@coords) <= 1)
			stop("no points set: too few columns")
		if (ncol(object@data) == 0)
			stop("data.frame is empty (possibly after stripping coordinate columns): use SpatialPoints() to create points-only object")
		if (nrow(object@data) != nrow(object@coords))
			stop("number of rows in data.frame and SpatialPoints don't match")
		n = length(object@coords.nrs)
		if (n > 0 && n != ncol(object@coords))
			stop("inconsistent coords.nrs slot")
		return(TRUE)
	}
)