[R-sig-Geo] gArea() units

Roger Bivand Roger.Bivand at nhh.no
Tue May 14 23:38:47 CEST 2013


On Tue, 14 May 2013, Ross Ahmed 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?

You cannot, GEOS only works on planar, that is projected, geometries. 
There are alternatives, either project, or use areaPolygon in geosphere.

Roger

>
> 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 at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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 mailing list