@@ -19,151 +19,18 @@ load_geo <- function(region, Rdata_file){
1919 mget(ls())
2020}
2121
22- # ' Add Berlin combined sewer catchments to a map
23- # '
24- # ' Polygons are drawn in different types of gray
25- # ' @param plot_names If TRUE, names of the districts will be included in the plot
26- # ' @param highlight_catchments Character vector containing the catchments names
27- # ' of catchments to be highlighted
28- # ' @param highlight_style Either "shaded" (default) or a specific color, which
29- # ' cab also be defined by [rgb()]
30- # '
31- # ' @importFrom graphics polygon abline text
32- # ' @export
33- # '
34- Berlin_add_catchments <- function (
35- plot_names = FALSE , highlight_catchments = NULL , highlight_style = " shaded"
36- ){
37- ezg <- NULL
38- load(file.path(system.file(package = " qsimVis" ),
39- " extdata/berlin_data/catch_polygon.RData" ))
40-
41- if (plot_names ){
42- ezg_namePositions <- lapply(ezg , function (loc_df ) {
43- data.frame (" x" = mean(loc_df [,1 ]), " y" = mean(loc_df [,2 ]))
44- })
45-
46- ezg_namePositions $ `Bln II` $ y <- ezg_namePositions $ `Bln II` $ y - 0.01
47- ezg_namePositions $ `Bln III` $ x <- ezg_namePositions $ `Bln III` $ x + 0.01
48- ezg_namePositions $ `Bln III` $ y <- ezg_namePositions $ `Bln III` $ y - 0.003
49- ezg_namePositions $ `Bln IIIa` $ x <- ezg_namePositions $ `Bln IIIa` $ x - 0.01
50- ezg_namePositions $ `Bln IIIa` $ y <- ezg_namePositions $ `Bln IIIa` $ y - 0.04
51- ezg_namePositions $ `Bln VIII` $ x <- ezg_namePositions $ `Bln VIII` $ x + 0.005
52- ezg_namePositions $ `Bln VIII` $ y <- ezg_namePositions $ `Bln VIII` $ y + 0.005
53- ezg_namePositions $ `Bln IX` $ x <- ezg_namePositions $ `Bln IX` $ x + 0.005
54- ezg_namePositions $ `Bln IX` $ y <- ezg_namePositions $ `Bln IX` $ y + 0.005
55- ezg_namePositions $ `Bln IX` $ y <- ezg_namePositions $ `Bln IX` $ y + 0.005
56- ezg_namePositions $ `Bln XI` $ x <- ezg_namePositions $ `Bln XI` $ x - 0.013
57- ezg_namePositions $ `Chb I` $ y <- ezg_namePositions $ `Chb I` $ y - 0.005
58- ezg_namePositions $ `Chb Ia` $ y <- ezg_namePositions $ `Chb Ia` $ y + 0.02
59- ezg_namePositions $ `Chb Ia` $ x <- ezg_namePositions $ `Chb Ia` $ x - 0.08
60- ezg_namePositions $ `Chb III` $ y <- ezg_namePositions $ `Chb III` $ y + 0.002
61- ezg_namePositions $ `Ruh` $ x <- ezg_namePositions $ `Ruh` $ x + 0.015
62- ezg_namePositions $ `Spa1` $ x <- ezg_namePositions $ `Spa1` $ x - 0.008
63- ezg_namePositions $ `Wil` $ y <- ezg_namePositions $ `Wil` $ y + 0.01
64- }
65-
66- if (length(highlight_catchments ) > 0L ){
67- wrong_names <- ! (highlight_catchments %in% names(ezg ))
68- if (any(wrong_names )){
69- warning(paste(highlight_catchments [wrong_names ], collapse = " , " ),
70- " : no defined catchment name(s) -> will not be highlighted" )
71- }
72- }
73-
74- # colCircle <- rep(paste0("gray",c(60,70,80,90)), 10)
75- # for(i in seq_along(ezg)){
76- # col <- colCircle[i]
77- # polygon(
78- # x = ezg[[i]][,1],
79- # y = ezg[[i]][,2],
80- # col = col)
81- # }
82- colCircle <- rep(paste0(" gray" ,c(60 ,70 ,80 ,90 )), 10 )
83- for (i in seq_along(ezg )){
84- col <- colCircle [i ]
85- shading <- NULL
86- if (names(ezg )[i ] %in% highlight_catchments ){
87- if (highlight_style == " shaded" ){
88- shading <- 30
89- } else {
90- col <- highlight_style
91- }
92- }
93- polygon(x = ezg [[i ]][,1 ], y = ezg [[i ]][,2 ], col = col , density = shading )
94- if (plot_names ){
95- text(x = ezg_namePositions [[i ]]$ x , y = ezg_namePositions [[i ]]$ y ,
96- labels = names(ezg_namePositions )[i ])
97-
98- }
99-
100- }
101-
102- if (plot_names ){
103- lines(
104- x = c(ezg_namePositions $ `Chb Ia` $ x + 0.012 , min(ezg $ `Chb Ia` [,1 ]) + 0.004 ),
105- y = c(ezg_namePositions $ `Chb Ia` $ y - 0.002 , max(ezg $ `Chb Ia` [,2 ]) - 0.002 ))
106- lines(
107- x = c(ezg_namePositions $ `Bln IIIa` $ x , mean(ezg $ `Bln IIIa` [,1 ]) + 0.0005 ),
108- y = c(ezg_namePositions $ `Bln IIIa` $ y + 0.002 , mean(ezg $ `Bln IIIa` [,2 ])))
109- }
110- abline(v = par(" usr" )[1 : 2 ])
111- abline(h = par(" usr" )[3 : 4 ])
112-
113- }
114-
115- # ' Add Berlin districts to a map
116- # '
117- # ' Polygons are drawn in lightgray
118- # '
119- # ' @importFrom graphics polygon
120- # ' @export
121- # '
122- add_districts <- function (){
123- geo <- load_geo(region = " berlin" , Rdata_file = " berlin_boarder" )
124- polygon(
125- x = geo $ gis_coordinates [,1 ],
126- y = geo $ gis_coordinates [,2 ],
127- col = " gray80" )
128-
129- }
130-
131- # ' Add Berlin boarder to a map
132- # '
133- # ' Polygons is drawn in lightgray
134- # ' @param bg_color Character string or [rgb()] for the polygon background color
135- # '
136- # ' @importFrom graphics polygon
137- # ' @export
138- # '
139- Berlin_add_boarder <- function (bg_color = " gray60" ){
140- geo <- load_geo(region = " berlin" , Rdata_file = " berlin_boarder" )
141- polygon(
142- x = geo $ gis_coordinates [," X" ],
143- y = geo $ gis_coordinates [," Y" ],
144- col = bg_color
145- )
146- }
147-
148- # ' Add Berlin boarder to a map
149- # '
150- # ' Polygons is drawn in lightgray
151- # ' @param bg_color Character string or [rgb()] for the polygon background color
152- # '
153- # ' @importFrom graphics polygon
154- # ' @export
155- # '
156- Berlin_add_waterbodies <- function (bg_color = " lightblue" ){
157- geo <- load_geo(region = " berlin" , Rdata_file = " berlin_waterbodies_ordnung1" )
158- polies <- unique(geo $ gis_coordinates [," L2" ])
159- for (poly in polies ){
160- poly_rows <- geo $ gis_coordinates [geo $ gis_coordinates [," L2" ] == poly ,]
161- polygon(
162- x = poly_rows [," X" ],
163- y = poly_rows [," Y" ],
164- col = bg_color , border = NA
165- )
166- }
167-
168- }
169-
22+ # ' #' Add Berlin districts to a map
23+ # ' #'
24+ # ' #' Polygons are drawn in lightgray
25+ # ' #'
26+ # ' #' @importFrom graphics polygon
27+ # ' #' @export
28+ # ' #'
29+ # ' add_districts <- function(){
30+ # ' geo <- load_geo(region = "berlin", Rdata_file = "berlin_boarder")
31+ # ' polygon(
32+ # ' x = geo$gis_coordinates[,1],
33+ # ' y = geo$gis_coordinates[,2],
34+ # ' col = "gray80")
35+ # '
36+ # ' }
0 commit comments