Misty Start Here:

Inits

    erd2023_filename <- "erd_2023.WI.data.parquet"  
    srd2023_filename <- "srd_2023.WI.data.parquet"
    solar_filename <-   "pv-1000kW-updated.csv"

Define WI Region & Season of interest

    max_lat <- 47
    max_lon <- -86.5
    min_lat <- 42.4
    min_lon <- -93
    day_max <- 210
    day_min <- 150

Load 2023 ERD & SRD & Solar data

erd <- read_parquet(erd2023_filename)
    srd <- read_parquet(srd2023_filename)
    solar <- read.csv(solar_filename)
dim(erd)
## [1] 174084    527
    dim(srd)
## [1] 24912   122
    dim(solar)
## [1] 93 13

Identify which ERD checklists (in B) are within a specified distance of any Solar installations (in A)

    A <- data.frame(
      lat = solar$latitude,
      lon = solar$longitude )
    A <- A[ complete.cases(A), ]
    

    # In any column in the data frame, remove rows with missing values.
    B <- data.frame(
      lat = erd$latitude,
      lon = erd$longitude, 
      checklist_id = erd$checklist_id )
    # (each element is the distance between one point in A and one in B)

    dist_matrix <- distm(
        cbind(B$lon, B$lat), 
        cbind(A$lon, A$lat), 
        fun = distHaversine)
head(dist_matrix)
    distance_threshold <- 10000  # 10k meters or 10 km

    within_distance <- apply(
        dist_matrix, 1, 
        function(distances) any(distances <= distance_threshold))
    B_within_distance <- B[within_distance, ]
head(B_within_distance)
head(within_distance)

Maps

plot checklists, solar arrays, and solar circles

# Plot Locations
    par(cex = 0.5)
#mfrow = c(1,2), 

    xxx <- erd$longitude
    yyy <- erd$latitude
    plot(xxx, yyy, 
        xlab = "Lon", 
        ylab = "Lat",
        main = "Breeding Season ERD2023",
        pch = 20,  
        cex = 0.15, 
        col = alpha("blue", 0.20 ))
    map("state", add=T, col="black") 

        # Add points to plot 
    points(
        A$lon, A$lat, 
        col=alpha("green", 0.5), pch = 19, cex = 2.5)
    points(
        B_within_distance$lon, B_within_distance$lat, 
        col=alpha("orange", 0.25), 
        pch = 19, cex = 0.25)

plot ??

xxx <- srd$longitude
    yyy <- srd$latitude
    plot(xxx, yyy, 
        xlab = "Lon", 
        ylab = "Lat",
        main = "SRD2023",
        pch = 20,  
        cex = 0.15, 
        col = alpha("orange", 1.0 ))
    map("state", add=T, col="black")

plot circles and orange only

# Plot Locations
    par(cex = 0.5)
#mfrow = c(1,2), 

    plot(A$lon, A$lat, 
        xlab = "Lon", 
        ylab = "Lat",
            col=alpha("green", 0.5), pch = 19, cex = 5,
        xlim = c(-92, -91), ylim = c(45.5,46.5))
    map("state", add=T, col="black") 

        # Add points to plot 
    
        points(
        B_within_distance$lon, B_within_distance$lat, 
        col=alpha("orange", 0.5), 
        pch = 19, cex = 0.25)
# Look how much data there are!
    dim(B_within_distance)
    dim(unique(B_within_distance[,c(1:2)]))
    # [1] 33982     3
    # [1] 14329     2

Determine how many checklists within 10 km of array

array46_91.2 = A %>% filter(A$lat > -91.7 & A$lat < 91.2)
dim(array46_91.2)
head(erd$latitude)

——————————————————————–

Checklist feature names

These include environmental and observation process features

——————————————————————–

