-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_unique_shp.R
executable file
·24 lines (21 loc) · 1.17 KB
/
write_unique_shp.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
filebase_path <- "/media/dogbert/XChange/Masterarbeit/Analyse_Modeloutput/"
filebase_raster <- paste0(filebase_path, "raster")
filebase_csv <- paste0(filebase_path, "csv/rH_ta_200/")
filebase_shp <- paste0(filebase_path, "vector/plots_shp/")
library("sp")
library(raster)
library("rgdal")
lyr <- ogrListLayers(paste0(filebase_shp,"PlotPoles_ARC1960_mod_20140807_final.shp"))
plots_shp <- readOGR(paste0(filebase_shp,"PlotPoles_ARC1960_mod_20140807_final.shp"),
layer= lyr)
plots_unique <- data.frame(plots_shp)
plots_unique <- data.frame(Name = plots_unique$PlotID,
X = plots_unique$X,
Y = plots_unique$Y,
Z_GPS = plots_unique$Z_GPS)
plots_unique <- plots_unique[!duplicated(plots_unique$Name), ]
plots_unique <- SpatialPointsDataFrame(coords= data.frame(plots_unique$X,plots_unique$Y), plots_unique)
crs(plots_unique) <- crs(plots_shp)
plots_unique<-spTransform(plots_unique, crs("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))
writeOGR(plots_unique, "/media/dogbert/XChange/Masterarbeit/Analyse_Modeloutput/vector/plots_shp/plots_unique.kml",
layer = "plots_unique", driver="KML")