114 |
120 |
|
ozmap_abs_ste_data <- function(...){ |
115 |
121 |
|
abs_ste |
116 |
122 |
|
} |
117 |
|
- |
|
118 |
|
- |
plot_bbox <- function(x, ...) { |
119 |
|
- |
xr <- x[c("xmin", "xmax")] |
120 |
|
- |
yr <- x[c("ymin", "ymax")] |
121 |
|
- |
plot(xr, yr, type = "n", axes = FALSE, xlab = "", ylab = "", ...) |
122 |
|
- |
} |
123 |
|
- |
|
124 |
|
- |
|
125 |
|
- |
|
126 |
|
- |
## from sf |
127 |
|
- |
# person(given = "Edzer", |
128 |
|
- |
# family = "Pebesma", |
129 |
|
- |
# role = c("ctb"), |
130 |
|
- |
# comment = c(ORCID = "0000-0001-8049-7069")) |
131 |
|
- |
#' @importFrom graphics plot polypath |
132 |
|
- |
plot_sfc <- function(x, y, ..., lty = 1, lwd = 1, col = NA, border = 1, add = FALSE, rule = "evenodd") { |
133 |
|
- |
# FIXME: take care of lend, ljoin, xpd, and lmitre |
134 |
|
- |
stopifnot(missing(y)) |
135 |
|
- |
geom <- x[[attr(x, "sf_column")]] |
136 |
|
- |
bb <- attr(geom, "bbox") |
137 |
|
- |
## stfusf |
138 |
|
- |
prj <- attr(geom, "crs")[["proj4string"]] |
139 |
|
- |
if (!"asp" %in% names(list(...))) { |
140 |
|
- |
asp <- 1 |
141 |
|
- |
if (grepl("longlat", prj) || grepl("4326", prj)) { |
142 |
|
- |
asp <- 1/cos(mean(bb[c("ymin", "ymax")]) * pi/180) |
143 |
|
- |
} |
144 |
|
- |
} else { |
145 |
|
- |
asp <- list(...)$asp |
146 |
|
- |
} |
147 |
|
- |
if (! add) |
148 |
|
- |
plot_bbox(bb, asp = asp) |
149 |
|
- |
x <- geom |
150 |
|
- |
lty = rep(lty, length.out = length(x)) |
151 |
|
- |
lwd = rep(lwd, length.out = length(x)) |
152 |
|
- |
col = rep(col, length.out = length(x)) |
153 |
|
- |
border = rep(border, length.out = length(x)) |
154 |
|
- |
#non_empty = ! st_is_empty(x) |
155 |
|
- |
lapply(seq_along(x), function(i) { |
156 |
|
- |
lapply(x[[i]], function(L) { |
157 |
|
- |
polypath(sf_p_bind(L), border = border[i], lty = lty[i], lwd = lwd[i], col = col[i], rule = rule) |
158 |
|
- |
})}) |
159 |
|
- |
invisible(NULL) |
160 |
|
- |
} |
161 |
|
- |
|
162 |
|
- |
|
163 |
|
- |
sf_p_bind <- function(lst) { |
164 |
|
- |
if (length(lst) == 1) |
165 |
|
- |
lst[[1]] |
166 |
|
- |
else { |
167 |
|
- |
ret = vector("list", length(lst) * 2 - 1) |
168 |
|
- |
ret[seq(1, length(lst) * 2 - 1, by = 2)] = lst # odd elements |
169 |
|
- |
ret[seq(2, length(lst) * 2 - 1, by = 2)] = NA # even elements |
170 |
|
- |
do.call(rbind, ret) # replicates the NA to form an NA row |
171 |
|
- |
} |
172 |
|
- |
} |