I am trying to calculate the area of various polygons from a shapefile containing areas of land with mining rights is South Africa.
Through this site and posts like:
- Understanding unit of area sizes calculated via rgeos::gArea?
- Getting geodetic area from rgeos::gArea? and
- Computing area of given polygon (in vector format) lying between specified lines of latitude?
I understand that I must project to an equal area projection.
So this is some of my code:
Mineralrights <-readOGR(dsn = "C:/blabla/notrelevant/Shapefiles",layer = "Mineral Rights") spTransform(Mineralrights, CRS("+proj=aea +lat_1=24 +lat_2=-33 +lat_0=0 +lon_0=24 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")) gArea(Mineralrights[Mineralrights$GID == "1710350",])  0.0004728565 Warning message: In RGEOSMiscFunc(spgeom, byid, "rgeos_area") : Spatial object is not projected; GEOS expects planar coordinates
And even if I don't perform the spTransform, I get the same warning with the same answer of 0.0004728565
While if I use areaPolygon from the geosphere package, I get a more believable answer:
areaPolygon(Mineralrights[Mineralrights$GID == "1710350",])  5130055
Which corresponds much better to two other methods I used to calculate the area (With a polygon measurement tool in Google Earth Pro and a freeware GIS tool called Mapwindow 5) yielding 5,14km^2 and 5.136km^2 respectively.
Why does the answer from gArea stay the same even if I transform to an equal area projection which I think should yield an answer in m^2? (due to the +units=m in the CRS)