0

I have a series of lat/long coordinates for capture sites and roost trees of bats. I'd like to connect the dots between the captures and roosts in order of date, and individual (each bat has a unique ID). I've found numerous ways of plot the tracks via either the "move" or "moveHMM" packages. But I haven't found a way to export the tracks as a shapefile. Here's an example of what I'd like to do using data and code from the "moveHMM" package:

install.packages("moveHMM")
install.packages("rgdal")
library(moveHMM)
library(rgdal)
elk_data$Easting <- elk_data$Easting/1000
elk_data$Northing <- elk_data$Northing/1000
data <- prepData(elk_data,type = "UTM",coordNames = c("Easting","Northing"))
utmcoord <- SpatialPoints(cbind(data$x*1000,data$y*1000),proj4string=CRS("+proj=utm +zone=17"))
llcoord <- spTransform(utmcoord,CRS("+proj=longlat"))
lldata <- data.frame(ID=data$ID,x=attr(llcoord,"coords")
[,1],y=attr(llcoord,"coords")[,2])
plotSat(lldata,zoom=8)

I'd like to have the tracks for the 4 elk displayed in this plot to all be within one shapefile. Thanks for any help you can provide.

Keith

K. Lott
  • 19
  • 3
  • if "lldata" is supposed to be your `Spatial*DataFrame` (I think you're missing a few steps), you could try exporting with `writeOGR(dsn="", lldata, layer="", driver="ESRI Shapefile")`. If you just want to write to the directory you're currently in, you can use "." instead of the pseudo directory I used with dsn. – shea Oct 05 '17 at 21:01
  • Thanks but that'll just provide me with the point data. What I'm having trouble doing is getting R to export the polylines that connect the points. – K. Lott Oct 06 '17 at 12:25
  • I'm no expert, but I'm _pretty_sure_ `writeOGR()` will export the as a shapefile. Maybe I've misunderstood your question, but you said "export the tracks as a shapefile." If your problem is making the polylines to begin with, that wasn't clear to me. If that is your problem, try looking at [this](https://gis.stackexchange.com/questions/163286/how-do-i-create-a-spatiallinesdataframe-from-a-dataframe). But again, once you make the `Spatial*DataFrame`, you can use `writeOGR()` as I described. – shea Oct 06 '17 at 13:19
  • [This question](https://stackoverflow.com/questions/15962277/creating-shapefiles-in-r) on GIS StackExchange has answers that detail what you wish to do. – Worm Oct 08 '17 at 02:15

0 Answers0