vein (version 0.7.8)

grid_emis: Allocate emissions gridded emissions into streets (grid to emis street)

Description

grid_emis it is sort of the opposite of emis_grid. It allocates gridded emissions into streets. This function applies emis_dist into each grid cell using lapply. This function is in development and pull request are welcome.

Usage

grid_emis(spobj, g, sr, pro, osm, verbose = TRUE)

Arguments

spobj

A spatial dataframe of class "sp" or "sf". When class is "sp" it is transformed to "sf".

g

A grid with class "SpatialPolygonsDataFrame" or "sf". This grid includes the total emissions with the column "emission". If profile is going to be used, the column 'emission' must include the sum of the emissions for each profile. For instance, if profile covers the hourly emissions, the column 'emission' bust be the sum of the hourly emissions.

sr

Spatial reference e.g: 31983. It is required if spobj and g are not projected. Please, see http://spatialreference.org/.

pro

Numeric, Matrix or data-frame profiles, for instance, pc_profile.

osm

Numeric; vector of length 5, for instance, c(5, 3, 2, 1, 1). The first element covers 'motorway' and 'motorway_link. The second element covers 'trunk' and 'trunk_link'. The third element covers 'primary' and 'primary_link'. The fourth element covers 'secondary' and 'secondary_link'. The fifth element covers 'tertiary' and 'tertiary_link'.

verbose

Logical; to show more info.

Examples

Run this code
# 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)
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
#
# }
# NOT RUN {
#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)
xnet <- grid_emis(osm, gCO)
plot(xnet, axes = T)
# }
# NOT RUN {
}
# }

Run the code above in your browser using DataCamp Workspace