Mapping
Overview Structs
GEMS.AgeMap
GEMS.AttackRateMap
GEMS.CaseFatalityMap
GEMS.Geolocated
GEMS.HouseholdSizeMap
GEMS.InfectionMap
GEMS.MapPlot
GEMS.PopDensityMap
GEMS.SinglesMap
Overview Functions
GEMS.agsmap
GEMS.gemsmap
GEMS.generate_map
GEMS.germanshapes
GEMS.maptypes
GEMS.prepare_map_df!
GEMS.region_range
Structs
GEMS.AgeMap
— TypeAgeMap <: MapPlot
A map that shows the average age per region.
GEMS.AttackRateMap
— TypeAttackRateMap <: MapPlot
A map that shows the fraction of individuals that got infected at least one time per region. The region code (AGS) is taken from the individuals' household location, not the location of infection.
GEMS.CaseFatalityMap
— TypeCaseFatailityMap <: MapPlot
A map that shows the fraction of infections that led to death time per region.
GEMS.Geolocated
— TypeSupertype for all simulation settings which directly contain individuals and are geolocated.
GEMS.InfectionMap
— TypeInfectionMap <: SimulationPlot
A simulation plot type for generating an infection map.
GEMS.HouseholdSizeMap
— TypeHouseholdSizeMap <: MapPlot
A map that shows the average household size per region.
GEMS.MapPlot
— TypeSupertype for all maps that go into single-run simulation reports
GEMS.PopDensityMap
— TypePopDensityMap <: MapPlot
A map that shows the population density per region.
GEMS.SinglesMap
— TypeSinglesMap <: MapPlot
A map that shows the fraction of single-person households per region.
Functions
GEMS.gemsmap
— Functiongemsmap(data; type = :nothing, level = 3, plotargs...)
Generates a geographical map of a desired type
. Just pass the name of the map-type as a Symbol
(must be exactly the same as the respective SimulationPlot
-struct). The data
argument mus be either a Simulation
object (used to map model-related features such as average household sizes per region) or a ResultData
object (used to map simulation-result-related features such as the attack rate per region). Most of the maps that can be generated also take the level
argument that converts the AGS
s to the desired geographical resolution: states (level = 1
), counties (level = 2
) or municipalities (level = 3
).
Parameters
data
:Simulation
orResultData
object.type = :nothing
(optional): Map type (instantiates a map with the exact same struct name).level = 3
(optional): Desired geographical resolution: states (level = 1
), counties (level = 2
) or municipalities (level = 3
)plotargs...
(optional): Any argument that theplot()
function of thePlots.jl
package can take.
Returns
Plots.Plot
: Map using thePlots.jl
package's struct.
Examples
Given that you have a simulation with geolocalized settings (available in the predefined models accessible via the German state codes. e.g., "SH" for the northern-most state of "Schleswig-Holstein"), you can plot the average age per region on a map like this:
sim = Simulation(population = "SH")
gemsplot(sim, type = :AgeMap)
If you want to change the resolution to counties, try:
sim = Simulation(population = "SH")
gemsplot(sim, type = :AgeMap, level = 2)
All gemsmap
s can be nested and combined with any plot of the Plots.jl
package or gemsplot
s:
using Plots
plot(
gemsmap(sim, type = :AgeMap),
gemsplot(rd, type = :TickCases)
)
Map Types
Type | Input Object | Description | Plot-Specific Parameters |
---|---|---|---|
:AgeMap | Simulation | Average age per region. | |
:AttackRate | ResultData | Fraction of people who got infected per region. | |
:CaseFatalityMap | ResultData | Fraction of infections that led to death per region. | |
:HouseholdSizeMap | Simulation | Average household size per region. | |
:PopDensityMap | Simulation | Population density per region. | |
:SinglesMap | Simulation | Fraction of single-person households per region. |
Note: Maps that use infection data (e.g., the AttackRate
) use the individuals' household location to map the data, not the loction of infection.
Some Useful Keyword Arguments
Here are some examples of the Plots.jl
package's keyword arguments that you can also pass to the gemsmap()
function and might find helpful:
clims = (0, 1)
: Setting the color bar range between 0 and 1colorbar = false
: Disabling the colorbarsize = (300, 400)
: Resizing the map plottitle = "My Subtitle"
: Adding a subtitleplot_title = "My New Title"
: Changing the map title
Please consult the Plots.jl
package documentation for a comprehensive list
GEMS.agsmap
— Functionagsmap(df::DataFrame, level::Int64; plotargs...)
Returns a Plot.js
plot with shapes of German states, counties, or municipalities. The input dataframe df
requires two columns. The first column needs to be named ags
and has to be a vector of AGS
structs (Amtlicher Gemeindeschlüssel). The second column needs to be a vector of numerical values which are used to color-code the map. The level
argument defines wether the map plots states (level = 1
), counties (level = 2
) or municipalities (level = 3
). Note that the AGS
in the dataframe must thus also be of the same geographic resolution. The optional plotargs...
are passed to the plot object. Please lookup the Plots.jl
package for more information about what arguments can be used to customize a plot.
Parameters
df::DataFrame
: DataFrame withags
-named column that containsAGS
structs and a second column with numerical values.level::Int64
: Map resolution. states (level = 1
), counties (level = 2
) or municipalities (level = 3
)plotargs...
(optional): Any argument that theplot()
function of thePlots.jl
package can take.
Returns
Plots.Plot
: Plot using thePlots.jl
package's struct.
agsmap(df::DataFrame; plotargs...)
Wrapper for the agsmap function that infers the correct geographical resolution (level
) from the input dataframe. Please lookup the agsmap(df, level; plotargs...)
function's docstring for more information.
GEMS.generate_map
— Functiongenerate_map(coords::DataFrame, dest::AbstractString; region = [], plotempty::Bool = false)
Generates a GMT map and stores it into the folder specified in dest
. The coords
DataFrame must provide at least a lat
- and a lon
-column specifying latitude and longitude data pairs. The region
parameter expects an array of four integer values providing the outer bounds of the map according to [min_lon, max_lon, min_lat, max_lat]
. If no region
parameter is passed, the bounds are taken from the lan/lon range provided in the coords
data with a %-padding according to MAP_PADDING
defined in constants.jl . With the plotempty
flag you can force to plot a map without any data points.
Parameters
coords::DataFrame
: Dataframe withlat
andlon
columndest::AbstractString
: Storage location for the generated mapregion = []
(optional): four-item region vector defining the map limits in lat/lon min/max pairs (look upGMT.jl
package to learn about regions)plotempty::Bool = false
(optional): Allows to plot an empty map if no data points are given
Returns
GMTWrapper
: Custom struct containing the storage location of the generated map
GEMS.germanshapes
— Methodgermanshapes(level::Int64)
Returns the Shapefile.Table
object read from the respective shapefile. Downloads the file if it is not already locally available. Lookup constants.jl
to find remote location of the shapefile. The level
argument defines wether the state- (level = 1
), county- (level = 2
) or municipality- (level = 3
) shapes are returned.
Returns
Shapefile.Table{Union{Missing, Shapefile.Polygon}}
: Shapefile data. Lookup Shapefile.jl
package for documentation.
GEMS.maptypes
— Functionmaptypes()
Returns a list of all map types that can be used for the gemsmap()
function.
GEMS.prepare_map_df!
— Functionprepare_map_df!(df::DataFrame; level::Int = 3)
Input df
requires the format that can go into the agsmap()
function. This means, at least two columns, the first one being an AGS
column called ags
and a second column with numerical values. The level
argument converts the AGS
s to the desired geographical resolution: states (level = 1
), counties (level = 2
) or municipalities (level = 3
)
Returns
DataFrame
: Adapted dataframe with desiredAGS
resolution in first column.
GEMS.region_range
— Methodregion_range(coords::DataFrame)
returns outer bound lat/lon for map plotting based in the provided coordinates dataframe. Adds a padding as specified in MAP_PADDING
in constants.jl