From 979b8b69eb92342faf016e0b16054652d1dfbd45 Mon Sep 17 00:00:00 2001 From: Robin Lovelace Date: Sat, 28 Oct 2017 14:37:14 +0100 Subject: [PATCH] Update rmdnote on geometry col name Based on discussion in https://github.com/Robinlovelace/geocompr/commit/d2472619a81306037e1d414cfe219b240d768669 with @Nowosad --- 03-attribute-operations.Rmd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/03-attribute-operations.Rmd b/03-attribute-operations.Rmd index 64334bbbc..e09b1d2ef 100644 --- a/03-attribute-operations.Rmd +++ b/03-attribute-operations.Rmd @@ -72,9 +72,10 @@ Many of these functions, including `rbind()` (for binding rows of data together) A key feature of `sf` objects is that they store spatial and non-spatial data in the same way, as columns in a `data.frame` (the geometry column is typically called `geometry`). ```{block2 type = 'rmdnote'} -It is important to note that the geometry column of an `sf` object is typically called `geometry`. -However, `sf`-objects imported from a spatial database might have names such as `wkb_geometry`, `the_geog` or `the_geom`. -Additionally, an R user can rename the geometry column of an `sf` object however he/she likes. +The geometry column of `sf` objects is typically called `geometry` but any name can be used. +The following command, for example, creates a geometry column named `g`: +`st_sf(data.frame(n = world$name_long), g = world$geom)`. +This enables geometries imported from spatial databases to have a variety of names such as `wkb_geometry`, the_geog` and `the_geom`. ``` `sf` objects also support `tibble` and `tbl` classes used in the tidyverse, allowing 'tidy' data analysis workflows for spatial data.