File: pcent.R

package info (click to toggle)
r-cran-maptools 1%3A0.7-34-2
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 2,184 kB
  • ctags: 232
  • sloc: ansic: 3,014; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Copyright 2000-2001 (c) Nicholas Lewin-Koh 
# modifications 2001-2003 Roger Bivand


get.Pcent <- function(theMap) {
  .Deprecated("", package="maptools", msg="exrtact centroid from SpatialPolygons object;\nobjects other than Spatial objects defined in the sp package are deprecated")
  p.cent <- function(poly, flag) {
    cent <- .External("RshpCentrd_2d", poly, as.integer(flag),
      PACKAGE="maptools")
    cent
  }
  if (!inherits(theMap,"Map")) stop("not a Map object")
  theShapes <- theMap$Shapes

  if (attr(theShapes,'shp.type') != 'poly')
    stop("Must be a valid polygon shapelist")

  cent<-lapply(theShapes, p.cent, 0)
  return(matrix(unlist(cent), ncol=2, byrow=TRUE))
}