range(erd$longitude)
## [1] -92.99995 -86.50023
range(erd$latitude)
## [1] 42.40009 46.99900
names(erd)
##   [1] "checklist_id"                       "observer_id"                       
##   [3] "loc_id"                             "longitude"                         
##   [5] "latitude"                           "year"                              
##   [7] "day_of_year"                        "hours_of_day"                      
##   [9] "solar_noon_diff"                    "is_stationary"                     
##  [11] "effort_hrs"                         "effort_distance_km"                
##  [13] "effort_speed_kmph"                  "num_observers"                     
##  [15] "cci"                                "moon_fraction"                     
##  [17] "moon_altitude"                      "cds_u10"                           
##  [19] "cds_v10"                            "cds_d2m"                           
##  [21] "cds_t2m"                            "cds_hcc"                           
##  [23] "cds_i10fg"                          "cds_mcc"                           
##  [25] "cds_lcc"                            "cds_sf"                            
##  [27] "cds_rf"                             "cds_slc"                           
##  [29] "cds_msl"                            "eastness_1km_median"               
##  [31] "eastness_1km_sd"                    "eastness_90m_median"               
##  [33] "eastness_90m_sd"                    "northness_1km_median"              
##  [35] "northness_1km_sd"                   "northness_90m_median"              
##  [37] "northness_90m_sd"                   "bathymetry_elevation_median"       
##  [39] "bathymetry_elevation_sd"            "elevation_30m_median"              
##  [41] "elevation_30m_sd"                   "island"                            
##  [43] "mountain"                           "astwbd_c1_ed"                      
##  [45] "astwbd_c1_pland"                    "astwbd_c2_ed"                      
##  [47] "astwbd_c2_pland"                    "astwbd_c3_ed"                      
##  [49] "astwbd_c3_pland"                    "gsw_c2_pland"                      
##  [51] "gsw_c2_ed"                          "ntl_mean"                          
##  [53] "ntl_sd"                             "road_density_c1"                   
##  [55] "road_density_c2"                    "road_density_c3"                   
##  [57] "road_density_c4"                    "road_density_c5"                   
##  [59] "mcd12q1_lccs1_c1_ed"                "mcd12q1_lccs1_c1_pland"            
##  [61] "mcd12q1_lccs1_c2_ed"                "mcd12q1_lccs1_c2_pland"            
##  [63] "mcd12q1_lccs1_c11_ed"               "mcd12q1_lccs1_c11_pland"           
##  [65] "mcd12q1_lccs1_c12_ed"               "mcd12q1_lccs1_c12_pland"           
##  [67] "mcd12q1_lccs1_c13_ed"               "mcd12q1_lccs1_c13_pland"           
##  [69] "mcd12q1_lccs1_c14_ed"               "mcd12q1_lccs1_c14_pland"           
##  [71] "mcd12q1_lccs1_c15_ed"               "mcd12q1_lccs1_c15_pland"           
##  [73] "mcd12q1_lccs1_c16_ed"               "mcd12q1_lccs1_c16_pland"           
##  [75] "mcd12q1_lccs1_c21_ed"               "mcd12q1_lccs1_c21_pland"           
##  [77] "mcd12q1_lccs1_c22_ed"               "mcd12q1_lccs1_c22_pland"           
##  [79] "mcd12q1_lccs1_c31_ed"               "mcd12q1_lccs1_c31_pland"           
##  [81] "mcd12q1_lccs1_c32_ed"               "mcd12q1_lccs1_c32_pland"           
##  [83] "mcd12q1_lccs1_c41_ed"               "mcd12q1_lccs1_c41_pland"           
##  [85] "mcd12q1_lccs1_c42_ed"               "mcd12q1_lccs1_c42_pland"           
##  [87] "mcd12q1_lccs1_c43_ed"               "mcd12q1_lccs1_c43_pland"           
##  [89] "mcd12q1_lccs1_c255_ed"              "mcd12q1_lccs1_c255_pland"          
##  [91] "mcd12q1_lccs2_c9_ed"                "mcd12q1_lccs2_c9_pland"            
##  [93] "mcd12q1_lccs2_c25_ed"               "mcd12q1_lccs2_c25_pland"           
##  [95] "mcd12q1_lccs2_c35_ed"               "mcd12q1_lccs2_c35_pland"           
##  [97] "mcd12q1_lccs2_c36_ed"               "mcd12q1_lccs2_c36_pland"           
##  [99] "mcd12q1_lccs3_c27_ed"               "mcd12q1_lccs3_c27_pland"           
## [101] "mcd12q1_lccs3_c50_ed"               "mcd12q1_lccs3_c50_pland"           
## [103] "mcd12q1_lccs3_c51_ed"               "mcd12q1_lccs3_c51_pland"           
## [105] "has_shoreline"                      "shoreline_waveheight_mean"         
## [107] "shoreline_waveheight_sd"            "shoreline_tidal_range_mean"        
## [109] "shoreline_tidal_range_sd"           "shoreline_chlorophyll_mean"        
## [111] "shoreline_chlorophyll_sd"           "shoreline_turbidity_mean"          
## [113] "shoreline_turbidity_sd"             "shoreline_sinuosity_mean"          
## [115] "shoreline_sinuosity_sd"             "shoreline_slope_mean"              
## [117] "shoreline_slope_sd"                 "shoreline_outflow_density_mean"    
## [119] "shoreline_outflow_density_sd"       "shoreline_erodibility_n"           
## [121] "shoreline_erodibility_c1_density"   "shoreline_erodibility_c2_density"  
## [123] "shoreline_erodibility_c3_density"   "shoreline_erodibility_c4_density"  
## [125] "shoreline_emu_physical_n"           "shoreline_emu_physical_c1_density" 
## [127] "shoreline_emu_physical_c2_density"  "shoreline_emu_physical_c3_density" 
## [129] "shoreline_emu_physical_c4_density"  "shoreline_emu_physical_c5_density" 
## [131] "shoreline_emu_physical_c6_density"  "shoreline_emu_physical_c7_density" 
## [133] "shoreline_emu_physical_c8_density"  "shoreline_emu_physical_c9_density" 
## [135] "shoreline_emu_physical_c10_density" "shoreline_emu_physical_c11_density"
## [137] "shoreline_emu_physical_c12_density" "shoreline_emu_physical_c13_density"
## [139] "shoreline_emu_physical_c14_density" "shoreline_emu_physical_c15_density"
## [141] "shoreline_emu_physical_c16_density" "shoreline_emu_physical_c17_density"
## [143] "shoreline_emu_physical_c18_density" "shoreline_emu_physical_c19_density"
## [145] "shoreline_emu_physical_c20_density" "shoreline_emu_physical_c21_density"
## [147] "shoreline_emu_physical_c22_density" "shoreline_emu_physical_c23_density"
## [149] "has_evi"                            "evi_median"                        
## [151] "evi_sd"                             "wilsni1"                           
## [153] "comloo"                             "virrai2"                           
## [155] "mallar3"                            "pibgre"                            
## [157] "easwpw1"                            "cedwax"                            
## [159] "dowwoo"                             "amerob"                            
## [161] "baleag"                             "rthhum"                            
## [163] "rewbla"                             "olsfly"                            
## [165] "easblu"                             "easpho"                            
## [167] "blujay"                             "boboli"                            
## [169] "eursta"                             "bnhcow"                            
## [171] "moudov"                             "comrav"                            
## [173] "rocpig"                             "whbnut"                            
## [175] "yebsap"                             "balori"                            
## [177] "purfin"                             "comgra"                            
## [179] "treswa"                             "easkin"                            
## [181] "amegfi"                             "amecro"                            
## [183] "haiwoo"                             "amebit"                            
## [185] "eastow"                             "eawpew"                            
## [187] "barswa"                             "swaspa"                            
## [189] "sancra"                             "norcar"                            
## [191] "sora"                               "robgro"                            
## [193] "indbun"                             "buggna"                            
## [195] "comyel"                             "veery"                             
## [197] "reevir1"                            "houwre"                            
## [199] "rehwoo"                             "sonspa"                            
## [201] "nrwswa"                             "comnig"                            
## [203] "grycat"                             "wooduc"                            
## [205] "brdowl"                             "cangoo"                            
## [207] "blkter"                             "amwpel"                            
## [209] "purmar"                             "y00475"                            
## [211] "grnher"                             "forter"                            
## [213] "dickci"                             "wilfly"                            
## [215] "graspa"                             "easmea"                            
## [217] "rebwoo"                             "grbher3"                           
## [219] "killde"                             "warvir"                            
## [221] "belkin1"                            "grcfly"                            
## [223] "yelwar"                             "bkcchi"                            
## [225] "ribgul"                             "hergul"                            
## [227] "chiswi"                             "houspa"                            
## [229] "mouwar"                             "amered"                            
## [231] "chswar"                             "chispa"                            
## [233] "wiltur"                             "pilwoo"                            
## [235] "pinsis"                             "turvul"                            
## [237] "houfin"                             "scatan"                            
## [239] "yetvir"                             "ovenbi1"                           
## [241] "osprey"                             "yebcha"                            
## [243] "brebla"                             "leafly"                            
## [245] "grhowl"                             "rethaw"                            
## [247] "fiespa"                             "baisan"                            
## [249] "cliswa"                             "litgul"                            
## [251] "shbdow"                             "bongul"                            
## [253] "lesyel"                             "redkno"                            
## [255] "caster1"                            "sposan"                            
## [257] "stisan"                             "gresca"                            
## [259] "comter"                             "banswa"                            
## [261] "amekes"                             "greegr"                            
## [263] "woothr"                             "brnthr"                            
## [265] "carwre"                             "savspa"                            
## [267] "rudduc"                             "buwtea"                            
## [269] "norsho"                             "leabit"                            
## [271] "gnwtea"                             "coohaw"                            
## [273] "solsan"                             "doccor"                            
## [275] "amewig"                             "sedwre1"                           
## [277] "herthr"                             "hoomer"                            
## [279] "amewoo"                             "loeowl"                            
## [281] "norfli"                             "dunlin"                            
## [283] "semsan"                             "pinwar"                            
## [285] "rebnut"                             "commer"                            
## [287] "aldfly"                             "whtspa"                            
## [289] "buhvir"                             "attwoo1"                           
## [291] "rufgro"                             "yerwar"                            
## [293] "naswar"                             "lessca"                            
## [295] "merlin"                             "perfal"                            
## [297] "rebmer"                             "y00478"                            
## [299] "sander"                             "phivir"                            
## [301] "bkbplo"                             "retloo"                            
## [303] "rudtur"                             "whrsan"                            
## [305] "semplo"                             "marwre"                            
## [307] "brwhaw"                             "acafly"                            
## [309] "hoowar"                             "winwre3"                           
## [311] "norwat"                             "chwwid"                            
## [313] "btnwar"                             "bawwar"                            
## [315] "tuftit"                             "gadwal"                            
## [317] "orcori"                             "norgos"                            
## [319] "clcspa"                             "henspa"                            
## [321] "buwwar"                             "norhar2"                           
## [323] "norpar"                             "bkbwar"                            
## [325] "canwar"                             "bkbcuc"                            
## [327] "larspa"                             "redhea"                            
## [329] "ambduc"                             "horlar"                            
## [331] "blugrb1"                            "purgal2"                           
## [333] "rengre"                             "norpin"                            
## [335] "leasan"                             "willet1"                           
## [337] "pecsan"                             "greyel"                            
## [339] "bubsan"                             "wesmea"                            
## [341] "magwar"                             "rusbla"                            
## [343] "fragul"                             "normoc"                            
## [345] "evegro"                             "reshaw"                            
## [347] "tenwar"                             "canvas"                            
## [349] "yehbla"                             "bcnher"                            
## [351] "bknsti"                             "buffle"                            
## [353] "lbbgul"                             "palwar"                            
## [355] "gryjay"                             "yebfly"                            
## [357] "linspa"                             "gockin"                            
## [359] "rinduc"                             "rinphe1"                           
## [361] "sheowl"                             "comgal1"                           
## [363] "lobdow"                             "margod"                            
## [365] "categr1"                            "gbbgul"                            
## [367] "brncre"                             "btbwar"                            
## [369] "wilpha"                             "vesspa"                            
## [371] "gowwar"                             "whimbr"                            
## [373] "comgol"                             "bkbwoo"                            
## [375] "shtgro"                             "uplsan"                            
## [377] "yebcuc"                             "wlswar"                            
## [379] "conwar"                             "snoegr"                            
## [381] "renpha"                             "whocra"                            
## [383] "glagul"                             "mutswa"                            
## [385] "calgul"                             "prowar"                            
## [387] "laugul"                             "hudgod"                            
## [389] "swathr"                             "whcspa"                            
## [391] "kirwar"                             "amgplo"                            
## [393] "shshaw"                             "truswa"                            
## [395] "lecspa"                             "louwat"                            
## [397] "cerwar"                             "woewar1"                           
## [399] "prawar"                             "whevir"                            
## [401] "belvir"                             "camwar"                            
## [403] "daejun"                             "logshr"                            
## [405] "easowl1"                            "larbun"                            
## [407] "ruckin"                             "horgre"                            
## [409] "bkpwar"                             "snogoo"                            
## [411] "kenwar"                             "parjae"                            
## [413] "eucdov"                             "sprgro"                            
## [415] "whfibi"                             "kinrai4"                           
## [417] "gloibi"                             "yetwar"                            
## [419] "norbob"                             "tunswa"                            
## [421] "swahaw"                             "snoplo5"                           
## [423] "ycnher"                             "babwar"                            
## [425] "wesgre"                             "ameavo"                            
## [427] "pipplo"                             "whwcro"                            
## [429] "nswowl"                             "sagthr"                            
## [431] "gycthr"                             "eargre"                            
## [433] "sumtan"                             "blksco2"                           
## [435] "neocor"                             "whwdov"                            
## [437] "amepip2"                            "orcwar"                            
## [439] "whwsco2"                            "whiibi"                            
## [441] "triher"                             "clagre"                            
## [443] "comred"                             "sctfly"                            
## [445] "redcro"                             "grpchi"                            
## [447] "lazbun"                             "eugplo"                            
## [449] "weskin"                             "yelrai"                            
## [451] "borchi2"                            "bkchum"                            
## [453] "eurgol"                             "foxspa"                            
## [455] "goleag"                             "sprpip"                            
## [457] "sursco"                             "pacloo"                            
## [459] "arcter"                             "gwfgoo"                            
## [461] "calhum"                             "monpar"                            
## [463] "y00678"                             "lotduc"                            
## [465] "gretit1"                            "pomjae"                            
## [467] "swtkit"                             "bbcdov1"                           
## [469] "redpha1"                            "bohwax"                            
## [471] "lotjae"                             "grypar"                            
## [473] "bkbmag1"                            "bubhum"                            
## [475] "virrai"                             "rolhaw"                            
## [477] "wessan"                             "cavswa"                            
## [479] "trokin"                             "eutspa"                            
## [481] "bargoo"                             "spotow"                            
## [483] "bulori"                             "amtspa"                            
## [485] "snoowl1"                            "pingro"                            
## [487] "hooori"                             "grtgra"                            
## [489] "rufhum"                             "bbwduc"                            
## [491] "libher"                             "moublu"                            
## [493] "bkhgro"                             "rocpar2"                           
## [495] "harduc"                             "limpki"                            
## [497] "arcloo"                             "towwar"                            
## [499] "annhum"                             "rosgoo"                            
## [501] "whtkit"                             "cintea"                            
## [503] "fiscro"                             "savhaw1"                           
## [505] "harspa"                             "sedwre"                            
## [507] "blkrai"                             "grgowl"                            
## [509] "saypho"                             "caskin"                            
## [511] "bkhgul"                             "brbhum"                            
## [513] "acowoo"                             "towsol"                            
## [515] "rosgul"                             "blkvul"                            
## [517] "brnpel"                             "stejay"                            
## [519] "carchi"                             "whwbec1"                           
## [521] "audori"                             "lesgol"                            
## [523] "redwin"                             "miskit"                            
## [525] "norshr4"                            "rosspo1"                           
## [527] "bewwre"

