Manuscript: The spatial and temporal relationship of blue-winged teal (Anas discors) to avian inuenza H5 and H7 hemagglutinin subtypes across North America
Filtering “dead” locations.
Selecting “plausible” records from the DAF_Filter.
Formating date, adding local time (America/Chicago) and getting Hour, Day, Week, season.
Assigning seasons based on date.
Argos_sp = read.csv("C:/Users/humph173/Documents/LabWork/Patuxent/Douglas_080218/BWTeal_2013-2017_Ramey_argos_tabular_diag_gis_filtered.csv",
stringsAsFactors=FALSE,
header = TRUE, sep=",")[,1:35] %>%
filter(Fate == "alive",
DAF_Filter == 0) %>%
mutate(ID = Animal_ID,
ObsDate = as.POSIXct(Location_Datetime_GMT,
tz = "GMT",
format = "%Y/%m/%d %H:%M:%S"),
ObsDateD = as.Date(Location_Datetime_GMT),
LocT = ymd_hms(format(ObsDate, tz="America/Chicago", usetz=TRUE)),
LocHR = hour(LocT),
LocDY = day(LocT),
LocWK = week(LocT),
LocMN = month(LocT))
Argos_sp$Season = ifelse(Argos_sp$LocMN == 12 | Argos_sp$LocMN == 1, "Winter",
ifelse(Argos_sp$LocMN == 3, "Spring",
ifelse(Argos_sp$LocMN >= 4 & Argos_sp$LocMN <= 8, "Breeding",
ifelse(Argos_sp$LocMN >= 9 & Argos_sp$LocMN <= 11, "Fall",
ifelse(Argos_sp$LocMN == 2 & Argos_sp$Day <= 15, "Winter",
ifelse(Argos_sp$LocMN == 2 & Argos_sp$Day >= 16, "Spring",
NA))))))
Jurisdictional boundaries for North America. Loading shapefile and creating raster and point version for later mapping.
NAmer.reg = readOGR(dsn = "./Arc/NAmer/States",
layer = "NA_regions",
stringsAsFactors = FALSE)
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\humph173\Documents\LabWork\Patuxent\Patux_level1\Arc\NAmer\States", layer: "NA_regions"
## with 127 features
## It has 36 fields
## Integer64 fields read as strings: FID_NA_reg FID_Cuba FID_ FID_NA_r_1 FID_0 MEXST0_ MEXST0_ID TOTPOP MALE FEMALE FID_NA_sta FID_Bahama OBJECTID TOTPOP_CY
LL84 = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
NAmer = gUnaryUnion(NAmer.reg)
#Great Lakes Boundaries
Lakes = readOGR(dsn = "./Arc/Lakes",
layer = "Lakes",
stringsAsFactors = FALSE)
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\humph173\Documents\LabWork\Patuxent\Patux_level1\Arc\Lakes", layer: "Lakes"
## with 1 features
## It has 11 fields
## Integer64 fields read as strings: OBJECTID gid water sqmi sqkm
Lakes = spTransform(Lakes, proj4string(NAmer.reg))
tmp.ras = raster(res=0.2) #raster verion
extent(tmp.ras) = extent(NAmer)
Domain.r = rasterize(NAmer,
tmp.ras,
field = 0,
background = NA)
Grd.pnt = rasterToPoints(Domain.r, sp = TRUE)
Grd.pnt@data = Grd.pnt@data %>%
mutate(Long = Grd.pnt@coords[,1],
Lat = Grd.pnt@coords[,2]) %>%
select(-layer)
GLakes = readOGR(dsn = "./Arc/RedRast/GLake",
layer = "GLakes",
stringsAsFactors = FALSE)
## OGR data source with driver: ESRI Shapefile
## Source: "C:\Users\humph173\Documents\LabWork\Patuxent\Patux_level1\Arc\RedRast\GLake", layer: "GLakes"
## with 5 features
## It has 6 fields
## Integer64 fields read as strings: OBJECTID_1 ObjectID
Convert to Points
Converting telemetry locations to spatial points.
Locs = cbind(Argos_sp$Longitude, Argos_sp$Latitude)
Sp.pnts = SpatialPointsDataFrame(Locs, Argos_sp)
proj4string(Sp.pnts) = proj4string(NAmer.reg)
RECORDS RETAINED FOR ANALYSIS:
PTT transmitter identifier (Tag)
Date of deployment (Deployment)
Last transmission date (Last)
Bird mortality type (Mortality)
Duration of record (Duration, days)
Median sampling interval between locations (Median, minutes)
Total locations (Sample)
Coordinates (Latitude, Longitude)
Geographic region of deployment (Region)
Deploy = read.csv("C:/Users/humph173/Documents/LabWork/Patuxent/Patux_level1/StopOver_out/Paper/Tags2.csv",
stringsAsFactors=FALSE,
header = TRUE, sep=",")[,1:10]
Deploy.pnts = SpatialPointsDataFrame(cbind(Deploy$deploy_on_longitude, Deploy$deploy_on_latitude), Deploy)
proj4string(Deploy.pnts) = proj4string(NAmer.reg)
plot(NAmer.reg)
plot(Deploy.pnts, add=T, col="red")
Deploy$Region = over(Deploy.pnts, NAmer.reg)[,"NAME"]
Deploy = Deploy %>% select(-Animal_ID)
names(Deploy) = c("Tag", "Deployment", "Last", "Mortality", "Duration", "Median", "Sample", "Latitude", "Longitude", "Region")
kable(Deploy,
caption = "Tag Deployment Table ") %>%
kable_styling("striped", full_width = F) %>%
row_spec(0, font_size = 20) %>%
column_spec(1, bold = T)
Tag | Deployment | Last | Mortality | Duration | Median | Sample | Latitude | Longitude | Region |
---|---|---|---|---|---|---|---|---|---|
131009 | 8/13/2013 | 10/26/2013 | Hunting | 74 | 29 | 558 | 52.04454 | -107.0976 | Saskatchewan |
131010 | 8/13/2013 | 3/26/2014 | Unknown | 225 | 40 | 1142 | 52.04454 | -107.0976 | Saskatchewan |
131011 | 8/14/2013 | 4/27/2015 | Unknown | 620 | 48 | 2730 | 50.48194 | -112.1186 | Alberta |
131012 | 8/14/2013 | 11/5/2013 | Unknown | 83 | 41 | 464 | 50.48194 | -112.1186 | Alberta |
131013 | 8/14/2013 | 10/24/2013 | Hunting | 71 | 37 | 453 | 52.04454 | -107.0976 | Saskatchewan |
131014 | 8/11/2013 | 10/24/2013 | Unknown | 73 | 31 | 523 | 52.04454 | -107.0976 | Saskatchewan |
131015 | 8/12/2013 | 4/8/2014 | Unknown | 239 | 43 | 1149 | 52.04454 | -107.0976 | Saskatchewan |
131016 | 8/12/2013 | 1/25/2014 | Unknown | 165 | 42 | 803 | 52.04454 | -107.0976 | Saskatchewan |
131017 | 8/12/2013 | 10/21/2013 | Unknown | 70 | 32 | 516 | 52.04454 | -107.0976 | Saskatchewan |
131018 | 8/12/2013 | 10/17/2013 | Unknown | 66 | 32 | 468 | 52.04454 | -107.0976 | Saskatchewan |
131019 | 8/15/2013 | 11/29/2013 | Unknown | 106 | 42 | 593 | 50.48194 | -112.1186 | Alberta |
131020 | 8/15/2013 | 10/17/2013 | Unknown | 63 | 39 | 408 | 50.48194 | -112.1186 | Alberta |
131009 | 3/17/2015 | 10/25/2015 | Unknown | 222 | 46 | 1087 | 30.00790 | -94.1425 | Texas |
131013 | 3/19/2015 | 9/26/2015 | Unknown | 191 | 47 | 898 | 29.61340 | -94.5342 | Texas |
135841 | 3/17/2015 | 12/9/2015 | Hunting | 267 | 49 | 1165 | 30.00790 | -94.1425 | Texas |
135842 | 3/17/2015 | 11/12/2015 | Unknown | 240 | 57 | 816 | 30.00790 | -94.1425 | Texas |
135843 | 3/17/2015 | 10/31/2015 | Unknown | 228 | 47 | 1055 | 30.00790 | -94.1425 | Texas |
135844 | 3/17/2015 | 5/28/2015 | Unknown | 72 | 49 | 335 | 30.00790 | -94.1425 | Texas |
135845 | 3/18/2015 | 4/28/2015 | Unknown | 41 | 52 | 181 | 29.67090 | -94.4405 | Texas |
135846 | 3/18/2015 | 10/2/2015 | Hunting | 198 | 43 | 1061 | 29.67090 | -94.4405 | Texas |
135847 | 3/18/2015 | 8/17/2015 | Unknown | 152 | 56 | 565 | 29.67090 | -94.4405 | Texas |
135848 | 3/18/2015 | 10/27/2015 | Unknown | 223 | 46 | 1051 | 29.67090 | -94.4405 | Texas |
135849 | 3/18/2015 | 9/27/2016 | Unknown | 559 | 53 | 2129 | 29.67090 | -94.4405 | Texas |
135850 | 3/19/2015 | 3/31/2015 | Unknown | 12 | 53 | 57 | 29.61340 | -94.5342 | Texas |
135851 | 3/19/2015 | 5/11/2015 | Unknown | 53 | 54 | 205 | 29.61340 | -94.5342 | Texas |
135852 | 3/19/2015 | 9/30/2016 | Unknown | 561 | 56 | 1918 | 29.61340 | -94.5342 | Texas |
135853 | 3/19/2015 | 5/5/2015 | Unknown | 47 | 53 | 211 | 29.61340 | -94.5342 | Texas |
135854 | 3/19/2015 | 10/18/2015 | Unknown | 213 | 48 | 938 | 29.61340 | -94.5342 | Texas |
135855 | 3/22/2015 | 10/21/2015 | Unknown | 213 | 48 | 955 | 30.55380 | -91.8466 | Louisiana |
135856 | 3/22/2015 | 7/12/2015 | Unknown | 112 | 48 | 532 | 30.55380 | -91.8466 | Louisiana |
135857 | 3/22/2015 | 7/22/2015 | Unknown | 122 | 51 | 519 | 30.55380 | -91.8466 | Louisiana |
135858 | 3/22/2015 | 5/8/2015 | Unknown | 47 | 47 | 226 | 30.55380 | -91.8466 | Louisiana |
135859 | 3/22/2015 | 7/17/2015 | Unknown | 117 | 46 | 569 | 30.55380 | -91.8466 | Louisiana |
135860 | 3/22/2015 | 12/23/2016 | Unknown | 642 | 50 | 2647 | 30.55380 | -91.8466 | Louisiana |
135861 | 3/22/2015 | 4/13/2016 | Unknown | 388 | 50 | 1338 | 30.55380 | -91.8466 | Louisiana |
135862 | 3/22/2015 | 8/14/2015 | Unknown | 145 | 55 | 528 | 30.55380 | -91.8466 | Louisiana |
135863 | 3/22/2015 | 4/17/2015 | Unknown | 26 | 50 | 125 | 30.55380 | -91.8466 | Louisiana |
135864 | 3/21/2015 | 10/28/2015 | Hunting | 221 | 48 | 1019 | 30.46420 | -91.5718 | Louisiana |
135865 | 3/21/2015 | 4/7/2015 | Unknown | 17 | 51 | 89 | 30.46420 | -91.5718 | Louisiana |
135866 | 3/21/2015 | 5/31/2015 | Unknown | 71 | 53 | 290 | 30.46420 | -91.5718 | Louisiana |
135867 | 3/21/2015 | 11/23/2015 | Unknown | 247 | 47 | 1141 | 30.46420 | -91.5718 | Louisiana |
135868 | 3/21/2015 | 4/7/2015 | Unknown | 17 | 49 | 84 | 30.46420 | -91.5718 | Louisiana |
#SelMod.fx = xtable(Deploy) #table for manuscript
#print(SelMod.fx, include.rownames = F)
Estimated residence time serves as inital input values for later space-time modeling.
After estimating residence time for the full dataset, stopover locations are identified for the spring and fall migrations.
Estimating duration of time (hours) spent in each grid cell. Individual birds are returned as layers in a raster stack. Birds are then combined to get the maximum duration any one bird spent in each cell. Time spent in grid cells lacking satellite fixes are interpolated assuming uniform movement between successful satellite captures.
Animal.IDs = levels(as.factor(Sp.pnts$Animal_ID))
for(i in 1:length(Animal.IDs)){
Ani.tmp = subset(Sp.pnts, Animal_ID == Animal.IDs[i])
tmp.res = ResidenceRaster(Ani.tmp, Domain.r)
if(i == 1){Res.stk = tmp.res}
else{Res.stk = stack(Res.stk, tmp.res)}
}
names(Res.stk) = Animal.IDs
All.brds.res.stk = Res.stk
ZZ = max(All.brds.res.stk)
View residence time tesults (full dataset)
rng = seq(0, 81, 1)
mCols = brewer.pal(9, "YlOrRd")[-c(1:2)]
cr0 = colorRampPalette(mCols)(n = 2000)
cr = colorRampPalette(c(cr0),
bias = 4)
#Removing background zeros for plotting
ZZ2 = ZZ
ZZ2[ZZ2 == 0] = NA
Plt.a = levelplot(ZZ2,
margin = FALSE,
xlab =NULL,
ylab = NULL,
main = "Residence Time (days)",
maxpixels = 1e5,
col.regions = cr, at =rng,
colorkey = list(labels=list(at=c(0, 20, 40, 60, 80, 103),
labels=c("0", "20", "40", "60", "80", "100 Days"), cex=1),
labels=list(cex=12),
space = "bottom"),
par.strip.text = list(fontface='bold', cex=1),
par.settings = list(axis.line = list(col = "black"),
strip.background = list(col = 'transparent'),
strip.border = list(col = 'transparent')),
scales = list(cex = 1)) +
latticeExtra::layer(sp.polygons(NAmer.reg, col = "darkgray", lwd = 0.5))
Plt.a
Residence times during migration periods greater than 1 Day are assumed stopovers.
Spring migration.
Animal.IDs = levels(as.factor(Sp.pnts$Animal_ID))
for(i in 1:length(Animal.IDs)){
Ani.tmp = subset(Sp.pnts, Animal_ID == Animal.IDs[i])
Ani.tmp = subset(Ani.tmp, LocMN >= 2 & LocMN < 6)
if(dim(Ani.tmp@data)[1] < 2){tmp.res = Domain.r}
else{
tmp.res = ResidenceRaster(Ani.tmp, Domain.r)}
if(i == 1){Res.stkS = tmp.res}
else{Res.stkS = stack(Res.stkS, tmp.res)}
}
Spring.res = Res.stkS
names(Spring.res) = Animal.IDs
nStrata = dim(Spring.res)[3]
for(i in 1:nStrata){
f.rast = Spring.res[[i]]
f.rast[f.rast < 1] = NA
if(sum(values(f.rast), na.rm=T) == 0){
tmp.strat = as.data.frame(cbind(0,0,0))
names(tmp.strat) = c("Long", "Lat", "Duration")
tmp.strat$Bird = Animal.IDs[i]
}
else{
tmp.strat = as.data.frame(rasterToPoints(f.rast, sp=F))
names(tmp.strat) = c("Long", "Lat", "Duration")
tmp.strat$Bird = Animal.IDs[i] }
if(i == 1){stpovr.pnts = tmp.strat}
else{stpovr.pnts = rbind(stpovr.pnts, tmp.strat)}
}
Spr.StpOvr.pnts = stpovr.pnts %>% filter(Lat >= 31 & Lat <=45)
Spr.StpOvr.pnts$Season = "Spring"
Spr.StpOvr.pnts = subset(Spr.StpOvr.pnts, Lat != 0)
Fall migration.
Animal.IDs = levels(as.factor(Sp.pnts$Animal_ID))
for(i in 1:length(Animal.IDs)){
Ani.tmp = subset(Sp.pnts, Animal_ID == Animal.IDs[i])
Ani.tmp = subset(Ani.tmp, LocMN >= 9 & LocMN < 12)
if(dim(Ani.tmp@data)[1] < 2){tmp.res = Domain.r}
else{
tmp.res = ResidenceRaster(Ani.tmp, Domain.r)}
if(i == 1){Res.stkF = tmp.res}
else{Res.stkF = stack(Res.stkF, tmp.res)}
}
Fall.res = Res.stkF
names(Fall.res) = Animal.IDs
nStrata = dim(Fall.res)[3]
for(i in 1:nStrata){
f.rast = Fall.res[[i]]
f.rast[f.rast < 1] = NA
if(sum(values(f.rast), na.rm=T) == 0){
tmp.strat = as.data.frame(cbind(0,0,0))
names(tmp.strat) = c("Long", "Lat", "Duration")
tmp.strat$Bird = Animal.IDs[i]
}
else{
tmp.strat = as.data.frame(rasterToPoints(f.rast, sp=F))
names(tmp.strat) = c("Long", "Lat", "Duration")
tmp.strat$Bird = Animal.IDs[i] }
if(i == 1){stpovr.pnts = tmp.strat}
else{stpovr.pnts = rbind(stpovr.pnts, tmp.strat)}
}
Fall.StpOvr.pnts = stpovr.pnts %>% filter(Lat >= 31 & Lat <=45)
Fall.StpOvr.pnts$Season = "Fall"
Fall.StpOvr.pnts = subset(Fall.StpOvr.pnts, Lat != 0)
#Combine
SprFall.stpover.pnt = rbind(Spr.StpOvr.pnts, Fall.StpOvr.pnts)
SprFall.stpover.pnts = SpatialPointsDataFrame(SprFall.stpover.pnt[,c("Long","Lat")], SprFall.stpover.pnt)
proj4string(SprFall.stpover.pnts) = proj4string(NAmer)
View StopOver Locations
Residence times during migration periods greater than 1 Day are assumed stopovers.
wmap_df = fortify(NAmer.reg)
## Regions defined for each Polygons
tmp.df = SprFall.stpover.pnt
tmp.df$Duration = ifelse(tmp.df$Duration >= 3, 3, tmp.df$Duration)
#tmp.df$Size[tmp.df$Size==0] = 0.1
myCol = c("black", "red", "green3", "blue", "cyan", "magenta", "orange", "brown")
names(myCol) = levels(factor(tmp.df$AI))
myShapes = c(3:4)
names(myShapes) = levels(factor(tmp.df$Season))
colScale = scale_colour_manual(name = "Strain", values = myCol,
labels = c("Fall", "Spring"))
ShpScale = scale_shape_manual(name = "Season", values = myShapes,
labels = c("Fall", "Spring"))
ggplot(wmap_df, aes(long,lat, group=group)) +
geom_polygon(fill = "lightgray", col="darkgray") +
geom_point(data=tmp.df,
aes(Long, Lat,
group=Season, fill=NULL,
shape = Season,
color = Duration)) +
scale_colour_gradient(low = "blue", high = "red") +
ShpScale +
#colScale +
xlab("Longitude") +
ylab("Latitude") +
ggtitle("Stopover 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))
Stopovers By Bird
Bird.StpOvr = as.data.frame(
SprFall.stpover.pnt %>%
group_by(Bird, Season) %>%
summarize(Stopovers = length(Duration),
MinDuration = min(Duration),
MeanDuration = mean(Duration),
MaxDuration = max(Duration)))
Sp.set = Bird.StpOvr %>% filter(Season == "Spring")
Fl.set = Bird.StpOvr %>% filter(Season == "Fall")
kable(Sp.set,
caption = "Spring Stopovers by Bird") %>%
kable_styling("striped", full_width = F) %>%
row_spec(0, font_size = 20) %>%
column_spec(1, bold = T)
Bird | Season | Stopovers | MinDuration | MeanDuration | MaxDuration |
---|---|---|---|---|---|
BWTE13S_131011 | Spring | 11 | 1.023812 | 3.400350 | 8.718994 |
BWTE15S_131009 | Spring | 10 | 1.280445 | 2.290844 | 4.010739 |
BWTE15S_131013 | Spring | 9 | 1.270052 | 2.724942 | 4.263789 |
BWTE15S_135841 | Spring | 6 | 1.184467 | 1.671687 | 2.018994 |
BWTE15S_135842 | Spring | 4 | 1.956225 | 4.186395 | 6.142620 |
BWTE15S_135843 | Spring | 8 | 1.477020 | 3.076974 | 5.651407 |
BWTE15S_135844 | Spring | 4 | 1.423539 | 2.121222 | 2.802661 |
BWTE15S_135845 | Spring | 2 | 1.019103 | 1.019103 | 1.019103 |
BWTE15S_135846 | Spring | 7 | 1.245661 | 2.370123 | 4.288308 |
BWTE15S_135847 | Spring | 4 | 1.506573 | 3.040828 | 4.547401 |
BWTE15S_135848 | Spring | 8 | 1.001907 | 2.478607 | 5.257314 |
BWTE15S_135849 | Spring | 10 | 1.028808 | 2.621629 | 6.558354 |
BWTE15S_135851 | Spring | 3 | 1.365678 | 1.940705 | 2.338149 |
BWTE15S_135852 | Spring | 4 | 2.735596 | 5.490099 | 8.225694 |
BWTE15S_135855 | Spring | 11 | 1.040069 | 2.396922 | 5.434808 |
BWTE15S_135857 | Spring | 8 | 1.203439 | 2.261800 | 4.232223 |
BWTE15S_135858 | Spring | 4 | 1.302675 | 2.790639 | 4.093314 |
BWTE15S_135859 | Spring | 6 | 1.275443 | 2.118704 | 3.410049 |
BWTE15S_135860 | Spring | 10 | 1.270823 | 2.259087 | 3.862162 |
BWTE15S_135861 | Spring | 1 | 1.007670 | 1.007670 | 1.007670 |
BWTE15S_135864 | Spring | 6 | 1.034225 | 2.707784 | 5.314719 |
BWTE15S_135866 | Spring | 12 | 1.007364 | 2.114763 | 3.041905 |
BWTE15S_135867 | Spring | 14 | 1.184502 | 2.159875 | 3.574317 |
BWTE15S_135868 | Spring | 2 | 1.691965 | 1.696519 | 1.701073 |
kable(Fl.set,
caption = "Fall Stopovers by Bird") %>%
kable_styling("striped", full_width = F) %>%
row_spec(0, font_size = 20) %>%
column_spec(1, bold = T)
Bird | Season | Stopovers | MinDuration | MeanDuration | MaxDuration |
---|---|---|---|---|---|
BWTE13S_131010 | Fall | 2 | 2.794068 | 2.794696 | 2.795323 |
BWTE13S_131011 | Fall | 6 | 1.387099 | 5.625048 | 11.329162 |
BWTE13S_131012 | Fall | 8 | 1.243968 | 3.565047 | 6.579313 |
BWTE13S_131015 | Fall | 6 | 1.174337 | 2.161307 | 3.662968 |
BWTE13S_131016 | Fall | 8 | 1.197418 | 2.641036 | 4.769214 |
BWTE13S_131019 | Fall | 9 | 1.208699 | 2.970959 | 5.723570 |
BWTE13S_131020 | Fall | 9 | 1.022517 | 1.848832 | 3.710053 |
BWTE15S_135841 | Fall | 6 | 2.309841 | 4.934694 | 9.361109 |
BWTE15S_135842 | Fall | 9 | 1.066189 | 7.380978 | 21.224169 |
BWTE15S_135843 | Fall | 4 | 1.168868 | 2.396239 | 3.565108 |
BWTE15S_135846 | Fall | 2 | 1.110884 | 1.110884 | 1.110884 |
BWTE15S_135849 | Fall | 13 | 1.032501 | 2.046960 | 3.207565 |
BWTE15S_135852 | Fall | 112 | 1.205674 | 1.430623 | 8.021270 |
BWTE15S_135860 | Fall | 8 | 1.097183 | 2.509382 | 5.366707 |
BWTE15S_135861 | Fall | 4 | 3.028012 | 6.084214 | 9.112226 |
BWTE15S_135867 | Fall | 12 | 1.228074 | 2.482733 | 4.547319 |
Measuring distance between stopover locations identified from residence time analysis and commercial domestic poultry operations of various capacities (livestock abundances).
nProj = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0
+x_0=0 +y_0=0 +k=1 +units=km +nadgrids=@null +no_defs" #Mercator projection (km)
NAMer_chk = raster("C:/Users/humph173/Documents/LabWork/Patuxent/GlobPoultry/NAmerExt/NAmer_chick.tif") #Livestock of the world.
NAMer_chk1000 = NAMer_chk
NAMer_chk1000[NAMer_chk1000 < 1000] = NA
Chk1000 = rasterToPoints(NAMer_chk1000, sp=T)
XX = pointDistance(SprFall.stpover.pnts, Chk1000)
NAMer_chk10k = NAMer_chk
NAMer_chk10k[NAMer_chk10k < 10000] = NA
Chk10k = rasterToPoints(NAMer_chk10k, sp=T)
NAMer_chk100k = NAMer_chk
NAMer_chk100k[NAMer_chk100k < 100000] = NA
Chk100k = rasterToPoints(NAMer_chk100k, sp=T)
NAMer_chk250k = NAMer_chk
NAMer_chk250k[NAMer_chk250k < 250000] = NA
Chk250k = rasterToPoints(NAMer_chk250k, sp=T)
NAMer_chk500k = NAMer_chk
NAMer_chk500k[NAMer_chk500k < 500000] = NA
Chk500k = rasterToPoints(NAMer_chk500k, sp=T)
NAMer_chk1m = NAMer_chk
NAMer_chk1m[NAMer_chk1m < 1000000] = NA
Chk1m = rasterToPoints(NAMer_chk1m, sp=T)
#Nearest A
SO.pnt = spTransform(SprFall.stpover.pnts, nProj)
so.pp = as.ppp(SO.pnt)
Chk1000p = as.ppp(spTransform(Chk1000, nProj))
NNS = as.data.frame(nncross(so.pp, Chk1000p, k=1))
SprFall.stpover.pnts$nChk1000 = NNS[,1]
Chk10kp = as.ppp(spTransform(Chk10k, nProj))
NNS = as.data.frame(nncross(so.pp, Chk10kp, k=1))
SprFall.stpover.pnts$nChk10k = NNS[,1]
Chk100kp = as.ppp(spTransform(Chk100k, nProj))
NNS = as.data.frame(nncross(so.pp, Chk100kp, k=1))
SprFall.stpover.pnts$nChk100k = NNS[,1]
Chk250kp = as.ppp(spTransform(Chk250k, nProj))
NNS = as.data.frame(nncross(so.pp, Chk250kp, k=1))
SprFall.stpover.pnts$nChk250k = NNS[,1]
Chk500kp = as.ppp(spTransform(Chk500k, nProj))
NNS = as.data.frame(nncross(so.pp, Chk500kp, k=1))
SprFall.stpover.pnts$nChk500k = NNS[,1]
Chk1mp = as.ppp(spTransform(Chk1m, nProj))
NNS = as.data.frame(nncross(so.pp, Chk1mp, k=1))
SprFall.stpover.pnts$nChk1m = NNS[,1]
View Proximity to Commercial Poultry
wmap_df = fortify(NAmer.reg)
## Regions defined for each Polygons
tmp.df = SprFall.stpover.pnts@data %>% select(-c(Duration, Bird))
myShapes = c(3:4)
names(myShapes) = levels(factor(tmp.df$Season))
ShpScale = scale_shape_manual(name = "Season", values = myShapes,
labels = c("Fall", "Spring"))
tmp.dfm = melt(tmp.df, c("Long", "Lat", "Season"))
tmp.dfm$Kilometers = as.numeric(tmp.dfm$value)
tmp.dfm$variable = ordered(tmp.dfm$variable, levels = c("nChk1000", "nChk10k", "nChk100k", "nChk250k", "nChk500k", "nChk1m"))
ggplot(wmap_df, aes(long,lat, group=group)) +
geom_polygon(fill = "lightgray", col="darkgray") +
geom_point(data=tmp.dfm,
aes(Long, Lat,
group=Season, fill=NULL,
shape = Season,
color = Kilometers)) +
scale_colour_gradient(low = "blue", high = "red",
breaks=seq(0, 3000, 500)) +
ShpScale +
facet_wrap(~variable, ncol=3) +
xlab(" ") +
ylab(" ") +
ggtitle("Stopover Proximity to Poultry") +
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))
A 3D Cartesian projection is used that is scaled to one Earth radius (6371km). The mesh is used to estimate model spatial fields.
NA.bf = gBuffer(NAmer,
width = 1,
byid = FALSE)
NA.bnds = inla.sp2segment(NA.bf)
MaxEdge = 0.5
mesh0 = inla.mesh.2d(boundary = NA.bnds,
cutoff = 1,
max.edge = MaxEdge,
min.angle = 21)
MeshLocs = cbind(mesh0$loc[,1], mesh0$loc[,2])
xyz = as.data.frame(
inla.mesh.map(MeshLocs,
projection = "longlat",
inverse = TRUE))
true.radius.of.earth = 6371 #km
radius.of.earth = 1
mesh.dom = inla.mesh.create(loc = xyz,
cutoff = 35/true.radius.of.earth,
refine=list(max.edge = 1000/true.radius.of.earth,
min.angle = 26))
Click, drag, and zoom to view mesh
mesh.dom$n
## [1] 9555
plot(mesh.dom, rgl = TRUE, main = " ")