# NOT RUN {
data(net)
data(pc_profile)
data(fkm)
PC_G <- c(33491,22340,24818,31808,46458,28574,24856,28972,37818,49050,87923,
133833,138441,142682,171029,151048,115228,98664,126444,101027,
84771,55864,36306,21079,20138,17439, 7854,2215,656,1262,476,512,
1181, 4991, 3711, 5653, 7039, 5839, 4257,3824, 3068)
pc1 <- my_age(x = net$ldv, y = PC_G, name = "PC")
# Estimation for morning rush hour and local emission factors
lef <- EmissionFactorsList(ef_cetesb("CO", "PC_G"))
E_CO <- emis(veh = pc1,lkm = net$lkm, ef = lef,
profile = 1, speed = Speed(1))
E_CO_STREETS <- emis_post(arra = E_CO, by = "streets", net = net)
g <- make_grid(net, 1/102.47/2) #500m in degrees
gCO <- emis_grid(spobj = E_CO_STREETS, g = g)
gCO$emission <- gCO$V1
area <- sf::st_area(gCO)
area <- units::set_units(area, "km^2") #Check units!
gCO$emission <- gCO$emission*area
#
\dontrun{
#do not run
library(osmdata)
library(sf)
osm <- osmdata_sf(
add_osm_feature(
opq(bbox = st_bbox(gCO)),
key = 'highway'))$osm_lines[, c("highway")]
st <- c("motorway", "motorway_link", "trunk", "trunk_link",
"primary", "primary_link", "secondary", "secondary_link",
"tertiary", "tertiary_link")
osm <- osm[osm$highway %in% st, ]
plot(osm, axes = T)
# top_down requires name `emissions` into gCO`
xnet <- grid_emis(osm, gCO, top_down = TRUE)
plot(xnet, axes = T)
# bottom_up requires that emissions are named `V` plus the hour like `V1`
xnet <- grid_emis(osm, gCO,top_down= FALSE)
plot(xnet["V1"], axes = T)
}
# }
Run the code above in your browser using DataLab