Bruce--
You don't specify if you want the intersected polygons: 1 record for each
polygon intersection of species rangemap and habitat polygon, or just a
list of which habitat type polygons are at least partially within the
species' rangemap polygons.
The former is much slower but can give you estimates of proportions of
habitat (not necessarily _good_ estimates!).

In general, brute force polygon-polygon intersections are slow, as the
computation involves each segment of one polygon compared against each
segment of the other polygon.  Depending on your question, you may be able
to use gOverlaps() instead of the slower gIntersection().  One of the nice
things about coding this in R is that you can use bounding boxes to rapidly
eliminate pairs of polygons to test, and points in polygons as rapid
flagging of intersected/overlapped polygons if you only need the list of
habitats.  Then, the slower over() or gInstersect() computations only need
to be performed on the few pairs that overlap bounding boxes but not point
in polygons.  For the Rodhouse et al. 2016 Ecosphere Bats in Parks paper,
half a day of thinking, coding, & testing resulted in ~10k increase in
speed.  If your habitat polygons tile the entire area, I suspect first
using bounding boxes of your rangemaps to select only relevant habitat
polygons, then using point in polygon of habitat polygon centroids vs
rangemap polygons (assuming habitat polygons are much smaller than
rangemaps) will also greatly speed your computations.

Tom


On Thu, May 30, 2019 at 5:57 AM Sarah Goslee <sarah.gos...@gmail.com> wrote:

> Hi Bruce,
>
> There's extensive material online about spatial capabilities in R.
> Without being sure what you've looked at so far, do these help:
>
>
> https://stackoverflow.com/questions/15075361/how-to-perform-a-vector-overlay-of-two-spatialpolygonsdataframe-objects
>
> https://rspatial.org/rosu/Chapter11.html
>
> In general, you need the sp and rgeos packages. I know that the sf
> package also has very good capabilities for overlaying data, but I'm
> less familiar with its usage.
>
> Sarah
>
> On Thu, May 30, 2019 at 8:36 AM Bruce Miller <batsnc...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I am still searching for a way to extract associations between 2 vector
> > polygon layers using R.
> >
> > What I need is information on if this is possible and if so which
> > packages to use and a basic set of code to do what I can run in the GIS
> > software.
> >
> > For each iteration I have a vector polygon of a bat species
> distributions.
> > Depending on the country  the number of these can range from only a
> > dozen to > 150 species distribution shape files.
> >
> > What I need to do is use the most current habitat/ecosystem vector
> > layers for each geographic area and then extract the species overlapping
> > values.  This creates a new shape file that has added to the species
> > data table all values for the ecosystem where the species polygons
> > overlap the ecosystem polygons.  This provides habitat associations for
> > each species.
> >
> > Then the table is exported to Excel and the data is used for Interactive
> > Identification Keys for New World Bat calls.
> > This eliminates species that do not occur in a given ecosystem as people
> > work on IDing their bats form acoustic surveys.
> >
> > I assume this can be accomplished using R.
> >
> > I have a new ecosystem data set of polygons for Peru, for example that
> > is very detailed.  I extracted one species late yesterday.
> > It took >8 hours in the GIS to compile the areas where the species
> > distribution and ecosystem areas overlapped!
> > I would like to do this in R as a batch file and run on another computer
> > so not to tie up my main workstation.
> >
> > Any guidance or suggestions welcomed.
> >
> > Bruce
> >
> > _______________________________________________
> > R-sig-ecology mailing list
> > R-sig-ecology@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to