Sam,

if _and only if_ your data are in long/lat you can use:

library(geosphere)
perimeter(x)

where x is a SpatialPolygons* object (which you can read with functions
from maptools if you cannot install rgdal).

Robert

On Tue, Nov 8, 2011 at 9:24 AM, Sam Rabin <srabin@princeton.edu> wrote:

> Hello all. I feel like this is a very easy thing that I have made
> difficult, but such is learning. I am trying to calculate the perimeter of
> every polygon in a shapefile, and I am running into all kinds of problems.
> I have looked into PBSmapping's calcLength, but I get the following error:
>
> > data = readShapePoly("shapefile.shp")
> > data.polydata = as.PolyData(data@data)
> > calcLength(data.polydata)
> Error in calcLength(data.polydata) : Invalid PolySet 'polys'.
> Unexpected class (PolyData).
>
> I'm running Mac OS X 10.7 and cannot seem to get rgeos or rgdal to load,
> which is compounding the difficulty. I was wondering if somebody might fix
> my code above, or point me towards a package that can do this easily.
>
> Thanks very much!
>
> Sam Rabin
>     Graduate student
>         Princeton University
>         Ecology & Evolutionary Biology
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

