/
.Rhistory
65 lines (65 loc) · 2.16 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
rm(list=ls(all=TRUE))
library(dplyr)
library(rgdal)
library(ggplot2)
library(raster)
# set working directory
setwd("~elahi/github/marBiodivChange_impacts/")
# Load data table of impact scores from Ginger Allington
siteList <- read.csv("./data/elahi_extractedVals.csv")
unique(siteList$studyName)
# Need to remove large-scale studies that were not used in the CB analysis
sl2 <- siteList[siteList$studyName != "Keller" &
siteList$studyName != "Bebars" &
siteList$studyName != "Greenwood" &
siteList$studyName != "Sonnewald" &
siteList$studyName != "SwedFishTrawl" , ]
unique(sl2$studyName)
# Categorize impact score or not, rename and select columns
sl2$impact <- with(sl2, ifelse(Impact.Score == -9999, "no", "yes"))
head(sl2)
sl3 <- sl2 %>% rename(Long = Long_, impactScore = Impact.Score,
originalID = OBJECTID..) %>%
dplyr::select(originalID, studyName, Lat, Long, impactScore, impact)
head(sl3)
# write.csv(sl3, './data/elahi_cb_sites.csv')
###############################
###############################
# First order of business, as proof of concept
# Can I replicate Ginger's extracted scores?
head(sl3)
with(sl3, table(impact))
# 62 sites did not get an impact score, because
# the points were on land or data were NA
# remove these 62
sl4 <- sl3 %>% filter(impact == "yes")
summary(sl4)
# rename file
pointsObject <- sl4
head(pointsObject)
# set spatial coordinates to create a spatial object
# c(x, y) i.e., c(long, lat)
coordinates(pointsObject) <- c("Long", "Lat")
pointsObject
head(pointsObject)
str(pointsObject)
# set projection reference
projection(pointsObject) <-
"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
Samplepts<-readShapePoints("Samplepts.shp")
library(raster)
library(rgdal)
library(dismo)
library(maptools)
install.packages("dismo")
Samplepts<-readShapePoints("Vellendpts.shp")
install.packages("mapstools")
install.packages("maptools")
Samplepts<-readShapePoints("Vellendpts.shp")
library(dismo)
Samplepts<-readShapePoints("Vellendpts.shp")
library(maptools)
Samplepts<-readShapePoints("Vellendpts.shp")
Samplepts<-readShapePoints("./data/Vellendpts.shp")
Samplepts<-readShapePoints("./data/vellendpts.shp")
Samplepts<-readShapePoints("./data/Dornelas_mar.shp")