|
7 | 7 |
|
8 | 8 | if (length(args) < 2) {
|
9 | 9 | if(.Platform$OS.type == "windows") {
|
10 |
| - general$application <- "testexample" # ...or myfish |
11 |
| - general$main_path_gis <- file.path("C:","Users","fbas","Documents","GitHub","DISPLACE_input_gis", general$application) |
| 10 | + general$application <- "balticRTI" # ...or myfish |
| 11 | + general$main_path_gis <- file.path("C:","Users","fbas","Documents","GitHub","DISPLACE_input_gis_all", general$application) |
12 | 12 | general$main.path.ibm <- file.path("C:","Users","fbas","Documents","GitHub",paste("DISPLACE_input_", general$application, sep=''))
|
13 | 13 | general$igraph <- 56 # caution: should be consistent with existing objects already built upon a given graph
|
14 |
| - |
| 14 | + fit_to_GRID <- TRUE |
15 | 15 | }
|
16 | 16 | } else {
|
17 | 17 | general$application <- args[1]
|
18 | 18 | general$main_path_gis <- args[2]
|
19 | 19 | general$main.path.ibm <- args[3]
|
20 | 20 | general$igraph <- args[4] # caution: should be consistent with existing vessels already built upon a given graph
|
| 21 | + fit_to_GRID <- FALSE |
21 | 22 | }
|
22 | 23 | cat(paste("START \n"))
|
23 | 24 |
|
|
30 | 31 |
|
31 | 32 | #!#!#!#!#!#
|
32 | 33 | #!#!#!#!#!#
|
33 |
| - # choose your country |
| 34 | + # choose your country (and adapt below accordingly) |
34 | 35 | ctry <- "DEN"
|
35 | 36 | #!#!#!#!#!#
|
36 | 37 | #!#!#!#!#!#
|
|
86 | 87 | }
|
87 | 88 |
|
88 | 89 |
|
89 |
| - |
| 90 | + # subset for the area of interest |
| 91 | + if(fit_to_GRID && general$application=="balticRTI"){ |
| 92 | + library(maptools) |
| 93 | + handmade <- readShapePoly(file.path(general$main_path_gis, "MANAGEMENT", "wbaltic_wgs84")) # built in ArcGIS 10.1 |
| 94 | + the_area <- sapply(slot(handmade, "polygons"), function(x) lapply(slot(x, "Polygons"), function(x) x@coords)) |
| 95 | + in_area <- point.in.polygon(as.numeric(as.character(tacsatp[,'SI_LONG'])), as.numeric(as.character(tacsatp[,'SI_LATI'])), the_area[[1]][,1],the_area[[1]][,2]) |
| 96 | + tacsatp <- tacsatp[in_area==1,] |
| 97 | + } |
| 98 | + |
90 | 99 |
|
91 | 100 | xrange <- range(as.numeric(as.character(tacsatp$SI_LONG)), na.rm=TRUE)
|
92 | 101 | yrange <- range(as.numeric(as.character(tacsatp$SI_LATI)), na.rm=TRUE)
|
|
160 | 169 | levels(tacsatp$LE_MET_rough) [levels(tacsatp$LE_MET_rough) %in% c("OTB","OTT", "OTM", "PTB", "PTM" )] <- "Trawl"
|
161 | 170 | levels(tacsatp$LE_MET_rough) [levels(tacsatp$LE_MET_rough) %in% c("PS_", "SDN", "SSC")] <- "Seine"
|
162 | 171 |
|
163 |
| - |
| 172 | + tacsatp$LE_MET_level6 <- factor(tacsatp$LE_MET_level6) |
| 173 | + if(fit_to_GRID){ |
| 174 | + # alter the level 6 to fit the GRID fleet segment definition i.e. a combination of a gear and a target assemblage (!=level6) |
| 175 | + levels(tacsatp$LE_MET_level6) <- unlist(lapply(strsplit(as.character(levels(tacsatp$LE_MET_level6)), split="_"), function (x) paste(x[1], x[2], sep='_'))) # rename by simplifying for GRID |
| 176 | + } |
| 177 | + |
164 | 178 | # keep level 6 and built an OTHER metier
|
165 | 179 | levels(tacsatp$LE_MET_level6)
|
166 | 180 | agg_per_met <- tapply(tacsatp[tacsatp$SI_STATE==1, ]$LE_EFF_VMS, list(tacsatp[tacsatp$SI_STATE==1, ]$LE_MET_level6), sum, na.rm=TRUE)
|
|
200 | 214 |
|
201 | 215 | # add midpoint of gridcell to dataset
|
202 | 216 | aggResult <- cbind(aggtacsatp, CELL_LONG=coordinates(grd)[aggtacsatp$grID,1], CELL_LATI=coordinates(grd)[aggtacsatp$grID,2])
|
203 |
| - save(aggResult, file=file.path(general$main_path_gis, "FISHERIES", "SpatialLayers","2015_aggtacsatp.RData")) |
| 217 | + if(!fit_to_GRID) save(aggResult, file=file.path(general$main_path_gis, "FISHERIES", "SpatialLayers","2015_aggtacsatp.RData")) |
204 | 218 |
|
205 | 219 |
|
206 | 220 | # loop over relevant activity/metier
|
|
0 commit comments