if (FALSE) {
# Not run
library(vein)
library(units)
library(sf)
data(net)
data(pc_profile)
data(profiles)
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 and speed
speed <- data.frame(S8 = net$ps)
lef <- EmissionFactorsList(ef_cetesb("CO",
"PC_G",
agemax = ncol(pc1)))
E_CO <- emis(veh = pc1,
lkm = net$lkm,
ef = lef,
speed = speed)
# rowSums drop units
net$CO <- set_units(rowSums(E_CO), g/h)
# selecting only CO and exploding lines and updating emissions
df <- st_explode(net["CO"])
# st_explode should not drop units, must fix
df$CO <- set_units(df$CO, g/h)
# now we have split line in vertex
# selecting 1000 links
dfco <- df[1:1000,"CO"]
###########
#MUNICH relies in a python script that reads emissions with units ug/km/h
# Therefore
dfco$CO <- set_units(dfco$CO, ug/h)
dfco$CO<- dfco$CO/set_units(st_length(dfco), km)
etm <- to_munich(sdf = dfco)
names(etm)
class(etm)
head(etm$Emissions)
head(etm$Street)
write.table(x = etm$Emissions,
file = paste0(tempfile(), "_Emissions.txt"),
row.names = FALSE,
sep = " ",
quote = FALSE)
write.table(x = etm$Street,
file = paste0(tempfile(), "_Street.txt"),
row.names = FALSE,
sep = " ",
quote = FALSE)
}
Run the code above in your browser using DataLab