How to generate inputs for the MUNICH model from the VEIN model MUNICH is the Model of Urban Network of Intersecting Canyons and Highways (MUNICH) (Kim et al., 2018) and VEIN is the Vehicular Emissions INventory model (Ibarra-Espinosa et al, 2018), an R package.
VEIN estimates vehicular emissions at street level, generating useful inputs for the MUNICH model, however, some pre-processing is necessary. Therefore, the model eixport was created to help in this processing.
As a maintainer I receive many emails asking how to generate inputs for the MUNICH model

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.
Ibarra-Espinosa, S., Ynoue, R., O'Sullivan, S., Pebesma, E., Andrade, M. D. F., and Osses, M.: VEIN v0.2.2: an R package for bottom–up vehicular emissions inventories, Geosci. Model Dev., 11, 2209–2229, https://doi.org/10.5194/gmd-11-2209-2018, 2018.
Ibarra-Espinosa et al., (2018b). eixport: An R package to export emissions to atmospheric models. Journal of Open Source Software, 3(24), 607, https://doi.org/10.21105/joss.00607
First, download a project with vein and estimate vehicular emissions.
Some projects are here: https://atmoschem.github.io/vein/reference/get_project.html
library(vein)
get_project(directory = &quot;awesomecity&quot;)

Then open the file main.Rproj with Rstudio and source the file main.R
Then, run the following code

library(data.table)
library(eixport)
library(sf)
#&gt; Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(writexl)
library(vein)
library(units)
#&gt; udunits system database from /usr/share/xml/udunits
# epsg 31983, projected UTM
co &lt;- readRDS(&quot;post/streets/CO.rds&quot;)
st_crs(co)
#&gt; Coordinate Reference System:
#&gt;   User input: EPSG:31983 
#&gt;   wkt:
#&gt; PROJCS[&quot;SIRGAS 2000 / UTM zone 23S&quot;,
#&gt;     GEOGCS[&quot;SIRGAS 2000&quot;,
#&gt;         DATUM[&quot;Sistema_de_Referencia_Geocentrico_para_las_AmericaS_2000&quot;,
#&gt;             SPHEROID[&quot;GRS 1980&quot;,6378137,298.257222101,
#&gt;                 AUTHORITY[&quot;EPSG&quot;,&quot;7019&quot;]],
#&gt;             TOWGS84[0,0,0,0,0,0,0],
#&gt;             AUTHORITY[&quot;EPSG&quot;,&quot;6674&quot;]],
#&gt;         PRIMEM[&quot;Greenwich&quot;,0,
#&gt;             AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],
#&gt;         UNIT[&quot;degree&quot;,0.0174532925199433,
#&gt;             AUTHORITY[&quot;EPSG&quot;,&quot;9122&quot;]],
#&gt;         AUTHORITY[&quot;EPSG&quot;,&quot;4674&quot;]],
#&gt;     PROJECTION[&quot;Transverse_Mercator&quot;],
#&gt;     PARAMETER[&quot;latitude_of_origin&quot;,0],
#&gt;     PARAMETER[&quot;central_meridian&quot;,-45],
#&gt;     PARAMETER[&quot;scale_factor&quot;,0.9996],
#&gt;     PARAMETER[&quot;false_easting&quot;,500000],
#&gt;     PARAMETER[&quot;false_northing&quot;,10000000],
#&gt;     UNIT[&quot;metre&quot;,1,
#&gt;         AUTHORITY[&quot;EPSG&quot;,&quot;9001&quot;]],
#&gt;     AXIS[&quot;Easting&quot;,EAST],
#&gt;     AXIS[&quot;Northing&quot;,NORTH],
#&gt;     AUTHORITY[&quot;EPSG&quot;,&quot;31983&quot;]]
head(co, 1) # units g/h
#&gt; Simple feature collection with 1 feature and 25 fields
#&gt; geometry type:  LINESTRING
#&gt; dimension:      XY
#&gt; bbox:           xmin: 328001.4 ymin: 7391129 xmax: 328036.5 ymax: 7391204
#&gt; projected CRS:  SIRGAS 2000 / UTM zone 23S
#&gt;        id            V1             V2             V3             V4
#&gt; 1 1 [1/h] 275.088 [g/h] 140.0241 [g/h] 84.63286 [g/h] 86.81989 [g/h]
#&gt;               V5             V6             V7         V8             V9
#&gt; 1 195.8425 [g/h] 680.7458 [g/h] 1423.767 [g/h] 1719 [g/h] 1723.265 [g/h]
#&gt;              V10            V11            V12            V13          V14
#&gt; 1 1748.996 [g/h] 1600.077 [g/h] 1448.586 [g/h] 1378.825 [g/h] 1551.5 [g/h]
#&gt;              V15            V16            V17            V18            V19
#&gt; 1 1556.648 [g/h] 1538.186 [g/h] 1698.133 [g/h] 1655.548 [g/h] 1601.138 [g/h]
#&gt;              V20            V21            V22            V23            V24
#&gt; 1 1398.703 [g/h] 941.4398 [g/h] 709.3241 [g/h] 581.2601 [g/h] 407.1127 [g/h]
#&gt;                         geometry
#&gt; 1 LINESTRING (328001.4 739120...

# example of  polygon as buffer at center
st_bbox(co) %&gt;%
  st_as_sfc() %&gt;%
  st_centroid() %&gt;%
  st_buffer(dist = 2000) -&gt; polygon

