10 Creating a Points Shapefile from Data

Often you will have a .csv file with x and y coordinates (either in lat/lon or UTM) that you sampled in the field and want to load into a GIS so that you can extract data from other GIS layers. Here’s how to do it. We’ll jump back to the San Joaquin Data set, so reset your working directory to the SJER folder (you’re getting lots of practice with working directories this way!)

First we need to load the csv plots data as an `sf object and display it

plots_sjer_csv <- st_read("SJER/sjer_plots.csv", options = c("X_POSSIBLE_NAMES=longitude", "Y_POSSIBLE_NAMES=latitude"), crs = 4326)
## options:        X_POSSIBLE_NAMES=longitude Y_POSSIBLE_NAMES=latitude 
## Reading layer `sjer_plots' from data source `C:\Users\ywiersma\Documents\BIOL4651\GIS_R_manual\ConservationGIS\SJER\sjer_plots.csv' using driver `CSV'
## Simple feature collection with 7 features and 4 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: -119.7432 ymin: 37.10542 xmax: -119.7298 ymax: 37.11729
## geographic CRS: WGS 84

Then we’ll re-project it to the UTM coordinates of the digital terrain models

plots_sjer_csv_utm <- st_transform(plots_sjer_csv, st_crs(SJER_dtm))

Now you can proceed to map these points with any of the other SJER layers, as you did before, if you’d like to do more practice.