[R-sig-Geo] Differences in area between R sp and ArcGIS

Tom Philippi tephilippi at gmail.com
Tue Jun 2 04:55:41 CEST 2015


Andrew--
I suspect that some of your polygons have holes in them.
The area slot of the Polygons class doesn't subtract off the area of
holes.  If you want the net area, I recommend using rgeos::gArea()

library(rgdal)
library(rgeos)
raw <- readOGR('k:/','polySample',stringsAsFactors=FALSE)
str(raw at data)
raw$Area_G <- gArea(raw,byid=TRUE)
raw at data[,17:19]

I hope that this helps.

Tom 2

On Mon, Jun 1, 2015 at 5:57 PM, Andrew Plowright <plowright.andrew at gmail.com
> wrote:

> Hello,
>
> As my first email to this list, I just wanted to start out by thanking
> everyone who has been involved in developing this excellent package, and to
> everyone who has answered questions on this mailing list. I have been
> consulting this list's archives for years, and the answers that have been
> given have been a huge help.
>
> My question is as follows:
>
> I was just wondering if there was a known difference in between the way the
> R sp's package computes area and the way ArcGIS does. Below is a link to a
> subset of a dataset I am working on. Its attribute table contains two
> columns: "Area_Arc" and "Area_R".
>
>
> https://drive.google.com/folderview?id=0Bw1lKQwaoU84fmRwald5d0JqM1BEemFQX2FmVEFtdHk2RlltTzZFLU1EQ01CcURZcDdteUU&usp=sharing
>
> "Area_R" was computed using the following lines in R:
>
> > polySample <- readOGR("C:\\Users\\Andy\\Documents", "polySample")
> > polySample[["Area_R"]] <- sapply(polyfile at polygons, function(x){x at area})
>
> "Area_Arc" was computed using ArcMap's Calculate Geometry tool, using the
> coordinate system associated with the file.
>
> I tried reprojecting this file and repeating the process, but each time,
> there is a discrepancy between the areas. Specifically, the area calculated
> by ArcMap is always in the same ballpark but smaller.
>
> > proj4string(polySample)
> [1] "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000
> +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"
> > sum(polySample[["Area_R"]])
> [1] 15332220331
> > sum(polySample[["Area_Arc"]])
> [1] 12330204266
>
> My understanding is that both of these methods use the same underlying
> mathematics to compute area based on the projection system assigned to the
> file, so I can't figure out why they would produce different results. I
> apologize if this question has been addressed before, but I was unable to
> come up with any answers from the R sp help file or on the mailing list's
> archives.
>
> Thank you very much
> Andrew
>
>         [[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
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list