fiddlings to determine # checklists within 10k of a given array

solar_f = solar %>% select("latitude", "longitude", "Customer.ProjectName")
solar_f = solar_f %>% filter(!is.na(latitude))

determine max/min lat for 10 km

# 1 deg = 110.574 km

solar_f$ lat.plus.10k = solar_f$ latitude + ((1/110)*10)
solar_f$ lat.less.10k = solar_f$ latitude - ((1/110)*10)

determine max/min long for 10 km

# 1. convert degrees to radians

## function that converts degree to radians

deg2rad <- function(x) {(x * pi) / (180)}

# create variable of converted values

solar_f$ lat.deg2radians = deg2rad(solar_f$ latitude)
solar_f$ long.deg2radians = deg2rad(solar_f$ longitude)


# 1 deg = 111.320*cos(latitude) km
# 1 degree = 111.320*cos(lat in radians) km

solar_f$ km_per_1deglong = 111.32*cos(solar_f$ lat.deg2radians)


# calculate 1 degree longitude with formula
# 1 degree = 111.320*cos(lat in radians) km

solar_f$ deg.in.10km = (1/(solar_f$ km_per_1deglong))*10

solar_f$ long.plus.10k = solar_f$ longitude + solar_f$ deg.in.10km
solar_f$ long.less.10k = solar_f$ longitude - solar_f$ deg.in.10km

