-
-
Notifications
You must be signed in to change notification settings - Fork 611
c4 review #675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
c4 review #675
Changes from 100 commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
28a0b64
Split-out pkg loading and reading for #669
Robinlovelace 6c5d3c3
Refactor index.Rmd text about bookdown, update links
Robinlovelace 4f98482
Update ex location
Robinlovelace d1f8097
Update ex location
Robinlovelace 400daec
Define spatial ops upfront
Robinlovelace 0e4672c
Update prose in Section 4.1
Robinlovelace 17990b1
Define map algebra
Robinlovelace ac9bfa3
Update map algebra section
Robinlovelace aadc73e
Shorten and simplify description of spatial vs attribute operations
Robinlovelace 4ae179b
Minor tweak to c4
Robinlovelace 55f20af
It uses the terra not raster package
Robinlovelace 8eb32b6
Introduce terra pkg in context of raster in c2
Robinlovelace 61c04f4
Cross reference c1
Robinlovelace 942bba3
Reword 4.2.1, make it clearer (hopefully)
Robinlovelace 613fe32
Complete review of Section 4.2.1
Robinlovelace eba5e53
Improve segway to topological relations section
Robinlovelace 95e5a86
Update with reference for #677
Robinlovelace 3b7a803
Merge branch 'c4-v2-updates-rl' of github.com:Robinlovelace/geocompr …
Robinlovelace 5ab7ab6
Add new refs and update bib
Robinlovelace 98abe14
Add new references on algebraic topology
Robinlovelace eb51533
Update text with refs for #677
Robinlovelace de750fc
Test ggplot2 code for #677
Robinlovelace 2011877
Add placeholder section on DE-9IM #677
Robinlovelace cf85720
Tweak comment and replace code with link to terra issue in c2
Robinlovelace 0bb2df3
Test code for #677
Robinlovelace b1c2c4e
Add start fun for #677
Robinlovelace af95b09
MVP for de_9im fun
Robinlovelace 552474a
Move test code to function script, fix build
Robinlovelace c931039
Working de_9im function
Robinlovelace fcf6bf0
Update code, fix build mkII
Robinlovelace d771041
Progress on #677
Robinlovelace 5a7002a
Require sf
Robinlovelace 76499a3
New fig 4.2 for #677
Robinlovelace 9286ab9
Fix polygons, improve vis for #677
Robinlovelace 22cbb41
Finish updating s. 4.2.2, close #677
Robinlovelace 55e40d4
Add chunk to get around failing terra code
Robinlovelace df4b7cc
Fix references in c4
Robinlovelace cc53365
Comment out experimental new de-9im section for now...
Robinlovelace c4a62c3
Split paragraph in s. 4.2.2 in 2
Robinlovelace 0302b07
Update text in 4.2.2, improve figure 4.2 caption
Robinlovelace b314c83
Break-up geometry creation code chunk
Robinlovelace 87eccc4
Finish review of Section 4.2.2
Robinlovelace 876e4ac
Split-out pkg loading and reading for #669
Robinlovelace 490e37a
Refactor index.Rmd text about bookdown, update links
Robinlovelace 5e7611d
Define spatial ops upfront
Robinlovelace 70140cc
Update prose in Section 4.1
Robinlovelace 8f8dfe0
Define map algebra
Robinlovelace 13272f5
Update map algebra section
Robinlovelace a4f3a56
Shorten and simplify description of spatial vs attribute operations
Robinlovelace 0061610
Minor tweak to c4
Robinlovelace 40d7f49
It uses the terra not raster package
Robinlovelace cebae2c
Introduce terra pkg in context of raster in c2
Robinlovelace 26bc961
Cross reference c1
Robinlovelace 627214c
Reword 4.2.1, make it clearer (hopefully)
Robinlovelace d00f116
Complete review of Section 4.2.1
Robinlovelace f4974ec
Improve segway to topological relations section
Robinlovelace 788081a
Update with reference for #677
Robinlovelace dead3a1
Add new refs and update bib
Robinlovelace bc0288b
Add new references on algebraic topology
Robinlovelace 7546fdc
Update text with refs for #677
Robinlovelace 0548e7e
Test ggplot2 code for #677
Robinlovelace 2c72f4a
Add placeholder section on DE-9IM #677
Robinlovelace 2095564
Tweak comment and replace code with link to terra issue in c2
Robinlovelace 886f98a
Test code for #677
Robinlovelace ee22ec2
Add start fun for #677
Robinlovelace 3f3206e
MVP for de_9im fun
Robinlovelace 596aa44
Move test code to function script, fix build
Robinlovelace 8f13921
Working de_9im function
Robinlovelace 4569a2a
Update code, fix build mkII
Robinlovelace 2fe1345
Progress on #677
Robinlovelace 29e4587
Require sf
Robinlovelace 20c292d
New fig 4.2 for #677
Robinlovelace 90f5f2b
Fix polygons, improve vis for #677
Robinlovelace 60481d7
Finish updating s. 4.2.2, close #677
Robinlovelace 2d21ff8
Add chunk to get around failing terra code
Robinlovelace d5cd6c9
Fix references in c4
Robinlovelace d305f94
Comment out experimental new de-9im section for now...
Robinlovelace 8950306
Split paragraph in s. 4.2.2 in 2
Robinlovelace 6c58bd9
Update text in 4.2.2, improve figure 4.2 caption
Robinlovelace 262c158
Break-up geometry creation code chunk
Robinlovelace 4fe30d5
Finish review of Section 4.2.2
Robinlovelace a93c16b
Update bib
Robinlovelace 2769f73
Merge with main
Robinlovelace 10f9d65
Merge
Robinlovelace 4760195
Tweak prose, see https://github.com/Robinlovelace/geocompr/pull/686/c…
Robinlovelace db7daee
Refactor code + prose in 4.2.3
Robinlovelace d8aad30
Complete review of 4.2.3
Robinlovelace 471defa
Add idea
Robinlovelace 7ecb0de
Complete review of Section 4.2.4
Robinlovelace bd857de
Review section on spatial aggregation
Robinlovelace 59639bc
Rename spatia-aggr section
Robinlovelace 1d28020
Create new section on incongruent zones, they deserve one!
Robinlovelace 6e7f825
Remove unclear explanation of st_interpolate_aw()
Robinlovelace 1232ac2
Complete review of new section on incongruent data
Robinlovelace ca83435
Rename + label incongruent section
Robinlovelace 8618b4c
Refactor prose in raster section
Robinlovelace 2f256c1
Evaluate zonal fun
Robinlovelace 887d73d
Global object rename w. fd:
Robinlovelace fdb74cf
Merge branch 'main' into c4-v2-updates-rl
Robinlovelace 8ca4363
Source local script for CI
Robinlovelace 92fc311
Demonstrate st_filter, close #688
Robinlovelace a50f479
Improve description of st_filter
Robinlovelace dc2725e
Comment out link to tidyverse-pitfalls vignette
Robinlovelace ce9cb74
Shorten sentence
Robinlovelace 5ff0674
Use full epsg code
Robinlovelace bf7572c
Drop sentence on history of map algebra (!)
Robinlovelace 9ff09a1
Remove double is
Robinlovelace 70104db
Replace as.raster() with raster() etc
Robinlovelace File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #' This function visualises sf objects and returns info on the | ||
| #' types of spatial relationship there is between them | ||
| #' | ||
| #' Context: [robinlovelace/geocompr#677](https://github.com/Robinlovelace/geocompr/issues/677) | ||
| #' | ||
| #' @examples | ||
| #' library(sf) | ||
| #' x = st_sfc(st_polygon(list(rbind(c(0, 0), c(1, 0), c(1, 1), c(0, 0))))) | ||
| #' y = st_sfc(st_polygon(list(rbind(c(0, 0), c(0, 1), c(1, 1), c(0, 0))))) | ||
| #' de_9im(x, y) | ||
| #' p3 = st_sfc(st_polygon(list(rbind(c(0.7, 0.3), c(0.7, 0.95), c(0.9, 0.95), c(0.7, 0.3))))) | ||
| #' p4 = st_sfc(st_polygon(list(rbind(c(0.6, 0.1), c(0.7, 0.5), c(0.9, 0.5), c(0.6, 0.1))))) | ||
| #' p5 = st_sfc(st_polygon(list(rbind(c(0, 0.2), c(0, 1), c(0.9, 1), c(0, 0.2))))) | ||
| #' de_9im(x, p3) | ||
| de_9im = function(x, | ||
| y, | ||
| object_names = c("x", "y"), | ||
| plot = TRUE, | ||
| funs = list( | ||
| "st_intersects", | ||
| "st_disjoint", | ||
| "st_touches", | ||
| "st_crosses", | ||
| "st_within", | ||
| "st_contains", | ||
| "st_contains_properly", | ||
| "st_overlaps", | ||
| "st_equals", | ||
| "st_covers", | ||
| "st_covered_by" | ||
| # , | ||
| # "st_equals_exact" # requuires par argument | ||
| ), | ||
| include_relate = TRUE, | ||
| sparse = FALSE, | ||
| output = "character", | ||
| collapse = " ✓\n" | ||
| ) { | ||
| require("sf") | ||
| if (is(x, "sfc") && is(y, "sfc")) { | ||
| x = st_sf(data.frame(Object = object_names[1]), geometry = x) | ||
| y = st_sf(data.frame(Object = object_names[2]), geometry = y) | ||
| } | ||
| xy = rbind(x, y) | ||
| funs_matched = lapply(funs, match.fun) | ||
| res = lapply(seq(length(funs)), function(i) { | ||
| funs_matched[[i]](x, y, sparse = sparse) | ||
| }) | ||
| res = unlist(res) | ||
| if(output == "character") { | ||
| res = unlist(funs)[res] | ||
| } | ||
| if(include_relate) { | ||
| relation = sf::st_relate(x, y) | ||
| relate_text = paste0(" \nDE-9IM string: \n", relation) | ||
| res = c(res, relate_text) | ||
| } | ||
| if(plot) { | ||
| res_text = paste(res, collapse = collapse) | ||
| message("Object x has the following spatial relations to y: ", res_text) | ||
| res = de_9im_plot(xy, label = res_text) | ||
| } | ||
| res | ||
| } | ||
|
|
||
| de_9im_plot = function(xy, label = "test", alpha = 0.5, show.legend = FALSE, x = 0.1, y = 0.95, theme = ggplot2::theme_void()) { | ||
| require("ggplot2", quietly = TRUE) | ||
| # browser() | ||
| ggplot(xy) + geom_sf(aes(fill = Object), alpha = alpha, show.legend = show.legend) + | ||
| annotate("text", x = 0.1, y = 0.95, label = label, hjust = "left", vjust = "top") + | ||
| theme | ||
| } | ||
|
|
||
| # # Test code to functionalize: | ||
| # theme_set(new = theme_void()) | ||
| # g1 = ggplot(ps1) + geom_sf(aes(fill = Object), alpha = 0.5, show.legend = FALSE) | ||
| # # g1 + annotate("text", x = 0.3, y = 0.9, label = "st_intersects(Polygon1, Polygon2)") | ||
| # g1 + annotate("text", x = 0.1, y = 0.95, label = "intersects TRUE\ndisjoint FALSE\ntouches TRUE\n", hjust = "left", vjust = "top") | ||
| # # Try annotating only which type of relations apply | ||
| # # g1 + annotate("text", x = 0.1, y = 0.95, label = "Relations: intersects, touches", hjust = "left", vjust = "top") | ||
| # g1an = g1 + | ||
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.