-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshp_to_csv.R~
33 lines (25 loc) · 1.02 KB
/
shp_to_csv.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
25
26
27
28
29
30
31
32
33
# This script extracts delta tc metrics of points shp from the raster to the csv
rm(list=ls())
# load raster packages
library(rgdal)
library(raster)
# This script extracts delta tc metrics of points shp from the raster to the csv
rm(list=ls())
# load raster packages
library(rgdal)
library(raster)
# function to abbrevaite paste
"%+%" <- function(x,y) paste(x,y,sep="")
#out_dir = "/projectnb/landsat/users/shijuan/above/bh14v14/"
#shp_loc = "/projectnb/landsat/users/shijuan/above/bh14v14/" # directory
#shp_name = "bh14v14_training_data_pts" # no .shp
args <- commandArgs(trailingOnly=TRUE)
tile_name <- args[1]
out_dir = "/projectnb/landsat/users/shijuan/above/training_data/"%+%tile_name%+%"/"
shp_loc = "/projectnb/landsat/users/shijuan/above/training_data/"%+%tile_name%+%"/"%+%tile_name%+%"_pts.shp"
shp_name = tile_name%+%"_pts" # no .shp
# read the shapefile
pts_df = readOGR(shp_loc, shp_name)
#print(pts_df)
out_file = out_dir%+%tile_name%+%"_pts.csv"
write.table(pts_df, file=out_file,sep=",",col.names=T,row.names=F, quote=F)