-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLS_ALL_format.R
36 lines (21 loc) · 1.12 KB
/
LS_ALL_format.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
34
35
36
# create table based data frames, one value one entry
# purpose: formats data downloaded from laco-wiki and other LandSense pilot data sources
# in: geojson output from laco-wiki (requiers currently reformating downloaded zip shp to geojson)
# in: ADD other formats
# out: data formated pilto specific QA
# 25.04.2019, [email protected]
# add fomat identification
LacoFormat <- function(In, Out, pt, nl, se){ # arguments: In = Input folder, Out = Output folder, pt = pattern (eg. *.zip) of downloaded data, nl = redundancy depth if 0 or 1 than no redundancy (needs implementation), s = sampling population
# get files
setwd(In) # location of downloads
dl <- list.files(pattern = glob2rx(pt)) # select relevant files
file.copy(dl, Out) # copy files to workspace
# extract/rename files
setwd(Out)
dl <- list.files(pattern = glob2rx(pt)) # select relevant files
for (i in 1:length(dl)){
unzip(dl[i]) # unzip your file
sf <- list.files(pattern = 'Sample Polygons*') # list shape file elements
for (j in 1:length(sf)){ file.rename(sf[j], paste0(nl[i], se[j])) } # rename files
}
}