head(solar_f)
##   latitude longitude          Customer.ProjectName lat.plus.10k lat.less.10k
## 1 45.41171 -92.63882               Interstate Park     45.50262     45.32081
## 2 45.36830 -92.55854               Sand Lake Solar     45.45920     45.27739
## 3 45.44526 -92.54959 Sand Lake Solar (Polk County)     45.53617     45.35435
## 4 44.95917 -92.51738                  Warren Solar     45.05008     44.86826
## 5 45.52665 -92.49619           Community Insurance     45.61756     45.43574
## 6 46.70992 -92.08766                   UW Superior     46.80083     46.61901
##   lat.deg2radians long.deg2radians km_per_1deglong deg.in.10km long.plus.10k
## 1       0.7925839        -1.616852        78.14747   0.1279632     -92.51086
## 2       0.7918261        -1.615451        78.20753   0.1278649     -92.43067
## 3       0.7931694        -1.615295        78.10104   0.1280393     -92.42155
## 4       0.7846855        -1.614733        78.77120   0.1269499     -92.39043
## 5       0.7945899        -1.614363        77.98829   0.1282244     -92.36797
## 6       0.8152419        -1.607233        76.33127   0.1310079     -91.95665
##   long.less.10k
## 1     -92.76678
## 2     -92.68640
## 3     -92.67763
## 4     -92.64433
## 5     -92.62441
## 6     -92.21867
# rad2deg <- function(rad) {(rad * 180) / (pi)}
# deg2rad <- function(deg) {(deg * pi) / (180)}

