# [R-sig-Geo] Extracting minimum convex polygons of species distributions

Colin Rundel rundel at gmail.com
Thu Mar 15 21:32:35 CET 2012

```While I think it is somewhat simplistic for modeling a species' distribution you can use a convex hull to get a convex bounding polygon for your presence locations. This will not take into account islands but you can remove non-terristrial areas by getting an intersection of the bounding polygon with a coast line shapefile. You can look into gConvexHull and gIntersection in the rgeos package for implementations of these two operations.

I'm not sure what scale you're working with for the final boundaries but since the presence data is for 1 km grid cells you can take this into account using the raster package's rasterToPolygons function to create polygons which are then used to construct the convex hull.

-Colin

On Mar 15, 2012, at 9:56 AM, Louise Mair wrote:

> Hello,
>
> I have a distribution dataset for species consisting of xy coordinates at
> the 1km resolution, with only presence data. So a simplified example of a
> species distribution might be:
>
> y <- rbind(as.integer(rnorm(100,50,20)), as.integer(rnorm(200,100,30)),
> as.integer(rnorm(100,180,15)))
> x <- rbind(as.integer(rnorm(200,50,20)), as.integer(rnorm(200,100,20)),
> as.integer(rnorm(100,200,15)))
> plot(y~x)
>
> I would like to create polygons for each species distribution, where if an
> island is present (as I have tried to show in the example), it would be a
> seperate polygon, and the jagged edges where species distributions meet
> coastlines etc are maintained. I have tried functions such as mcp in the
> package adehabitat, but this produces a very coarse polygon, which doesn't
> provide the detailed distribution edges that I need. Other functions I've
> tried require the data already to be in the format where the only xy
> coordinates present are the outline of the polygon.
>
> Can anyone please recommend a function I can use here, or suggest a way of
> extracting the outline points? I have tried this manually but cannot seem
> to write a code that will effectively take account of jagged edges and
> islands.
>
> Thanks very much for your help,
>
> Louise.
>
> 	[[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

```