Hi Ross,

you result is in square degrees, you will need to project your data to
planar coordinates.

You could do for example:

library(rgeos)
library(rgdal)
library(sp)

myPoly <- spTransform(myPolygonSpatial, CRS("+init=epsg:32640"))

# the area in m2
 gArea(myPoly)

# or in km2
gArea(myPoly) / 1e6

HTH

Johannes




On Tue, May 14, 2013 at 4:08 PM, Ross Ahmed <rossahmed@googlemail.com>wrote:

> Hi all
>
> The documentation for gArea() says the units of area are based on the
> current projection. The polygon below is in longlat, and in my primative
> understanding, the units should be square metres. The output is
>  0.000828375
> but I know the approximate area of this polygon is 4.45 square kilometres.
> Using gArea(), how can I calculate the area of the polygon below in units
> of
> square kilometres?
>
> library(sp); library(rgeos)
> polygonCoords <- matrix(c(-1.9450, -1.9075, -1.9075, -1.9450, -1.9450,
> 55.72476, 55.72476, 55.70267, 55.70267, 55.72476), ncol=2)
> p = Polygon(polygonCoords)
> myPolygon = Polygons(list(p),1)
> myPolygonSpatial = SpatialPolygons(list(myPolygon))
>
> proj4string(myPolygonSpatial) <- CRS("+proj=longlat +datum=WGS84
> +ellps=WGS84 +towgs84=0,0,0")
>
> gArea(myPolygonSpatial)
> # output is [1] 0.000828375
> # area in square kilometres is circa 4.45 square kilometres
>
>
> Thanks
> Ross
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 

## ## Contact:
## Johannes Signer, MSc
## PhD-Candidate -- Wildlife Management
## Dept. of Forest Zoology & Forest Conservation
## University of Goettingen
## Buesgenweg 3 (room 85)
## 37077 Goettingen, Germany
## e: jmsigner@gmail.com
## p: +49 (0)551 39 3583
## m: +49 (0)176 61 962856
## skype: j.m.signer
## ##

	[[alternative HTML version deleted]]