Isolate array and see what checklists are within 10 km

Hill Construction

Hill Construction
2016
lat 46.007367 max 46.09827609 min 45.91645791 long -91.492534 max -91.62186819 min -91.36319981

Hill_constrxn = erd %>% select (latitude, longitude, checklist_id, year)
max(solar_f$lat.less.10k)
## [1] 46.61901
min(solar_f$lat.less.10k)
## [1] 42.44924
max(solar_f$lat.plus.10k)
## [1] 46.80083
min(solar_f$lat.plus.10k)
## [1] 42.63105
max(solar_f$long.plus.10k)
## [1] -87.41756
min(solar_f$long.plus.10k)
## [1] -92.51086
max(solar_f$long.less.10k)
## [1] -87.66846
min(solar_f$long.less.10k)
## [1] -92.76678
# selecting checklists between the max and min lat longs for Hill Construction 

## select lat

Hill_constrxn.code = Hill_constrxn %>% filter (Hill_constrxn$latitude < max(solar_f$lat.plus.10k) & Hill_constrxn$latitude > min(solar_f$lat.less.10k))

#Hill_constrxn.manual = Hill_constrxn %>% filter (Hill_constrxn$latitude < 46.8 & Hill_constrxn$latitude < 42.4)
## select long

Hill_constrxn.code = Hill_constrxn %>% filter (Hill_constrxn$longitude < max(solar_f$long.plus.10k) & Hill_constrxn$longitude > min(solar_f$long.less.10k))

