plot2 <- rayshader::plot_gg(plot1, multicore = TRUEraytrace = TRUE, width = 7, height = 4,
scale = 300, windowsize = c(1400, 866), zoom = 0.6, phi = 30, theta = 30)
#3d version using rayshader package
plot2 <- rayshader::plot_gg(plot1, multicore = TRUEraytrace = TRUE, width = 7, height = 4,
windowsize = c(1400, 866), zoom = 0.6, phi = 30, theta = 30)
#3d version using rayshader package
plot2 <- rayshader::plot_gg(plot1, multicore = TRUE)
install.packages("viridis")
library(viridis)
?scale_fill_viridis
plot1 <- ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
# scale_fill_jcolors_contin("pal12")+
scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
# scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
coord_cartesian(xlim = xlim,ylim = ylim)+
# north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
# ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
#                height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
#                dist_unit = "km", transform = F)+
theme(legend.position="none",legend.justification = "center")
plot1 <- ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
# scale_fill_jcolors_contin("pal12")+
scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
# scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
coord_cartesian(xlim = xlim,ylim = ylim)+
north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F)+
theme(legend.position="right",legend.justification = "center")+
theme(panel.grid=element_blank(),
axis.text=element_text(size=8),
axis.title=element_text(size=9,face="bold"),
legend.text=element_text(face="bold",size=8),
legend.title=element_text(face="bold",size=8))
plot1
plot1 <- ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
# scale_fill_jcolors_contin("pal12")+
scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
# scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
coord_cartesian(xlim = xlim,ylim = ylim)+
north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F)+
theme(legend.position="right",legend.justification = "center")+
theme(panel.grid=element_blank(),
axis.text=element_text(size=8),
axis.title=element_text(size=9,face="bold"),
legend.text=element_text(face="bold",size=8),
legend.title=element_text(face="bold",size=8))
plot1
#DEM
dem <- rasterToPoints(dem.ras); dem <- data.frame(dem)
colnames(dem) <- c("long","lat","DEM")
b.dem <- seq(min(dem$DEM),max(dem$DEM),length.out=5)
#for scale bar
e.sbar <- extent(fdinflow.ras)
plot1 <- ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
# scale_fill_jcolors_contin("pal12")+
# scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
# scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
coord_cartesian(xlim = xlim,ylim = ylim)+
north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F)+
theme(legend.position="right",legend.justification = "center")+
theme(panel.grid=element_blank(),
axis.text=element_text(size=8),
axis.title=element_text(size=9,face="bold"),
legend.text=element_text(face="bold",size=8),
legend.title=element_text(face="bold",size=8))
plot1
ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
scale_fill_jcolors_contin("pal12")+
# scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
# scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
coord_cartesian(xlim = xlim,ylim = ylim)+
north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F)+
theme(legend.position="right",legend.justification = "center")+
theme(panel.grid=element_blank(),
axis.text=element_text(size=8),
axis.title=element_text(size=9,face="bold"),
legend.text=element_text(face="bold",size=8),
legend.title=element_text(face="bold",size=8))
plot1 <- ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
scale_fill_jcolors_contin("pal12")+
# scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
# scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
# coord_cartesian(xlim = xlim,ylim = ylim)+
north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F)+
theme(legend.position="right",legend.justification = "center")+
theme(panel.grid=element_blank(),
axis.text=element_text(size=8),
axis.title=element_text(size=9,face="bold"),
legend.text=element_text(face="bold",size=8),
legend.title=element_text(face="bold",size=8))
plot1 <- ggplot()+
geom_raster(data=dem,mapping=aes(long,lat,fill=DEM))+
#geom_polygon(data=prop.border,mapping=aes(long,lat,group = group),fill=NA, colour="black")+
#geom_polygon(data=river.border,mapping=aes(long,lat,group = group),fill="black", colour="black")+
# geom_point(data=points,mapping=aes(long,lat))+
# geom_text(data=points,aes(x=long, y=lat, label=lab, hjust=hjust, vjust=vjust),
#           size=3, nudge_x=20,fontface="bold")+
# scale_fill_gradientn(colours = terrain.colors(10))+
# scale_fill_gradientn(colours = rainbow(5), limits = c(35,105))+
scale_fill_jcolors_contin("pal12")+
# scale_fill_viridis(option = "D") +
# scale_fill_grey()+
# scale_fill_gradient2(low = "darkgreen", mid = "orange", high = "darkred",midpoint = 70)+
# scale_x_continuous(expand = c(0, 0), breaks=c(312000,312100, 312200)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
labs(x=NULL, y=NULL,fill='Elevation (m)')+
# coord_cartesian(xlim = xlim,ylim = ylim)+
north(data=dem, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10)) +
ggsn::scalebar(data=dem, dist =0.25,location = "bottomleft", st.size=2.3,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F)+
theme(legend.position="left",legend.justification = "bottom")+
theme(panel.grid=element_blank(),
axis.text=element_text(size=8),
axis.title=element_text(size=9,face="bold"),
legend.text=element_text(face="bold",size=8),
legend.title=element_text(face="bold",size=8))
plot1
png("./plots/02012019/1.2.png",res=300, width = 150, height = 90, units="mm")
plot1
dev.off()
#3d version using rayshader package
plot2 <- rayshader::plot_gg(plot1, multicore = TRUE)
if ( !require(zoo) )    { install.packages("zoo");    library(zoo) }
if ( !require(ggplot2) )    { install.packages("ggplot2");    library(ggplot2) }
if ( !require(hydroGOF) )    { install.packages("hydroGOF");    library(hydroGOF) }
if ( !require(raster) )    { install.packages("raster");    library(raster) }
if ( !require(rgdal) )    { install.packages("rgdal");    library(rgdal) }
if ( !require(ggsn) )    { install.packages("ggsn");    library(ggsn) }
if ( !require(rgeos) )    { install.packages("rgeos");    library(rgeos) }
#file names
prop.shp.name <- "Cliped_Properties"
riv.shp.name <- "River_outline"
fd.shp.name <- "Surveyed_wrack_Monica"
fe.shp.name <- "FloodExtent"
dem.ras.name <- "CbDEM_1m_EA.tif"
#dem.ras.name <- "DTM_EA_1m.tif"
fdinflow.ras.name <- "Depth (Max).CbDEM_1m_EA_inflow.tif"
fdcomb.ras.name <- "Depth (Max).CbDEM_1m_EA_comp.tif"
# Read raster files
dem.ras <- raster(dem.ras.name)
fdinflow.ras <- raster(fdinflow.ras.name)
fdinflow.ras[is.na(fdinflow.ras[])] <- 0
#fdinflow.ras[which(getValues(fdinflow.ras)<0.1)] <- 0 #if a threshold is needed
fdcomb.ras <- raster(fdcomb.ras.name)
fdcomb.ras[is.na(fdcomb.ras[])] <- 0
#fdcomb.ras[which(getValues(fdcomb.ras)<5)] <- 0 #if a threshold is needed
#Read shape files
measFD <- readOGR(dsn="./Surveyed_wrack_Cockermouth",
layer=fd.shp.name,pointDropZ=T)
measFE <- readOGR(dsn="./FloodExtent",
layer=fe.shp.name)
AffProp <- readOGR(dsn="./AffectedProperties",
layer="AffectedProperties")
points <- read.csv("SelectedPoints.csv")
prop.shp <- readOGR(dsn="./ClippedProperties", layer=prop.shp.name)
prop.border <- gUnaryUnion(prop.shp)
plot(prop.shp)
prop.shp <- prop.shp[,c("Theme")]
prop.shp$id <- 0:(nrow(prop.shp)-1)
prop.shp$area <- area(prop.shp)
prop.f <- fortify(prop.shp,region="id")
# Read river boundary
river.shp <- readOGR(dsn="./RiverOutline", layer=riv.shp.name)
river.border <- gUnaryUnion(river.shp)
plot(river.shp)
river.shp <- river.shp[,c("Theme")]
river.shp$id <- 0:(nrow(river.shp)-1)
river.shp$area <- area(river.shp)
river.f <- fortify(river.shp,region="id")
rinflow.vals <- extract(fdinflow.ras, prop.shp)
# Use apply to calculate mean for each polygon
rinflow.mean <- sapply(rinflow.vals,function (x) mean(x, na.rm=T))
rinflow.mean <- as.data.frame(cbind(prop.shp$id,rinflow.mean))
colnames(rinflow.mean) = c("id","MeanFD")
rinflow.mean <- merge(rinflow.mean,prop.shp,by="id")
inflow.gg <- merge(prop.f,rinflow.mean,by="id")
#comb flood
# Extract raster values to list object
rcomb.vals <- extract(fdcomb.ras, prop.shp)
# Use apply to calculate mean for each polygon
rcomb.mean <- sapply(rcomb.vals,function (x) mean(x, na.rm=T))
rcomb.mean <- as.data.frame(cbind(prop.shp$id,rcomb.mean))
colnames(rcomb.mean) = c("id","MeanFD")
rcomb.mean <- merge(rcomb.mean,prop.shp,by="id")
comb.gg <- merge(prop.f,rcomb.mean,by="id")
#combine data for facet_wrap
inflow.gg$type <- " Fluvial"
comb.gg$type <- "Combined"
#changing themes
levels(inflow.gg$Theme)[match("Land,Structures",levels(inflow.gg$Theme))] <- "Others"
levels(inflow.gg$Theme)[match("Roads Tracks And Paths,Structures",levels(inflow.gg$Theme))] <- "Others"
levels(inflow.gg$Theme)[match("Structures",levels(inflow.gg$Theme))] <- "Others"
levels(inflow.gg$Theme)[match("Roads Tracks And Paths",levels(inflow.gg$Theme))] <- "Roads"
levels(inflow.gg$Theme)[match("Water",levels(inflow.gg$Theme))] <- "River"
levels(inflow.gg$Theme)[match("Land",levels(inflow.gg$Theme))] <- "Bareland"
inflow.gg$Theme <- factor(inflow.gg$Theme, levels=c("Buildings","Roads","Bareland","River","Others"))
levels(comb.gg$Theme)[match("Land,Structures",levels(comb.gg$Theme))] <- "Others"
levels(comb.gg$Theme)[match("Roads Tracks And Paths,Structures",levels(comb.gg$Theme))] <- "Others"
levels(comb.gg$Theme)[match("Structures",levels(comb.gg$Theme))] <- "Others"
levels(comb.gg$Theme)[match("Roads Tracks And Paths",levels(comb.gg$Theme))] <- "Roads"
levels(comb.gg$Theme)[match("Water",levels(comb.gg$Theme))] <- "River"
levels(comb.gg$Theme)[match("Land",levels(comb.gg$Theme))] <- "Bareland"
comb.gg$Theme <- factor(comb.gg$Theme, levels=c("Buildings","Roads","Bareland","River","Others"))
all.gg <- rbind(inflow.gg,comb.gg)
all.gg$type <- factor(all.gg$type, levels=c(" Fluvial","Combined"))
#plot 5.1
colnames(all.gg.new)[9] <- "Landuse"
#plot 5
all.gg.new <- all.gg[-which(all.gg$MeanFD<0.01),]
#plot 5.1
colnames(all.gg.new)[9] <- "Landuse"
plot6 <- ggplot(data = all.gg.new, aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=comb.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10))+
ggsn::scalebar(data=comb.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
ggplot(data = all.gg.new, aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=all.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10))+
ggsn::scalebar(data=all.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
#for scale bar
e.sbar <- extent(fdinflow.ras)
xlim <- c(311950,312250); ylim <- c(530650,531000)
ggplot(data = all.gg.new, aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=all.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10))+
ggsn::scalebar(data=all.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
plot6 <- ggplot(data = all.gg.new, aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=all.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10), symbol=10)+
ggsn::scalebar(data=all.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
plot6
plot6 <- ggplot(data = all.gg.new, aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(face="bold",size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=all.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10), symbol=10)+
ggsn::scalebar(data=all.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
plot6
png("./plots/02012019/6.2.png",res=600, width = 200, height = 120, units="mm")
plot6
dev.off()
png("./plots/02012019/6.2.png",res=600, width = 200, height = 140, units="mm")
plot6
dev.off()
plot6 <- ggplot(data = filter(all.gg.new, type==Combined), aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(face="bold",size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=all.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10), symbol=10)+
ggsn::scalebar(data=all.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
plot6 <- ggplot(data = filter(all.gg.new, type=="Combined"), aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(face="bold",size = 7))+
labs(fill="Mean\nflood\ndepth (m)")+
north(data=all.gg.new, anchor = c(x = e.sbar@xmax-20, y = e.sbar@ymax -10), symbol=10)+
ggsn::scalebar(data=all.gg.new, dist =0.25,location = "bottomleft", st.size=2,st.dist=0.03,
height=0.02, anchor = c(x = e.sbar@xmin+50, y = e.sbar@ymin +50),
dist_unit = "km", transform = F,
facet.var = "type", facet.lev =c(" Fluvial"))
filter(all.gg.new, type=="Combined")
all.gg.new
ggplot(data = filter(all.gg.new, type=="Combined"), aes(x=long, y=lat, group = group,
fill = MeanFD, colour = Landuse)) +
geom_polygon()  +
facet_wrap(~type, ncol=2)+
#scale_fill_gradient2(low = "darkgreen", mid = "yellow", high = "darkred",midpoint = 3)+
scale_fill_continuous(high = "#132B43", low = "#56B1F7")+
#geom_path(color = "white") +
coord_equal()+
#labs(x="Longitute", y="Lattitute")+
theme(panel.grid=element_blank(),
legend.position="right",
legend.title=element_text(face="bold",size=8),
legend.text=element_text(face="bold",size=8))+
theme(axis.text=element_text(size=6),
axis.title=element_blank())+
theme(strip.text.x = element_text(face="bold",size = 7))+
labs(fill="Mean\nflood\ndepth (m)")
?filter
?resample
aaa <- c(5, 8, 10, 15, 20, 50)
?rmse
bbb <- sr((aaa^2)%length(aaa))
sqrt(mean((aaa^2)))
#adding the cross section lines to the plot
riv.ts.df <- fortify(riv.ts)
#selected DEM, FD (flood depth) resolutions
res.list <- c("1m","2m","5m","10m","30m","50m",
"2m1m","5m1m","10m1m", "30m1m", "50m1m") # when 1m is added to the name it means combined DEM/FD
res.vec <- c(1,2,5,10,30,50,1,1,1,1,1)
#reference
ref.dem <- raster("CbDEM_1m_EA.tif")
ref.FD <- raster("Depth (Max).CbDEM_1m_EA.tif")
ext.new <-extent(ref.dem)
ref.dem <- crop(ref.dem,ext.new)
ref.FD <- crop(ref.FD,ext.new)
#river outline and transects
riv.ol <- readOGR(dsn="./RiverBoundaryMajor",layer="riv_bound_major")
riv.ts <- readOGR(dsn="./RiverTransect",layer="Transect")
plot(riv.ol)
plot(riv.ts, add=T)
