Skip to content

Commit

Permalink
Update de_9im.R
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowosad committed May 3, 2024
1 parent c7a07cd commit d5bfccf
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions code/de_9im.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ de_9im = function(x,
funs_matched[[i]](x, y, sparse = sparse)
})
res = unlist(res)
if(output == "character") {
if (output == "character") {
res = unlist(funs)[res]
}
res_text2 = ""
if(include_relate) {
if (include_relate) {
relation = sf::st_relate(x, y)
res_text2 = paste0(" \nDE-9IM string: \n", relation)
}
if(plot) {
if (plot) {
res_text1 = paste(res, collapse = collapse)
collapse_no_break = gsub(pattern = "\\n", replacement = "", x = collapse)
res_text1 = paste0(res_text1, collapse_no_break)
Expand Down Expand Up @@ -88,14 +88,17 @@ de_9im_plot2 = function(xy, label1 = "test", label2 = "",
theme = ggplot2::theme_void()) {
require("tmap", quietly = TRUE)
# browser()
# toDo: does not work yet
st_crs(xy) = "EPSG:2180"
tm_shape(xy) +
tm_polygons("Object", legend.show = FALSE, alpha = alpha,
palette = c("#E36939", "#6673E3")) +
tm_credits(label1, position = c(0.1, "top"), just = "top") +
tm_credits(label2, position = c(0.1, 0.4), fontface = "italic", just = "bottom") +
tm_polygons("Object", fill.legend = tm_legend_hide(),
fill_alpha = alpha,
fill.scale = tm_scale(values = c("#E36939", "#6673E3"))) +
tm_credits(label1, position = c(0.07, 0.62), just = "top") +
tm_credits(label2, position = c(0.07, 0.32), fontface = "italic", just = "bottom") +
tm_layout(frame = FALSE)
}

9
# # Test code to functionalize:
# theme_set(new = theme_void())
# g1 = ggplot(ps1) + geom_sf(aes(fill = Object), alpha = 0.5, show.legend = FALSE)
Expand Down

0 comments on commit d5bfccf

Please sign in to comment.