First, transform SFhomes15_sp
(Remember, this is also called reprojecting.)
Note the two methods for doing same thing:
SFhighways <- st_read ("/Users/dr.auwal/Desktop/Personals/UC Berkeley/Workshops/Geospatial-Fundamentals-in-R-with-sf/2nd Workshop/Geospatial-Fundamentals-in-R-with-sf-master/data", "sfhighways")
## Reading layer `sfhighways' from data source `/Users/dr.auwal/Desktop/Personals/UC Berkeley/Workshops/Geospatial-Fundamentals-in-R-with-sf/2nd Workshop/Geospatial-Fundamentals-in-R-with-sf-master/data' using driver `ESRI Shapefile'
## Simple feature collection with 246 features and 5 fields
## geometry type: LINESTRING
## dimension: XY
## bbox: xmin: 543789.3 ymin: 4173548 xmax: 551295.9 ymax: 4183929
## epsg (SRID): 26910
## proj4string: +proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
SFhomes <- read.csv('/Users/dr.auwal/Desktop/Personals/UC Berkeley/Workshops/Geospatial-Fundamentals-in-R-with-sf/2nd Workshop/Geospatial-Fundamentals-in-R-with-sf-master/data/sf_properties_25ksample.csv',
stringsAsFactors = FALSE)
SFhomes_low2high <- SFhomes[order(SFhomes$totvalue, decreasing = FALSE),]
SFhomes15 <- subset(SFhomes_low2high, as.numeric(SalesYear) == 2015)
SFhomes15_sf = st_as_sf(SFhomes15, coords = c('lon', 'lat'), crs = 4326)
SFhomes15_sf
## Simple feature collection with 835 features and 17 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -122.5107 ymin: 37.70854 xmax: -122.3696 ymax: 37.80612
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## First 10 features:
## FiscalYear SalesDate Address
## 14769 2015 2015-10-06 0000 1450 POST ST0414
## 9640 2015 2015-08-25 0000 0695 MONTEREY BL0404
## 11598 2015 2015-05-15 0000 1224 QUESADA AV0000
## 14353 2015 2015-12-23 0000 0451 DONAHUE ST0410
## 631 2015 2015-12-30 0000 0900 NORTH POINT ST0B30J
## 18323 2015 2015-12-21 0000 0900 NORTH POINT ST0B30H
## 20877 2015 2015-02-24 0000 1515 15TH ST0302
## 21079 2015 2015-01-15 0000 2275 FRANCISCO ST0000
## 23919 2015 2015-11-30 0000 6901 GEARY BL0000
## 13054 2015 2015-12-15 0000 1400 MISSION ST1501
## YearBuilt NumBedrooms NumBathrooms NumRooms NumStories NumUnits
## 14769 1992 0 0 0 0 1
## 9640 1986 3 3 6 0 1
## 11598 1941 0 0 5 1 1
## 14353 2016 1 1 3 1 1
## 631 1912 2 2 0 0 1
## 18323 1912 2 2 0 0 1
## 20877 2014 2 2 4 1 1
## 21079 1927 0 0 21 3 1
## 23919 NA 0 0 0 1 1
## 13054 2015 2 2 0 1 1
## AreaSquareFeet ImprovementValue LandValue Neighborhood
## 14769 385 91929 48607 Japantown
## 9640 1477 108780 56256 West of Twin Peaks
## 11598 1250 112252 71266 Bayview Hunters Point
## 14353 595 218408 0 Bayview Hunters Point
## 631 1141 110000 110000 Russian Hill
## 18323 1141 110000 110000 Russian Hill
## 20877 981 115735 173603 Mission
## 21079 6837 203899 95657 Marina
## 23919 831 235983 71103 Outer Richmond
## 13054 913 309368 0 South of Market
## Location SupeDistrict totvalue
## 14769 (37.7863611689805, -122.425831110524) 5 140536
## 9640 (37.7312597444151, -122.450868995954) 7 165036
## 11598 (37.7285228603168, -122.382421022114) 10 183518
## 14353 (37.7290014854275, -122.369639191495) 10 218408
## 631 (37.8058579128889, -122.422925403947) 2 220000
## 18323 (37.8058579128889, -122.422925403947) 2 220000
## 20877 (37.7665417944845, -122.417977539825) 9 289338
## 21079 (37.8006926337809, -122.442482058931) 2 299556
## 23919 (37.7793761112608, -122.4936144478) 1 307086
## 13054 (37.7752826710964, -122.416489870771) 6 309368
## SalesYear geometry
## 14769 2015 POINT (-122.4258 37.78636)
## 9640 2015 POINT (-122.4509 37.73126)
## 11598 2015 POINT (-122.3824 37.72852)
## 14353 2015 POINT (-122.3696 37.729)
## 631 2015 POINT (-122.4229 37.80586)
## 18323 2015 POINT (-122.4229 37.80586)
## 20877 2015 POINT (-122.418 37.76654)
## 21079 2015 POINT (-122.4425 37.80069)
## 23919 2015 POINT (-122.4936 37.77938)
## 13054 2015 POINT (-122.4165 37.77528)
#highways are already in 26910!
st_crs(SFhighways)
## Coordinate Reference System:
## EPSG: 26910
## proj4string: "+proj=utm +zone=10 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
#so we can use them as the target CRS
SFhomes15_utm <- st_transform(SFhomes15_sf, st_crs(SFhighways))
#OR we could just use the EPSG code directly
#SFhomes15_utm <- st_transform(SFhomes15_sf, 26910)