Skip to content

Commit

Permalink
replace grey by gray
Browse files Browse the repository at this point in the history
  • Loading branch information
jannes committed Oct 7, 2024
1 parent 2ee5807 commit bc7ca5f
Show file tree
Hide file tree
Showing 23 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions 02-spatial-data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,14 @@ library(tmap)
tm1 = tm_shape(india_buffer_with_s2) +
tm_fill(fill = hcl.colors(4, palette = "purple green")[2], lwd = 0.01) +
tm_shape(india) +
tm_fill(fill = "grey95") +
tm_fill(fill = "gray95") +
tm_title("st_buffer() with dist = 1") +
tm_title("s2 switched on (default)", position = tm_pos_in("right", "bottom"), size = 1)
tm2 = tm_shape(india_buffer_without_s2) +
tm_fill(fill = hcl.colors(4, palette = "purple green")[3], lwd = 0.01) +
tm_shape(india) +
tm_fill(fill = "grey95") +
tm_fill(fill = "gray95") +
tm_title(" ") +
tm_title("s2 switched off", position = tm_pos_in("right", "bottom"), size = 1)
Expand Down
2 changes: 1 addition & 1 deletion 04-spatial-operations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ tm_shape(grid_sf) +
tm_fill(fill = c("queens", "rooks"),
fill.scale = tm_scale(values = c("white", "black"))) +
tm_shape(grid_sf) +
tm_borders(col = "grey", lwd = 2) +
tm_borders(col = "gray", lwd = 2) +
tm_layout(frame = FALSE, legend.show = FALSE,
panel.labels = c("queen", "rook"))
```
Expand Down
4 changes: 2 additions & 2 deletions 10-gis.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ aggzone_wgs = st_transform(aggregating_zones, "EPSG:4326")
#| results: hide
library(tmap)
tm_shape(incongr_wgs) +
tm_polygons(col = "grey5") +
tm_polygons(col = "gray5") +
tm_shape(aggzone_wgs) +
tm_borders(col_alpha = 0.5, col = "red") +
tm_add_legend(type = "lines", labels = c("incongr_wgs", "aggzone_wgs"),
col = c("grey5", "red"), lwd = 3, position = tm_pos_in("right", "top")) +
col = c("gray5", "red"), lwd = 3, position = tm_pos_in("right", "top")) +
tm_scalebar(position = c("left", "bottom"), breaks = c(0, 0.5, 1)) +
tm_layout(frame = FALSE, legend.text.size = 1,
inner.margins = c(0.02, 0.02, 0.03, 0.02))
Expand Down
6 changes: 3 additions & 3 deletions _02-ex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ text(world_coords, world$iso_a2)
# Alternative answer:
nigeria = world[world$name_long == "Nigeria", ]
africa = world[world$continent == "Africa", ]
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgrey", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "grey")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgrey")
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgray", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "gray")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgray")
a = africa[grepl("Niger", africa$name_long), ]
ncentre = st_centroid(a)
ncentre_num = st_coordinates(ncentre)
Expand Down
8 changes: 4 additions & 4 deletions _04-ex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ The starting point of this exercise is to create an object representing Colorado
```{r 04-ex-4-1}
colorado = us_states[us_states$NAME == "Colorado", ]
plot(us_states$geometry)
plot(colorado$geometry, col = "grey", add = TRUE)
plot(colorado$geometry, col = "gray", add = TRUE)
```

```{r 04-ex-4-2}
intersects_with_colorado = us_states[colorado, , op = st_intersects]
plot(us_states$geometry, main = "States that intersect with Colorado")
plot(intersects_with_colorado$geometry, col = "grey", add = TRUE)
plot(intersects_with_colorado$geometry, col = "gray", add = TRUE)
```

```{r 04-ex-4-3}
Expand All @@ -103,7 +103,7 @@ us_states |>
```{r 04-ex-4-4}
touches_colorado = us_states[colorado, , op = st_touches]
plot(us_states$geometry, main = "States that touch Colorado")
plot(touches_colorado$geometry, col = "grey", add = TRUE)
plot(touches_colorado$geometry, col = "gray", add = TRUE)
```


