Counties = readOGR(dsn = "C:/Users/humph173/Documents/Michigan_State/SLP_Beam_Diam/Counties_v17a",
layer = "Counties_v17a",
stringsAsFactors = FALSE)
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\humph173\Documents\Michigan_State\SLP_Beam_Diam\Counties_v17a", layer: "Counties_v17a"
## with 83 features
## It has 15 fields
## Integer64 fields read as strings: OBJECTID FIPSNUM
Michigan = gUnaryUnion(Counties)
MnYr = 1900
MxYr = 2019
CleanBird("C:/Users/humph173/Documents/Michigan_State/Marten/Marten_SDM/eBird/Data/ebd_btbwar_relFeb-2019.txt", "btbwar", MnYr, MxYr)
## Parsed with column specification:
## cols(
## .default = col_character(),
## `LAST EDITED DATE` = col_datetime(format = ""),
## `TAXONOMIC ORDER` = col_double(),
## `SUBSPECIES COMMON NAME` = col_logical(),
## `SUBSPECIES SCIENTIFIC NAME` = col_logical(),
## `BREEDING BIRD ATLAS CODE` = col_logical(),
## `BREEDING BIRD ATLAS CATEGORY` = col_logical(),
## COUNTY = col_logical(),
## `COUNTY CODE` = col_logical(),
## `BCR CODE` = col_logical(),
## `USFWS CODE` = col_logical(),
## `ATLAS BLOCK` = col_logical(),
## LATITUDE = col_double(),
## LONGITUDE = col_double(),
## `OBSERVATION DATE` = col_date(format = ""),
## `TIME OBSERVATIONS STARTED` = col_time(format = ""),
## `DURATION MINUTES` = col_double(),
## `EFFORT DISTANCE KM` = col_double(),
## `EFFORT AREA HA` = col_double(),
## `NUMBER OBSERVERS` = col_double(),
## `ALL SPECIES REPORTED` = col_double()
## # ... with 5 more columns
## )
## See spec(...) for full column specifications.
CleanBird("C:/Users/humph173/Documents/Michigan_State/Marten/Marten_SDM/eBird/Data/ebd_scatan_relFeb-2019.txt", "scatan", MnYr, MxYr)
## Parsed with column specification:
## cols(
## .default = col_character(),
## `LAST EDITED DATE` = col_datetime(format = ""),
## `TAXONOMIC ORDER` = col_double(),
## `SUBSPECIES COMMON NAME` = col_logical(),
## `SUBSPECIES SCIENTIFIC NAME` = col_logical(),
## COUNTY = col_logical(),
## `COUNTY CODE` = col_logical(),
## `BCR CODE` = col_double(),
## `USFWS CODE` = col_logical(),
## `ATLAS BLOCK` = col_logical(),
## LATITUDE = col_double(),
## LONGITUDE = col_double(),
## `OBSERVATION DATE` = col_date(format = ""),
## `TIME OBSERVATIONS STARTED` = col_time(format = ""),
## `DURATION MINUTES` = col_double(),
## `EFFORT DISTANCE KM` = col_double(),
## `EFFORT AREA HA` = col_double(),
## `NUMBER OBSERVERS` = col_double(),
## `ALL SPECIES REPORTED` = col_double(),
## `HAS MEDIA` = col_double(),
## APPROVED = col_double()
## # ... with 3 more columns
## )
## See spec(...) for full column specifications.
CleanBird("C:/Users/humph173/Documents/Michigan_State/Marten/Marten_SDM/eBird/Data/ebd_woothr_relFeb-2019.txt", "woothr", MnYr, MxYr)
## Parsed with column specification:
## cols(
## .default = col_character(),
## `LAST EDITED DATE` = col_datetime(format = ""),
## `TAXONOMIC ORDER` = col_double(),
## `SUBSPECIES COMMON NAME` = col_logical(),
## `SUBSPECIES SCIENTIFIC NAME` = col_logical(),
## `AGE/SEX` = col_logical(),
## COUNTY = col_logical(),
## `COUNTY CODE` = col_logical(),
## `BCR CODE` = col_logical(),
## `USFWS CODE` = col_logical(),
## `ATLAS BLOCK` = col_logical(),
## LATITUDE = col_double(),
## LONGITUDE = col_double(),
## `OBSERVATION DATE` = col_date(format = ""),
## `TIME OBSERVATIONS STARTED` = col_time(format = ""),
## `DURATION MINUTES` = col_double(),
## `EFFORT DISTANCE KM` = col_double(),
## `EFFORT AREA HA` = col_double(),
## `NUMBER OBSERVERS` = col_double(),
## `ALL SPECIES REPORTED` = col_double(),
## `HAS MEDIA` = col_double()
## # ... with 4 more columns
## )
## See spec(...) for full column specifications.
Selecting Michigan birds
btbwar.pnt = SpatialPointsDataFrame(btbwar[,c("Long", "Lat")], btbwar)
proj4string(btbwar.pnt) = proj4string(Michigan)
btbwar.pnt$MI = is.na(over(btbwar.pnt, Michigan))
btbwar.pnt = subset(btbwar.pnt, MI == FALSE)
scatan.pnt = SpatialPointsDataFrame(scatan[,c("Long", "Lat")], scatan)
proj4string(scatan.pnt) = proj4string(Michigan)
scatan.pnt$MI = is.na(over(scatan.pnt, Michigan))
scatan.pnt = subset(scatan.pnt, MI == FALSE)
woothr.pnt = SpatialPointsDataFrame(woothr[,c("Long", "Lat")], woothr)
proj4string(woothr.pnt) = proj4string(Michigan)
woothr.pnt$MI = is.na(over(woothr.pnt, Michigan))
woothr.pnt = subset(woothr.pnt, MI == FALSE)
btbwar.df = as.data.frame(
btbwar.pnt@data %>%
group_by(Year) %>%
summarise(Count = length(Year)))
#Total
sum(btbwar.df$Count)
## [1] 2733
btbwar.df
## Year Count
## 1 1937 1
## 2 1959 1
## 3 1961 1
## 4 1963 1
## 5 1964 1
## 6 1965 1
## 7 1966 1
## 8 1967 1
## 9 1968 1
## 10 1970 1
## 11 1971 2
## 12 1972 3
## 13 1973 1
## 14 1974 5
## 15 1975 2
## 16 1976 4
## 17 1977 5
## 18 1978 3
## 19 1979 3
## 20 1980 1
## 21 1981 5
## 22 1982 3
## 23 1983 4
## 24 1984 4
## 25 1985 2
## 26 1986 1
## 27 1987 1
## 28 1988 5
## 29 1989 4
## 30 1990 7
## 31 1991 3
## 32 1992 9
## 33 1993 6
## 34 1994 6
## 35 1995 8
## 36 1996 15
## 37 1997 18
## 38 1998 13
## 39 1999 10
## 40 2000 7
## 41 2001 11
## 42 2002 17
## 43 2003 17
## 44 2004 29
## 45 2005 31
## 46 2006 43
## 47 2007 43
## 48 2008 47
## 49 2009 63
## 50 2010 73
## 51 2011 132
## 52 2012 157
## 53 2013 186
## 54 2014 306
## 55 2015 268
## 56 2016 327
## 57 2017 338
## 58 2018 475
##Plot
wmap_df = fortify(Counties)
## Regions defined for each Polygons
tmp.df = btbwar.pnt@data
ggplot(wmap_df, aes(long,lat, group=group)) +
geom_polygon(fill = "lightgray", col="darkgray") +
geom_point(data=tmp.df,
aes(Long, Lat, group=NA),
col = "red",
size = 0.5) +
xlab("Longitude") +
ylab("Latitude") +
ggtitle("btbwar Locations") +
#scale_x_longitude(xmin=-110, xmax=80, step=10) +
#scale_y_latitude(ymin=20, ymax=60, step=10) +
coord_equal() +
theme(panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
legend.title = element_text(size=16, face="bold"),
axis.title.x = element_text(size=22, face="bold"),
axis.title.y = element_text(size=22, face="bold"),
plot.title = element_text(size=24, face="bold", hjust = 0.5))
scatan.df = as.data.frame(
scatan.pnt@data %>%
group_by(Year) %>%
summarise(Count = length(Year)))
#Total
sum(scatan.df$Count)
## [1] 8311
scatan.df
## Year Count
## 1 1909 1
## 2 1937 1
## 3 1955 4
## 4 1959 3
## 5 1960 2
## 6 1963 3
## 7 1964 9
## 8 1965 4
## 9 1966 3
## 10 1967 5
## 11 1968 2
## 12 1969 2
## 13 1970 2
## 14 1971 9
## 15 1972 2
## 16 1973 4
## 17 1974 7
## 18 1975 3
## 19 1976 12
## 20 1977 19
## 21 1978 8
## 22 1979 8
## 23 1980 5
## 24 1981 8
## 25 1982 5
## 26 1983 8
## 27 1984 7
## 28 1985 3
## 29 1986 4
## 30 1987 9
## 31 1988 6
## 32 1989 3
## 33 1990 10
## 34 1991 14
## 35 1992 18
## 36 1993 14
## 37 1994 14
## 38 1995 13
## 39 1996 24
## 40 1997 16
## 41 1998 26
## 42 1999 17
## 43 2000 17
## 44 2001 26
## 45 2002 36
## 46 2003 35
## 47 2004 57
## 48 2005 84
## 49 2006 119
## 50 2007 136
## 51 2008 129
## 52 2009 178
## 53 2010 209
## 54 2011 283
## 55 2012 496
## 56 2013 779
## 57 2014 891
## 58 2015 999
## 59 2016 1113
## 60 2017 1175
## 61 2018 1212
##Plot
wmap_df = fortify(Counties)
## Regions defined for each Polygons
tmp.df = scatan.pnt@data
ggplot(wmap_df, aes(long,lat, group=group)) +
geom_polygon(fill = "lightgray", col="darkgray") +
geom_point(data=tmp.df,
aes(Long, Lat, group=NA),
col = "red",
size = 0.5) +
xlab("Longitude") +
ylab("Latitude") +
ggtitle("scatan Locations") +
#scale_x_longitude(xmin=-110, xmax=80, step=10) +
#scale_y_latitude(ymin=20, ymax=60, step=10) +
coord_equal() +
theme(panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
legend.title = element_text(size=16, face="bold"),
axis.title.x = element_text(size=22, face="bold"),
axis.title.y = element_text(size=22, face="bold"),
plot.title = element_text(size=24, face="bold", hjust = 0.5))
woothr.df = as.data.frame(
woothr.pnt@data %>%
group_by(Year) %>%
summarise(Count = length(Year)))
#Total
sum(woothr.df$Count)
## [1] 6336
woothr.df
## Year Count
## 1 1953 1
## 2 1954 1
## 3 1955 2
## 4 1959 2
## 5 1962 1
## 6 1963 6
## 7 1964 4
## 8 1965 2
## 9 1966 2
## 10 1967 4
## 11 1968 5
## 12 1969 2
## 13 1970 5
## 14 1971 7
## 15 1972 4
## 16 1973 4
## 17 1974 7
## 18 1975 5
## 19 1976 11
## 20 1977 13
## 21 1978 6
## 22 1979 4
## 23 1980 4
## 24 1981 5
## 25 1982 4
## 26 1983 10
## 27 1984 3
## 28 1985 5
## 29 1986 3
## 30 1987 4
## 31 1988 6
## 32 1989 5
## 33 1990 5
## 34 1991 4
## 35 1992 18
## 36 1993 8
## 37 1994 12
## 38 1995 19
## 39 1996 21
## 40 1997 22
## 41 1998 29
## 42 1999 24
## 43 2000 20
## 44 2001 40
## 45 2002 38
## 46 2003 36
## 47 2004 59
## 48 2005 73
## 49 2006 106
## 50 2007 98
## 51 2008 109
## 52 2009 143
## 53 2010 180
## 54 2011 221
## 55 2012 340
## 56 2013 584
## 57 2014 654
## 58 2015 664
## 59 2016 815
## 60 2017 822
## 61 2018 1025
##Plot
wmap_df = fortify(Counties)
## Regions defined for each Polygons
tmp.df = woothr.pnt@data
ggplot(wmap_df, aes(long,lat, group=group)) +
geom_polygon(fill = "lightgray", col="darkgray") +
geom_point(data=tmp.df,
aes(Long, Lat, group=NA),
col = "red",
size = 0.5) +
xlab("Longitude") +
ylab("Latitude") +
ggtitle("woothr Locations") +
#scale_x_longitude(xmin=-110, xmax=80, step=10) +
#scale_y_latitude(ymin=20, ymax=60, step=10) +
coord_equal() +
theme(panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
legend.title = element_text(size=16, face="bold"),
axis.title.x = element_text(size=22, face="bold"),
axis.title.y = element_text(size=22, face="bold"),
plot.title = element_text(size=24, face="bold", hjust = 0.5))