[R-sig-Geo] Calculating area of polygons created from a spatial intersect

Robert J. Hijmans r.hijmans at gmail.com
Sat Mar 28 00:46:54 CET 2015


Walter,

I think that instead of
  gIntersects(buffered_projects, census_blocks, byID=TRUE)

you want
  library(raster)
  x <- intersect(buffered_projects, census_blocks, byID=TRUE)

and then Step 3
  x$newarea <- gArea(x, byid=TRUE)
  x$relarea <- x$newarea / x$area


Robert


On Fri, Mar 27, 2015 at 3:45 PM, Walter Anderson <wandrson01 at gmail.com> wrote:
> Hello all,
>
> I am attempting to automate an analysis that I developed with ArcInfo
> using R and the gdal and geos packages (or any other) if possible.
>
> Here is the basic process
>
> I have a shape file (lines) that defines the limits of all of the
> projects with each project having a unique identifier.
>
> I have another shape file (polys) that contains total population and
> low income population and represent Census block groups.  This shape
> file has an area field which has the acreage of the total block group.
>
> Process
>
> Step 1.
> I then buffer these project lines to create a second shape file that
> represents the 'footprint' of the project. (Creates polys).
>
> Step 2.
> In ArcInfo, I perform an intersection of the two shape files
> (footprint and census blocks) and this creates a third shape file
> which has a unique polygon for every project/census block intersection.
>
> Step 3.
> I then perform an area calculation (acres) on this new poly shape file
> and use this calculated area divided by the original area of the
> associated census block group to apportion the two population datum to
> this new polygon.
>
> Step 4.
> Finally, I sum the two population datums for each of the projects from
> the attribute table of this final shape file.
>
> When I try to replicate the above procedure I run into a problem with
> Step 2 when I use what I think is the appropriate command:
>
> gIntersects(buffered_projects, census_blocks, byID=TRUE)
>
> This command is producing a matrix of each project/census block
> combination and only providing me a true/false indication.  Is there
> any way to replicate the process from ArcInfo that I outlined above
> within R?
>
> Walter Anderson
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list