# if you have another polygon, read it
# polygon &lt;- st_read(&quot;/path/to/polygon.gpkg&quot;)

cob &lt;- st_intersection(co, polygon)
#&gt; Warning: attribute variables are assumed to be spatially constant throughout all
#&gt; geometries

# Remove ID
co$id &lt;- NULL

# split on vertex conserving mass
cos &lt;- st_explode(cob)
#&gt; Sum: 16542955.31
dim(cos)
#&gt; [1] 372  27
# it adds length LKM and LKM2
# Should we remove streets shorter than 10 mts?
cos &lt;- cos[as.numeric(cos$LKM2) &gt; 10, ]

# remove LKM and LKM2
cos$LKM &lt;- cos$LKM2 &lt;- NULL

# We need to add units back, g/h
cos &lt;- vein::Emissions(cos, time = &quot;1/h&quot;)
head(cos, 1)
#&gt; Simple feature collection with 1 feature and 24 fields
#&gt; geometry type:  LINESTRING
#&gt; dimension:      XY
#&gt; bbox:           xmin: 331916.3 ymin: 7385767 xmax: 331922.9 ymax: 7385775
#&gt; projected CRS:  SIRGAS 2000 / UTM zone 23S
#&gt;               V1             V2             V3             V4             V5
#&gt; 1 59.38562 [g/h] 30.22821 [g/h] 18.27042 [g/h] 18.74256 [g/h] 42.27821 [g/h]
#&gt;               V6             V7             V8             V9            V10
#&gt; 1 146.9585 [g/h] 307.3609 [g/h] 371.0953 [g/h] 372.0159 [g/h] 377.5708 [g/h]
#&gt;              V11            V12            V13            V14            V15
#&gt; 1 345.4224 [g/h] 312.7188 [g/h] 297.6588 [g/h] 334.9356 [g/h] 336.0469 [g/h]
#&gt;              V16            V17            V18            V19          V20
#&gt; 1 332.0614 [g/h] 366.5907 [g/h] 357.3973 [g/h] 345.6514 [g/h] 301.95 [g/h]
#&gt;              V21            V22            V23            V24
#&gt; 1 203.2367 [g/h] 153.1279 [g/h] 125.4816 [g/h] 87.88691 [g/h]
#&gt;                         geometry
#&gt; 1 LINESTRING (331916.3 738577...
# now we transform for the REQUIRED UNITS FOR MUNICH
# ug/km/h

# we have 24 hours in this case
hours &lt;- paste0(&quot;V&quot;, 1:24)

for (i in seq_along(hours)) {
  cos[[hours[i]]] &lt;- set_units(cos[[hours[i]]], ug / h)
  cos[[hours[i]]] &lt;- cos[[hours[i]]] / set_units(st_length(cos), km)
}
plot(cos[&quot;V1&quot;], axes = T)


etm &lt;- to_munich(sdf = cos)
names(etm)
#&gt; [1] &quot;Emissions&quot; &quot;Street&quot;
head(etm$Emissions, 1)
#&gt;   i idbrin typo        xa        ya        xb        yb                   V1
#&gt; 1 1      1    0 -46.64773 -23.62993 -46.64766 -23.63001 5462199660 [ug/h/km]
#&gt;                     V2                   V3                   V4
#&gt; 1 2780345076 [ug/h/km] 1680485867 [ug/h/km] 1723911918 [ug/h/km]
#&gt;                     V5                    V6                    V7
#&gt; 1 3888685780 [ug/h/km] 13517016236 [ug/h/km] 28270586844 [ug/h/km]
#&gt;                      V8                    V9                   V10
#&gt; 1 34132780053 [ug/h/km] 34217462106 [ug/h/km] 34728386913 [ug/h/km]
#&gt;                     V11                   V12                   V13
#&gt; 1 31771425772 [ug/h/km] 28763397272 [ug/h/km] 27378203813 [ug/h/km]
#&gt;                     V14                   V15                   V16
#&gt; 1 30806871891 [ug/h/km] 30909088139 [ug/h/km] 30542507720 [ug/h/km]
#&gt;                     V17                   V18                   V19
#&gt; 1 33718452534 [ug/h/km] 32872865695 [ug/h/km] 31792493506 [ug/h/km]
#&gt;                     V20                   V21                   V22
#&gt; 1 27772900557 [ug/h/km] 18693404826 [ug/h/km] 14084471885 [ug/h/km]
#&gt;                     V23                  V24
#&gt; 1 11541609851 [ug/h/km] 8083705065 [ug/h/km]
head(etm$Street, 1)
#&gt;   i       length width height
#&gt; 1 1 10.87211 [m]     0     30

# to export to CSV which supports bit64
data.table::fwrite(
  etm$Emissions,
  paste0(basename(getwd()), "_Emissions.csv")
)
data.table::fwrite(
  etm$Street,
  paste0(basename(getwd()), &quot;_Streets.csv&quot;)
)

# to export to Excel
writexl::write_xlsx(
  x = etm$Emissions,
  path = paste0(basename(getwd()), "_Emissions.xlsx")
)
writexl::write_xlsx(
  x = etm$Street,
  path = paste0(basename(getwd()), &quot;_Streets.xlsx&quot;)
)

Created on 2020-10-14 by the reprex package (v0.3.0)