You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: resources/mapping.qmd
+27-2Lines changed: 27 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -156,14 +156,39 @@ locations_sf
156
156
Notice the differences between `locations` and `locations_sf`. The latter has combined the `long` and `lat` columns into a single `geometry` column, while we also get attributes about the object's CRS as shown above in @fig-sf.
157
157
158
158
### 3. Get a base map
159
-
There are many packages that provide vector mapping data in R. [rnaturalearth](https://docs.ropensci.org/rnaturalearth/index.html) is a great starting point. It contains worldwide data for administrative boundaries and natural features such as lakes, rivers, and oceans. [tigris](https://github.com/walkerke/tigris) provides access to census bureau geographic data. In this example we will use [USAboundaries](https://docs.ropensci.org/USAboundaries/index.html), which provides contemporary and historical boundaries in the United states. Note that both rnaturalearth and USAboundaries provide most of the data through secondary packages. If these packages are needed, you will be prompted to install them. Both rnaturalearth and USAboundaries return `sf` objects with a CRS of EPSG:4326.
159
+
There are many packages that provide vector mapping data in R. [rnaturalearth](https://docs.ropensci.org/rnaturalearth/index.html) is a great starting point. It contains worldwide data for administrative boundaries and natural features such as lakes, rivers, and oceans. [tigris](https://github.com/walkerke/tigris) provides access to census bureau geographic data. In this example we will use [USAboundaries](https://docs.ropensci.org/USAboundaries/index.html), which provides contemporary and historical boundaries in the United states. Both rnaturalearth and USAboundaries provide most of the data through secondary packages. If these packages are needed, you will be prompted to install them.
160
160
161
-
Here, we want county data for a single state.
161
+
162
+
::: {.callout-warning collapse=false}
163
+
## Installing data packages on Windows
164
+
If the installation fails on Windows with an error that the package cannot be built, there are two options to solve the issue.
165
+
166
+
1. Download and install [RTools](https://cran.r-project.org/bin/windows/Rtools/), which makes it possible to build packages.
167
+
2. Install the package from a different repository:
Both rnaturalearth and USAboundaries return `sf` objects with a CRS of EPSG:4326. Here, we want county data for a single state.
162
186
163
187
```{r}
164
188
virginia <- us_counties(states = "Virginia")
165
189
```
166
190
191
+
167
192
### 4. Reproject the data
168
193
Now we have the data, but we might want to change our data from using the web Mercator projection to a CRS that more accurately reflects the local area. USAboundaries provides both a data frame of the [State Plane Coordinate System](https://en.wikipedia.org/wiki/State_Plane_Coordinate_System) projections as EPSG codes and a function to quickly return the code for a state. We can then use `st_transform()` to reproject the data.
0 commit comments