-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenerateFirmsFiles.R
48 lines (32 loc) · 1.8 KB
/
GenerateFirmsFiles.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
37
38
39
40
41
42
43
44
45
46
47
48
# GENERAL SETTINGS
args <- commandArgs(trailingOnly = TRUE)
general <- list()
if (length(args) < 2) {
if(.Platform$OS.type == "windows") {
general$application <- "testexample" # ...or myfish
general$main_path_gis <- file.path("C:","Users","fbas","Documents","GitHub","DISPLACE_input_gis", general$application)
general$main.path.ibm <- file.path("C:","Users","fbas","Documents","GitHub",paste("DISPLACE_input_", general$application, sep=''))
general$igraph <- 56 # caution: should be consistent with existing objects already built upon a given graph
do_plot <- TRUE
}
} else {
general$application <- args[1]
general$main_path_gis <- args[2]
general$main.path.ibm <- args[3]
general$igraph <- args[4] # caution: should be consistent with existing objects already built upon a given graph
do_plot <- FALSE
}
cat(paste("START\n"))
dir.create(file.path(general$main.path.ibm, paste("firmsspe_", general$application, sep='')))
# read
firms_features <- read.table(file.path(general$main_path_gis,"FIRMS", "firms_features.csv"), sep=";", header=TRUE)
cat(paste("Read firm specs...done\n"))
some_firms_features <- firms_features
colnames(some_firms_features) <- c('firms_id', 'firms_name', 'nb_vessels', 'long', 'lat')
# write
write.table(some_firms_features,
file=file.path(general$main.path.ibm, paste("firmsspe_", general$application, sep=''),
paste("firms_specs.dat",sep='')),
col.names=FALSE, row.names=FALSE, sep= '|', quote=FALSE, append=FALSE)
cat(paste("Write firms-related files...done\n"))
cat(paste("..........done\n"))