#Hill_constrxn.manual = Hill_constrxn %>% filter (Hill_constrxn$longitude < -87.4 & Hill_constrxn$longitude > -92.8)
#### create table with the total number of checklists per year - created by coding min and max

checklists_per_year.code <- Hill_constrxn.code %>% group_by(year) %>%
  summarise(total.sample.code=length(year))
checklists_per_year.code
## # A tibble: 15 × 2
##     year total.sample.code
##    <dbl>             <int>
##  1  2009              3982
##  2  2010              2830
##  3  2011              1888
##  4  2012              3704
##  5  2013              4979
##  6  2014              4399
##  7  2015              7726
##  8  2016             13424
##  9  2017             15179
## 10  2018             16495
## 11  2019             18193
## 12  2020             13316
## 13  2021             15727
## 14  2022             17137
## 15  2023             20220
#### create table with the total number of checklists per year

#checklists_per_year.manual <- Hill_constrxn.manual %>% group_by(year) %>%
 # summarise(total.sample.manual=length(year))
 #checklists_per_year.manual
ggplot(checklists_per_year.code,aes(x=year,y=total.sample.code))+
  geom_jitter() +
  labs(x="Year",y="Total checklists",title="Number of checklists submitted per year at Hill Construction") +
  geom_vline(xintercept = 2016)