Expand All @@ -116,7 +116,7 @@ washington_to_cali = us_states |>
states_crossed = us_states[washington_to_cali, , op = st_crosses]
states_crossed$NAME
plot(us_states$geometry, main = "States crossed by a straight line\n from the District of Columbia to central California")
plot(states_crossed$geometry, col = "grey", add = TRUE)
plot(states_crossed$geometry, col = "gray", add = TRUE)
plot(washington_to_cali, add = TRUE)
```

Expand Down
4 changes: 2 additions & 2 deletions _09-ex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ tmap_animation(tma1, filename = "tma2.gif", width = 1000, height = 1000)
browseURL("tma1.gif")
tma2 = tm_shape(africa) +
tm_polygons(fill = "lightgrey") +
tm_polygons(fill = "lightgray") +
tm_shape(ea) +
tm_polygons(fill = "darkgrey") +
tm_polygons(fill = "darkgray") +
tm_shape(ea) +
tm_polygons(fill = "HDI") +
tm_facets(by = "name", nrow = 1, ncol = 1)
Expand Down
4 changes: 2 additions & 2 deletions _404.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ null_island = st_point(c(0, 0))
null_island = st_sfc(null_island, crs = 4326)
null_island = st_sf(name = "Null Island", geom = null_island)
tm_shape(null_island) +
tm_graticules(labels.col = "grey40") +
tm_graticules(labels.col = "gray40") +
tm_text("name", size = 5, fontface = "italic") +
tm_layout(bg.color = "lightblue") +
tm_title("You are here:", color = "grey40")
tm_title("You are here:", color = "gray40")
```

