here some code I wrote to export different home range contours to a ESRI shapefiles. It currently does the 99, 95, 75, 50 and 25% level but you can easily change that to your needs. The parameter name is just the file name so the code bellow will create the following shapefile: C:/Shapefiles/HR/Animal1_KHR500.shp Please let me know if you have any quesitons.
Best,
Mathias
exportshape<-function(ud,name,dir){
library(shapefiles)
kv<-list()
class(kv) <- "kver"
kvtmp <- getverticeshr(ud, lev = 99)
kv$KHR99<- kvtmp[[1]]
kvtmp <- getverticeshr(ud, lev = 95)
kv$KHR95<- kvtmp[[1]]
kvtmp <- getverticeshr(ud, lev = 75)
kv$KHR75<- kvtmp[[1]]
kvtmp <- getverticeshr(ud, lev = 50)
kv$KHR50<- kvtmp[[1]]
kvtmp <- getverticeshr(ud, lev = 25)
kv$KHR25<- kvtmp[[1]]
shp<-kver2shapefile(kv)
filename<-paste(dir,name, sep="")
write.shapefile(shp,filename,arcgis=TRUE)
}
ud <- kernelUD(xy, id, grid=600,ker="bivnorm", h=500)
exportshape(ud,"Animal1_KHR500","C:/Shapefiles/HR/")
At 10:17 AM 11/24/2009, Corrie Curtice wrote:
Hello,
Is there a straightforward method for exporting a kernel home range
utilization distribution produced by kernelUD to an ESRI shapefile? I
have the following code:
xy<-Turtles[,c("x","y")]
id<-Turtles$Beach
kud<-kernelUD(xy,id)
I get a nice picture of the kernel home range utilization distribution
with contours. I want to create my maps in ArcMap (I'm not that good
with maps in R yet), so I'd like to export each homerange UD as an
ESRI shapefile, keeping the contour information so I can color ramp it
appropriately and do some analysis in ArcMap. This is what I think
I'm supposed to do, from reading
https://wiki.faunalia.it/dokuwiki/doku.php?id=public:animove_howto :
kver<-getverticeshr(kud)
spol <- kver2spol(kver)
df <- data.frame(Beach="Baja",row.names=("Agua Blanca, Baja California Sur"))
spdfBaja <- SpatialPolygonsDataFrame(spol, df, match.ID = TRUE)
writeOGR(spdfBaja,paste(td,"R-Output/Shapefiles",sep=""),"bajaUD","ESRI
Shapefile")
But I think this only gets me one contour level (95%), right? Once I
get that into ArcMap it's just a single polygon. It doesn't look like
getverticieshr takes a list of levels, just one. Do I need to repeat
this and glue them together for all the levels? Is there a different /
better way to do this?
Also, somewhat related, I'd like to get my projection information into
the SpatialPolygon object, but it's created in the kver2spol
function... is there a way to set the CRS still?
Thanks for any help or pointers.
Corrie
--
Corrie Curtice
Research Associate
Marine Geospatial Ecology Lab
Nicholas School of the Environment, Duke University
http://mgel.env.duke.edu
em: [email protected]
_______________________________________________
AniMov mailing list
[email protected]
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov
_______________________________________________ AniMov mailing list [email protected] http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov
