Coordinate reference systems

Visualizing Geospatial Data in R

Charlotte Wickham

Assistant Professor at Oregon State University

proj4string()

proj4string(countries_spdf)
"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

                                                                    ↑  Good for global datasets ↑

proj4string(water)
"+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"

                                                                    ↑ Common for US datasets ↑

Visualizing Geospatial Data in R

proj4string()

proj4string(nyc_tracts)
"+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"
proj4string(neighborhoods)
"+proj=lcc +lat_1=40.66666666666666 +lat_2=41.03333333333333 
+lat_0=40.16666666666666 +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83 

+units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0"

Lambert Conformal Conic projection

Visualizing Geospatial Data in R

Setting CRS

x <- SpatialPoints(data.frame(-123.2620, 44.5646))
x
class       : SpatialPoints 
features    : 1 
extent      : -123.262, -123.262, 44.5646, 44.5646  (xmin, xmax, ymin, ymax)
coord. ref. : NA
proj4string(x) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
x
class       : SpatialPoints 
features    : 1 
extent      : -123.262, -123.262, 44.5646, 44.5646  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
Visualizing Geospatial Data in R

Transforming CRS

rgdal::spTransform(x, CRSobj, ...)

spTransform(x, "+proj=lcc +lat_1=40.66666666666666         
                +lat_2=41.03333333333333 +lat_0=40.16666666666666  
                +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83
                +units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0")
Visualizing Geospatial Data in R

Transforming CRS

rgdal::spTransform(x, CRSobj, ...)

spTransform(x, proj4string(neighborhoods))
class       : SpatialPoints 
features    : 1 
extent      : -11214982, -11214982, 5127323, 5127323  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=lcc +lat_1=40.66666666666666    
              +lat_2=41.03333333333333 +lat_0=40.16666666666666 
              +lon_0=-74 +x_0=300000 +y_0=0 +datum=NAD83 
              +units=us-ft +no_defs +ellps=GRS80 +towgs84=0,0,0 
Visualizing Geospatial Data in R

Let's practice!

Visualizing Geospatial Data in R

Preparing Video For Download...