-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenerateShippingFiles.R
54 lines (41 loc) · 2.55 KB
/
GenerateShippingFiles.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
49
50
51
52
53
54
# 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("shipsspe_", general$application, sep='')))
# read
shipsspe_features <- read.table(file.path(general$main_path_gis,"SHIPPING", "shipsspe_features.csv"), sep=";", header=TRUE)
shipsspe_lanes_longlat <- read.table(file.path(general$main_path_gis,"SHIPPING", "shipsspe_lanes_longlat.csv"), sep=";", header=TRUE)
cat(paste("Read shipping specs...done\n"))
shipsspe_lanes_lat <- shipsspe_lanes_longlat[, c('ship_lane_number', 'lat_dec')]
shipsspe_lanes_lon <- shipsspe_lanes_longlat[, c('ship_lane_number', 'lon_dec')]
# write
write.table(shipsspe_features,
file=file.path(general$main.path.ibm, paste("shipsspe_", general$application, sep=''),
paste("shipsspe_features.dat",sep='')),
col.names=FALSE, row.names=FALSE, sep= '|', quote=FALSE, append=FALSE)
write.table(shipsspe_lanes_lat,
file=file.path(general$main.path.ibm, paste("shipsspe_", general$application, sep=''),
paste("shipsspe_lanes_lat.dat",sep='')),
col.names=TRUE, row.names=FALSE, sep= ' ', quote=FALSE, append=FALSE)
write.table(shipsspe_lanes_lon,
file=file.path(general$main.path.ibm, paste("shipsspe_", general$application, sep=''),
paste("shipsspe_lanes_lon.dat",sep='')),
col.names=TRUE, row.names=FALSE, sep= ' ', quote=FALSE, append=FALSE)
cat(paste("Write shipping-related files...done\n"))
cat(paste("..........done\n"))