2 changes: 1 addition & 1 deletion apps/coffeeApp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@
"URL": "http://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2",
"BugReports": "https://github.com/tidyverse/ggplot2/issues",
"LazyData": "true",
"Collate": "'ggproto.r' 'ggplot-global.R' 'aaa-.r'\n'aes-colour-fill-alpha.r' 'aes-evaluation.r'\n'aes-group-order.r' 'aes-linetype-size-shape.r'\n'aes-position.r' 'compat-plyr.R' 'utilities.r' 'aes.r'\n'legend-draw.r' 'geom-.r' 'annotation-custom.r'\n'annotation-logticks.r' 'geom-polygon.r' 'geom-map.r'\n'annotation-map.r' 'geom-raster.r' 'annotation-raster.r'\n'annotation.r' 'autolayer.r' 'autoplot.r' 'axis-secondary.R'\n'backports.R' 'bench.r' 'bin.R' 'coord-.r' 'coord-cartesian-.r'\n'coord-fixed.r' 'coord-flip.r' 'coord-map.r' 'coord-munch.r'\n'coord-polar.r' 'coord-quickmap.R' 'coord-sf.R'\n'coord-transform.r' 'data.R' 'facet-.r' 'facet-grid-.r'\n'facet-null.r' 'facet-wrap.r' 'fortify-lm.r' 'fortify-map.r'\n'fortify-multcomp.r' 'fortify-spatial.r' 'fortify.r' 'stat-.r'\n'geom-abline.r' 'geom-rect.r' 'geom-bar.r' 'geom-bin2d.r'\n'geom-blank.r' 'geom-boxplot.r' 'geom-col.r' 'geom-path.r'\n'geom-contour.r' 'geom-count.r' 'geom-crossbar.r'\n'geom-segment.r' 'geom-curve.r' 'geom-defaults.r'\n'geom-ribbon.r' 'geom-density.r' 'geom-density2d.r'\n'geom-dotplot.r' 'geom-errorbar.r' 'geom-errorbarh.r'\n'geom-freqpoly.r' 'geom-function.R' 'geom-hex.r'\n'geom-histogram.r' 'geom-hline.r' 'geom-jitter.r'\n'geom-label.R' 'geom-linerange.r' 'geom-point.r'\n'geom-pointrange.r' 'geom-quantile.r' 'geom-rug.r' 'geom-sf.R'\n'geom-smooth.r' 'geom-spoke.r' 'geom-text.r' 'geom-tile.r'\n'geom-violin.r' 'geom-vline.r' 'ggplot2.r' 'grob-absolute.r'\n'grob-dotstack.r' 'grob-null.r' 'grouping.r' 'guide-bins.R'\n'guide-colorbar.r' 'guide-colorsteps.R' 'guide-legend.r'\n'guides-.r' 'guides-axis.r' 'guides-grid.r' 'guides-none.r'\n'hexbin.R' 'labeller.r' 'labels.r' 'layer.r' 'layer-sf.R'\n'layout.R' 'limits.r' 'margins.R' 'performance.R'\n'plot-build.r' 'plot-construction.r' 'plot-last.r' 'plot.r'\n'position-.r' 'position-collide.r' 'position-dodge.r'\n'position-dodge2.r' 'position-identity.r' 'position-jitter.r'\n'position-jitterdodge.R' 'position-nudge.R' 'position-stack.r'\n'quick-plot.r' 'range.r' 'reshape-add-margins.R' 'save.r'\n'scale-.r' 'scale-alpha.r' 'scale-binned.R' 'scale-brewer.r'\n'scale-colour.r' 'scale-continuous.r' 'scale-date.r'\n'scale-discrete-.r' 'scale-expansion.r' 'scale-gradient.r'\n'scale-grey.r' 'scale-hue.r' 'scale-identity.r'\n'scale-linetype.r' 'scale-manual.r' 'scale-shape.r'\n'scale-size.r' 'scale-steps.R' 'scale-type.R' 'scale-view.r'\n'scale-viridis.r' 'scales-.r' 'stat-bin.r' 'stat-bin2d.r'\n'stat-bindot.r' 'stat-binhex.r' 'stat-boxplot.r'\n'stat-contour.r' 'stat-count.r' 'stat-density-2d.r'\n'stat-density.r' 'stat-ecdf.r' 'stat-ellipse.R'\n'stat-function.r' 'stat-identity.r' 'stat-qq-line.R'\n'stat-qq.r' 'stat-quantile.r' 'stat-sf-coordinates.R'\n'stat-sf.R' 'stat-smooth-methods.r' 'stat-smooth.r'\n'stat-sum.r' 'stat-summary-2d.r' 'stat-summary-bin.R'\n'stat-summary-hex.r' 'stat-summary.r' 'stat-unique.r'\n'stat-ydensity.r' 'summarise-plot.R' 'summary.r'\n'theme-elements.r' 'theme.r' 'theme-defaults.r'\n'theme-current.R' 'translate-qplot-ggplot.r'\n'translate-qplot-lattice.r' 'utilities-break.r'\n'utilities-grid.r' 'utilities-help.r' 'utilities-matrix.r'\n'utilities-resolution.r' 'utilities-table.r'\n'utilities-tidy-eval.R' 'zxx.r' 'zzz.r'",
"Collate": "'ggproto.r' 'ggplot-global.R' 'aaa-.r'\n'aes-colour-fill-alpha.r' 'aes-evaluation.r'\n'aes-group-order.r' 'aes-linetype-size-shape.r'\n'aes-position.r' 'compat-plyr.R' 'utilities.r' 'aes.r'\n'legend-draw.r' 'geom-.r' 'annotation-custom.r'\n'annotation-logticks.r' 'geom-polygon.r' 'geom-map.r'\n'annotation-map.r' 'geom-raster.r' 'annotation-raster.r'\n'annotation.r' 'autolayer.r' 'autoplot.r' 'axis-secondary.R'\n'backports.R' 'bench.r' 'bin.R' 'coord-.r' 'coord-cartesian-.r'\n'coord-fixed.r' 'coord-flip.r' 'coord-map.r' 'coord-munch.r'\n'coord-polar.r' 'coord-quickmap.R' 'coord-sf.R'\n'coord-transform.r' 'data.R' 'facet-.r' 'facet-grid-.r'\n'facet-null.r' 'facet-wrap.r' 'fortify-lm.r' 'fortify-map.r'\n'fortify-multcomp.r' 'fortify-spatial.r' 'fortify.r' 'stat-.r'\n'geom-abline.r' 'geom-rect.r' 'geom-bar.r' 'geom-bin2d.r'\n'geom-blank.r' 'geom-boxplot.r' 'geom-col.r' 'geom-path.r'\n'geom-contour.r' 'geom-count.r' 'geom-crossbar.r'\n'geom-segment.r' 'geom-curve.r' 'geom-defaults.r'\n'geom-ribbon.r' 'geom-density.r' 'geom-density2d.r'\n'geom-dotplot.r' 'geom-errorbar.r' 'geom-errorbarh.r'\n'geom-freqpoly.r' 'geom-function.R' 'geom-hex.r'\n'geom-histogram.r' 'geom-hline.r' 'geom-jitter.r'\n'geom-label.R' 'geom-linerange.r' 'geom-point.r'\n'geom-pointrange.r' 'geom-quantile.r' 'geom-rug.r' 'geom-sf.R'\n'geom-smooth.r' 'geom-spoke.r' 'geom-text.r' 'geom-tile.r'\n'geom-violin.r' 'geom-vline.r' 'ggplot2.r' 'grob-absolute.r'\n'grob-dotstack.r' 'grob-null.r' 'grouping.r' 'guide-bins.R'\n'guide-colorbar.r' 'guide-colorsteps.R' 'guide-legend.r'\n'guides-.r' 'guides-axis.r' 'guides-grid.r' 'guides-none.r'\n'hexbin.R' 'labeller.r' 'labels.r' 'layer.r' 'layer-sf.R'\n'layout.R' 'limits.r' 'margins.R' 'performance.R'\n'plot-build.r' 'plot-construction.r' 'plot-last.r' 'plot.r'\n'position-.r' 'position-collide.r' 'position-dodge.r'\n'position-dodge2.r' 'position-identity.r' 'position-jitter.r'\n'position-jitterdodge.R' 'position-nudge.R' 'position-stack.r'\n'quick-plot.r' 'range.r' 'reshape-add-margins.R' 'save.r'\n'scale-.r' 'scale-alpha.r' 'scale-binned.R' 'scale-brewer.r'\n'scale-colour.r' 'scale-continuous.r' 'scale-date.r'\n'scale-discrete-.r' 'scale-expansion.r' 'scale-gradient.r'\n'scale-gray.r' 'scale-hue.r' 'scale-identity.r'\n'scale-linetype.r' 'scale-manual.r' 'scale-shape.r'\n'scale-size.r' 'scale-steps.R' 'scale-type.R' 'scale-view.r'\n'scale-viridis.r' 'scales-.r' 'stat-bin.r' 'stat-bin2d.r'\n'stat-bindot.r' 'stat-binhex.r' 'stat-boxplot.r'\n'stat-contour.r' 'stat-count.r' 'stat-density-2d.r'\n'stat-density.r' 'stat-ecdf.r' 'stat-ellipse.R'\n'stat-function.r' 'stat-identity.r' 'stat-qq-line.R'\n'stat-qq.r' 'stat-quantile.r' 'stat-sf-coordinates.R'\n'stat-sf.R' 'stat-smooth-methods.r' 'stat-smooth.r'\n'stat-sum.r' 'stat-summary-2d.r' 'stat-summary-bin.R'\n'stat-summary-hex.r' 'stat-summary.r' 'stat-unique.r'\n'stat-ydensity.r' 'summarise-plot.R' 'summary.r'\n'theme-elements.r' 'theme.r' 'theme-defaults.r'\n'theme-current.R' 'translate-qplot-ggplot.r'\n'translate-qplot-lattice.r' 'utilities-break.r'\n'utilities-grid.r' 'utilities-help.r' 'utilities-matrix.r'\n'utilities-resolution.r' 'utilities-table.r'\n'utilities-tidy-eval.R' 'zxx.r' 'zzz.r'",
"VignetteBuilder": "knitr",
"RoxygenNote": "7.1.0.9000",
"Encoding": "UTF-8",
Expand Down
2 changes: 1 addition & 1 deletion code/02-contpop.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ par(mar = c(0, 0, 0, 0))
plot(world_proj["continent"], reset = FALSE, main = "", key.pos = NULL)
g = st_graticule()
g = st_transform(g, crs = "+proj=eck4")
plot(g$geometry, add = TRUE, col = "lightgrey")
plot(g$geometry, add = TRUE, col = "lightgray")
cex = sqrt(world$pop) / 10000
plot(st_geometry(world_cents), add = TRUE, cex = cex, lwd = 2, graticule = TRUE)
6 changes: 3 additions & 3 deletions code/02-vectorplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ london_orign = rbind(london_osgb, origin_osgb)
png("images/vector_lonlat.png")
globe::globeearth(eye = c(0, 0))
gratmat = st_coordinates(st_graticule())[, 1:2]
globe::globelines(loc = gratmat, col = "grey", lty = 3)
globe::globelines(loc = gratmat, col = "gray", lty = 3)
globe::globelines(loc = matrix(c(-90, 90, 0, 0), ncol = 2))
globe::globelines(loc = matrix(c(0, 0, -90, 90), ncol = 2))
globe::globepoints(loc = c(-0.1, 51.5), pch = 4, cex = 2, lwd = 3, col = "red")
Expand All @@ -28,6 +28,6 @@ uk = rnaturalearth::ne_countries(scale = 50) %>%
plot(uk$geometry)
plot(london_orign$geometry[1], add = TRUE, pch = 4, cex = 2, lwd = 3, col = "red")
plot(london_orign$geometry[2], add = TRUE, pch = 1, cex = 2, lwd = 3, col = "blue")
abline(h = seq(0, 9e5, length.out = 10), col = "grey", lty = 3)
abline(v = seq(0, 9e5, length.out = 10), col = "grey", lty = 3)
abline(h = seq(0, 9e5, length.out = 10), col = "gray", lty = 3)
abline(v = seq(0, 9e5, length.out = 10), col = "gray", lty = 3)
dev.off()
28 changes: 14 additions & 14 deletions code/05-venn-clip.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ if (!exists("b")) {
}

