--- title: "Manipulate a Simple Feature Data Frame" output: html_notebook: toc: yes toc_float: yes --- ## Introduction In this Notebook you'll practice importing some tabular data in to R, converting it to a simple feature data frame, projecting it, and saving it to disk as a GeoJSON file. \ ## 1) Import the missing persons CSV file: ```{r chunk01} miss_pips_df <- read.csv("./data/yosemite_missing_people.csv", stringsAsFactors = FALSE) head(miss_pips_df) # View(miss_pips_df) ``` \ Let's reduce the number of columns: ```{r chunk02} library(dplyr) miss_pips_thin_df <- miss_pips_df |> select(Long, Lat, Type, CaseNumber, IncidYear, ContactMet, IncidType, NumberofSu, GroupDynam, SubjectCat, SubSex, SubAge, IncidContr, Scenario, RescueMeth, Incident_N, Found_GR_N) head(miss_pips_thin_df) ``` \ ## 2) Convert the data frame to a simple feature data frame For convenience, here are some EPSG numbers: ```{r chunk03} epsg_geo_wgs84 <- 4326 ## General long-lat epsg_utm11n_nad83 <- 26911 ## use this one for YNP ``` Convert a data frame to a spatial object with `st_as_sf()`. You have to specify the names of the columns that contain the coordinates, and the EPSG number of the coordinates. ```{r chunk04} library(sf) miss_pips_sf <- st_as_sf(miss_pips_thin_df, coords = c("Long", "Lat"), crs = epsg_geo_wgs84) miss_pips_sf ``` \ ## 3) Project the missing persons layer to UTM 11N (NAD83) [Hint](https://bit.ly/3wJ46lJ). [Answer](https://bit.ly/3wmhGv6) ```{r chunk05} ## Your answer here ``` \ ## 4) Save as GeoJSON You can save a spatial object to disk with `st_write()`. R will figure out what format to use based on the file name extension. Save the Missing Persons layer as GeoJSON: [Answer](https://bit.ly/3wb8KcM) ```{r chunk06} ## Your answer here ```