#ggplot(checklists_per_year.manual,aes(x=year,y=total.sample.manual))+
 # geom_jitter() +
  # labs(x="Year",y="Total checklists",title="Number of checklists submitted per year at Hill Construction") +
  # geom_vline(xintercept = 2016)

NOW NEED TO FIND OUT HOW MANY SPECIES DETECTED PER CHECKLIST! NEED TO ACCOUNT FOR GREATER EFFORT (MORE CHECKLISTS) AFTER THE PANELS WENT IN

Hill Construction
2016
lat 46.007367 max 46.09827609 min 45.91645791 long -91.492534 max -91.62186819 min -91.36319981

create table with the total number of observations per year

columns are: year, spp1, spp2…sppn rows are year, # observed …

# calculate observations per species for a given year

## create vector for each year

spp.per.2009 = colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2009'), 7:382])
spp.per.2010 = colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2010'), 7:382])
spp.per.2011 = colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2011'), 7:382])
spp.per.2012 = colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2012'), 7:382])
spp.per.2013 = colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2013'), 7:382])
spp.per.2014 = colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2014'), 7:382])

## create vector with all years

spp.per.year = c(colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2009'), 7:382]), colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2010'), 7:382]), colSums(Hill_constrxn.spp[which(Hill_constrxn.spp$year=='2011'), 7:382]))

## create matrix with vectors
spp.per.year.matrix = matrix(spp.per.year, nrow = 3, byrow = TRUE)
dim(spp.per.year.matrix)

## add a column for year

spp.per.year.matrix <- cbind(spp.per.year.matrix,c(2009, 2010, 2011))
dim(spp.per.year.matrix)

#            dimnames = list(rown, coln))


spp.per.year.matrix[, 375:377]


## Now need to add spp names!!!

Now isolate for Hill construction

Hill_constrxn.spp = erd %>% select(1:6, 152:527)

checklists_per_year.code <- Hill_constrxn.spp %>% group_by(year) %>%
  summarise(total.sample.code=length(year))
checklists_per_year.code
names(Hill_constrxn.spp)
# selecting observations between the max and min lat longs for Hill Construction 

## select lat

Hill_constrxn.spp = Hill_constrxn.spp %>% filter (Hill_constrxn.spp$latitude < max(solar_f$lat.plus.10k) & Hill_constrxn.spp$latitude > min(solar_f$lat.less.10k))

#Hill_constrxn.manual = Hill_constrxn %>% filter (Hill_constrxn$latitude < 46.8 & Hill_constrxn$latitude < 42.4)
## select long

Hill_constrxn.spp = Hill_constrxn.spp %>% filter (Hill_constrxn.spp$longitude < max(solar_f$long.plus.10k) & Hill_constrxn.spp$longitude > min(solar_f$long.less.10k))

#Hill_constrxn.manual = Hill_constrxn %>% filter (Hill_constrxn$longitude < -87.4 & Hill_constrxn$longitude > -92.8)
year.f = factor(erd$year)
levels(year.f)
# calc total observations per spp

spp.sum=colSums(Hill_constrxn.spp[,7:382])
spp.sum


spp.per.year <- Hill_constrxn.spp %>% group_by(year) %>%
  reframe(spp.sum=colSums(Hill_constrxn.spp[,7:382]))
spp.per.year
ggplot(checklists_per_year.code,aes(x=year,y=total.sample.code))+
  geom_jitter() +
  labs(x="Year",y="Total checklists",title="Number of checklists submitted per year at Hill Construction") +
  geom_vline(xintercept = 2016)

`