old_par = par(mfrow = c(2, 3), mai = c(0.1, 0.1, 0.1, 0.1))
plot(b, border = "grey")
plot(x, add = TRUE, col = "lightgrey", border = "grey")
plot(b, border = "gray")
plot(x, add = TRUE, col = "lightgray", border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "x")
plot(b, add = TRUE, border = "grey")
plot(b, add = TRUE, border = "gray")
x_not_y = st_difference(x, y)
plot(b, border = "grey")
plot(x_not_y, col = "lightgrey", add = TRUE, border = "grey")
plot(b, border = "gray")
plot(x_not_y, col = "lightgray", add = TRUE, border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_difference(x, y)")

y_not_x = st_difference(y, x)
plot(b, border = "grey")
plot(y_not_x, col = "lightgrey", add = TRUE, border = "grey")
plot(b, border = "gray")
plot(y_not_x, col = "lightgray", add = TRUE, border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_difference(y, x)")
x_or_y = st_union(x, y)
plot(x_or_y, col = "lightgrey", border = "grey")
plot(x_or_y, col = "lightgray", border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_union(x, y)")
x_and_y = st_intersection(x, y)
plot(b, border = "grey")
plot(x_and_y, col = "lightgrey", add = TRUE, border = "grey")
plot(b, border = "gray")
plot(x_and_y, col = "lightgray", add = TRUE, border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_intersection(x, y)")
# x_xor_y = st_difference(x_xor_y, x_and_y) # failing
x_xor_y = st_sym_difference(x, y)
plot(x_xor_y, col = "lightgrey", border = "grey")
plot(x_xor_y, col = "lightgray", border = "gray")
text(cex = 1.8, x = 0.5, y = 1, "st_sym_difference(x, y)")
# plot.new()
# plot(b, border = "grey")
# plot(y, col = "lightgrey", add = TRUE, border = "grey")
# plot(b, add = TRUE, border = "grey")
# plot(b, border = "gray")
# plot(y, col = "lightgray", add = TRUE, border = "gray")
# plot(b, add = TRUE, border = "gray")
# text(cex = 1.2, x = 0.5, y = 1, "y")
par(old_par)
2 changes: 1 addition & 1 deletion code/13-cycleways.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ bristol_stations_top = bristol_stations[desire_rail, , op = st_is_within_distanc
m_leaflet = tm_shape(bristol_ttwa) +
tm_borders(col = "darkblue") +
tm_shape(bristol_ways) +
tm_lines(col = "highway", lwd = 3, palette = c("lightgreen", "grey", "pink")) +
tm_lines(col = "highway", lwd = 3, palette = c("lightgreen", "gray", "pink")) +
tm_scalebar() +
tm_shape(route_cycleway) +
tm_lines(col = "blue", lwd = "all", scale = 20, alpha = 0.6) +
Expand Down
4 changes: 2 additions & 2 deletions code/chapters/02-spatial-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ library(tmap)
tm1 = tm_shape(india_buffer_with_s2) +
tm_fill(col = hcl.colors(4, palette = "purple green")[3]) +
tm_shape(india) +
tm_fill(col = "grey95") +
tm_fill(col = "gray95") +
tm_layout(main.title = "st_buffer() with dist = 1",
title = "s2 switched on (default)")

tm2 = tm_shape(india_buffer_without_s2) +
tm_fill(col = hcl.colors(4, palette = "purple green")[3]) +
tm_shape(india) +
tm_fill(col = "grey95") +
tm_fill(col = "gray95") +
tm_layout(main.title = " ",
title = "s2 switched off")

Expand Down
2 changes: 1 addition & 1 deletion code/chapters/04-spatial-operations.R
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ plot(grid, col = grid_sf$rooks)
tm_shape(grid_sf) +
tm_fill(col = c("queens", "rooks"), palette = c("white", "black")) +
tm_shape(grid_sf) +
tm_borders(col = "grey", lwd = 2) +
tm_borders(col = "gray", lwd = 2) +
tm_layout(frame = FALSE, legend.show = FALSE,
panel.labels = c("queen", "rook"))

Expand Down
12 changes: 6 additions & 6 deletions code/chapters/05-geometry-operations.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ nz_scale_sf = st_set_geometry(nz, nz_scale)
## ----points, fig.cap="Overlapping circles.", fig.asp=0.4, crop = TRUE-------------------------------
b = st_sfc(st_point(c(0, 1)), st_point(c(1, 1))) # create 2 points
b = st_buffer(b, dist = 1) # convert points to circles
plot(b, border = "grey")
plot(b, border = "gray")
text(x = c(-0.5, 1.5), y = 1, labels = c("x", "y"), cex = 3) # add text


## ----circle-intersection, fig.cap="Overlapping circles with a gray color indicating intersection between them.", fig.asp=0.4, fig.scap="Overlapping circles showing intersection types.", crop = TRUE----
x = b[1]
y = b[2]
x_and_y = st_intersection(x, y)
plot(b, border = "grey")
plot(x_and_y, col = "lightgrey", border = "grey", add = TRUE) # intersecting area
plot(b, border = "gray")
plot(x_and_y, col = "lightgray", border = "gray", add = TRUE) # intersecting area


## ----venn-clip, echo=FALSE, fig.cap="Spatial equivalents of logical operators.", warning=FALSE------
Expand All @@ -194,9 +194,9 @@ box = st_as_sfc(bb)
set.seed(2017)
p = st_sample(x = box, size = 10)
p_xy1 = p[x_and_y]
plot(box, border = "grey", lty = 2)
plot(x, add = TRUE, border = "grey")
plot(y, add = TRUE, border = "grey")
plot(box, border = "gray", lty = 2)
plot(x, add = TRUE, border = "gray")
plot(y, add = TRUE, border = "gray")
plot(p, add = TRUE)
plot(p_xy1, cex = 3, col = "red", add = TRUE)
text(x = c(-0.5, 1.5), y = 1, labels = c("x", "y"), cex = 2)
Expand Down
4 changes: 2 additions & 2 deletions code/chapters/10-gis.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ aggzone_wgs = st_transform(aggregating_zones, "EPSG:4326")
## ----uniondata, echo=FALSE, fig.cap="Illustration of two areal units: incongruent (black lines) and aggregating zones (red borders). "----
library(tmap)
tm_shape(incongr_wgs) +
tm_polygons(border.col = "grey5") +
tm_polygons(border.col = "gray5") +
tm_shape(aggzone_wgs) +
tm_borders(alpha = 0.5, col = "red") +
tm_add_legend(type = "line",
labels = c("incongr_wgs", "aggzone_wgs"),
col = c("grey5", "red"),
col = c("gray5", "red"),
lwd = 3) +
tm_scale_bar(position = c("left", "bottom"),
breaks = c(0, 0.5, 1)) +
Expand Down
6 changes: 3 additions & 3 deletions code/chapters/_02-ex.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ text(world_coords, world$iso_a2)
# Alternative answer:
nigeria = world[world$name_long == "Nigeria", ]
africa = world[world$continent == "Africa", ]
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgrey", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "grey")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgrey")
plot(st_geometry(nigeria), col = "white", lwd = 3, main = "Nigeria in context", border = "lightgray", expandBB = c(0.5, 0.2, 0.5, 0.2))
plot(st_geometry(world), lty = 3, add = TRUE, border = "gray")
plot(st_geometry(nigeria), col = "yellow", add = TRUE, border = "darkgray")
a = africa[grepl("Niger", africa$name_long), ]
ncentre = st_centroid(a)
ncentre_num = st_coordinates(ncentre)
Expand Down
Loading

0 comments on commit bc7ca5f

Please sign in to comment.