Skip to content
Prev 5958 / 7419 Next

[EXTERNAL] Re: Query

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.goslee at gmail.com> wrote: