[R] AdehabitatHR Write Spatial Polygon Problem

Duncan Murdoch murdoch.duncan at gmail.com
Tue Nov 8 20:44:17 CET 2016


On 08/11/2016 12:09 PM, Shaney, Kyle J wrote:
> Hi All,
>
> I am trying to export a shapefile of a minimum convex polygon, but I receive the following error message:
>
>
> Error: is(x, "SpatialPolygonsDataFrame") is not TRUE
>
>
> I was able to successfully get my minimum convex polygon and plot it in R using the following code:
>
>
> PID208 <- read.csv(file="PID208.csv", header = TRUE, sep = ",")
>
> head(PID208)
>
>
>      Name      X       Y        X1       Y2 sex age        Receive.Time
> 1 PID208 391734 6744220 -148.9906 60.81855   2   3 2015.06.18 21:12:20
> 2 PID208 391738 6744219 -148.9905 60.81855   2   3 2015.06.18 22:50:30
> 3 PID208 391739 6744229 -148.9905 60.81864   2   3 2015.06.04 20:41:52
> 4 PID208 391748 6744229 -148.9904 60.81864   2   3 2015.06.04 20:44:27
> 5 PID208 391748 6744229 -148.9904 60.81864   2   3 2015.06.04 20:44:27
> 6 PID208 391743 6744229 -148.9904 60.81864   2   3 2015.06.04 22:07:07?
>
> xy<- SpatialPoints(PID208 [2:3])
> mcp(xy, percent=95)
> mcp(xy, percent=95)$area #to find actual area covered
> plot(mcp(xy,percent=100))
>
>
> Anybody know what I might be missing to successfully export the file for use in GIS?

You don't say how you're trying to export it, but you are creating a 
SpatialPoints object, and the error message says something wants a 
SpatialPolygonsDataFrame object.  So you need to convert it.

Duncan Murdoch



More information about the R-help mailing list