I created kde polygons in R and set the directory for output and when I run the code it works and says it exists but the shapefiles are not showing up in my folder.
Here is my code:
`Ei121130 <- read.csv('gps_data_121130.csv')
Ei121130fr <- filter(Ei121130, between(as.POSIXct(Date, format = "%m/%d/%Y %H:%M"),
as.POSIXct("2013-10-20 00:00", format = "%Y-%m-%d %H:%M"), as.POSIXct("2013-10-22 23:59",
format = "%Y-%m-%d %H:%M")))
gps_points121130fr <- SpatialPoints(Ei121130fr[, c("Longitude", "Latitude")],
proj4string = CRS("+proj=longlat +datum=WGS84"))
kde121130fr <- kernelUD(gps_points121130fr, h = "href", grid = 100, kern = "bivnorm")
kde50121130fr <- getverticeshr(kde121130fr, percent = 50)
plot50121130fr <- plot(kde50121130fr, col = "red", lwd = 2, main = "50% KDE of GPS data
121130fr")
outdir <- "Shapefiles2"
#Create directory if it doesn't exist
if(!dir.exists(outdir)){
dir.create(outdir)
}
#Converting data to Simple Features format
kde50_121130frdata <- st_as_sf(kde50121130fr)
#Using the st_write() function from the sf package to write the shapefile
st_write(kde50_121130frdata, "kde50_121130fr.shp")`
The "Shapefiles2" folder is created and the code says they exist but for some reason the folder is empty and I don't know what is going wrong.
Here is my sample code (I am struggling how to attach an actual file of it):
DeployID Ptt Instr Date Type Quality Latitude Longitude Error radius Error Semi-major axis Error Semi-minor axis Error Ellipse orientation Offset Offset orientation GPE MSD GPE U Count Comment
121130 121130 SPOT 10/20/2013 14:34 Argos B 20.956 -157.434
121130 121130 SPOT 10/20/2013 16:26 Argos 2 20.947 -157.254
121130 121130 SPOT 10/21/2013 0:03 Argos B 20.903 -157.145
121130 121130 SPOT 10/21/2013 1:45 Argos 1 20.993 -157.369
121130 121130 SPOT 10/21/2013 3:38 Argos 2 21.001 -157.314
121130 121130 SPOT 10/21/2013 3:38 Argos 2 21.001 -157.314
121130 121130 SPOT 10/21/2013 14:18 Argos B 21.122 -157.431