[R-sig-Geo] get the centroids of the polygones

Danlin Yu yud at mail.montclair.edu
Tue Apr 12 18:35:41 CEST 2011


Jianhua:

Looks like get.Pcent was legacy now based on the error.

But since you've already read the shapefile into a spatial polygon 
dataframe, why not just use coordinates() to get the centroids? Such as:

....
cte<- readShapePoly("cte2007.shp", IDvar=Null)
centroids<-coordinates (cte)

Hope this helps.

Cheers,
Dr. Danlin Yu

On 2011-4-12 12:11, Jianhua Huang wrote:
> Hi Everyone:
>
>
>
> I am trying to get the centroids of all the polygons in the shape file.
>
>
>
> I use the following code:
>
>
>
> library(spdep)
>
> library(maptools)
>
> cte<- readShapePoly("cte2007.shp",IDvar=NULL)
>
> get.Pcent(cte)
>
>
>
> But there is an error when I run get.Pcent (Error: could not find function
> "get.Pcent")
>
>
>
> My R version is 2.12.2
>
>
>
> Anybody knows why the function doesn't work?
>
>
>
> Thanks
>
>
>
> Robert
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
___________________________________________
Danlin Yu, Ph.D.
Associate Professor of GIS and Urban Geography
Department of Earth&  Environmental Studies
Montclair State University
Montclair, NJ, 07043
Tel: 973-655-4313
Fax: 973-655-4072
email: yud at mail.montclair.edu
webpage: csam.montclair.edu/~yu



More information about the R-sig-Geo mailing list