[R-sig-Geo] Problem finding the centroid of a polygon with get.Pcent
Roger.Bivand at nhh.no
Fri May 23 18:13:54 CEST 2008
On Fri, 23 May 2008, Mauricio Zambrano wrote:
> Dear List,
> For finding the centroid of a catchment, I tried with the function:
> but I got the following error:
> Error en get.Pcent(gallego_catchment) : not a Map object
> However, I checked the class:
>  "SpatialPolygonsDataFrame"
>  "sp"
Just say coordinates(gallego_catchment) to extract the "centroid" -
labelpoint - for each Polygons object - the coordinates() method retrieves
the label points. Note that a "Map" object is not a
"SpatialPolygonsDataFrame" object, and indeed "Map" objects are only used
internally in some limited settings. You are muddling up classes.
Installing rgdal properly would make sure you only saw the
"SpatialPolygonsDataFrame" object, which is all you need.
> and I read the catchment boundary with:
> p4s <- CRS("+proj=utm +zone=30 +ellps=intl +units=m +no_defs")
> # reading the boundary of the gallego catchment
> gallego_catchment <- readShapePoly("only_gallego_catchment.shp",
> Could somebody tell me if I'm doing something wrong?
> Thanks in advance
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