Learn R Programming

eixport (version 0.6.2)

to_munich: Export emissions to Model of Urban Network of Intersecting Canyons and Highways (MUNICH)

Description

to_munich Export spatial emissions objects according the format required by MUNICH. This function was designed to read street emissions from VEIN by it can be used to read any other.

Usage

to_munich(sdf, idbrin, typo, width, height, crs = 4326)

Value

A list with a data frame with columns "i", "idbrin", "typo", "xa", "ya", "xb", "yb" and the pollutants; and another data.frame with "i", "length" (m), "width" (with value 0) and "height" (with value 0). Width and height must be obtained by the user.

Arguments

sdf

Street Emissions object class 'sf' LINESTRING or "SpatialLinesdataFrame". The columns are the emissions.

idbrin

Integer; id.

typo

Integer; id2.

width

Integer; width.

height

Integer; heigth.

crs

Numeric; Coordenade Reference System to project data or not.

References

Kim, Y., Wu, Y., Seigneur, C., and Roustan, Y.: Multi-scale modeling of urban air pollution: development and application of a Street-in-Grid model (v1.0) by coupling MUNICH (v1.0) and Polair3D (v1.8.1), Geosci. Model Dev., 11, 611-629, https://doi.org/10.5194/gmd-11-611-2018, 2018.

Examples

Run this code
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