kmz_export¶
kmz_export ¶
Hand-rolled KMZ exporter for AERMOD project + results visualization in Google Earth.
Zero new dependencies — KMZ is a frozen OGC spec (a zipped KML XML document), and we emit only the small subset needed for sources, receptors, and concentration contours. Pyproj is used optionally to re-project UTM source/receptor coordinates to WGS84 lon/lat, but only when the caller specifies a CRS; lon/lat input passes through.
Public entry point::
from pyaermod import to_kmz
to_kmz(
output_path="myrun.kmz",
sources=project.sources.sources, # AERMOD source list
receptors=results.receptors, # iterable of (x, y, conc)
contours=[...], # optional
utm_zone=18, # if x/y are UTM meters
northern_hemisphere=True,
title="My AERMOD run",
)
The resulting .kmz drops into Google Earth via File > Open.
ContourPolygon
dataclass
¶
One contour level rendered as a closed polygon in lon/lat.
to_kmz ¶
to_kmz(output_path: Union[str, Path], *, sources: Optional[Iterable] = None, receptors: Optional[Iterable[Tuple[float, float, float]]] = None, contours: Optional[Iterable[ContourPolygon]] = None, utm_zone: Optional[int] = None, northern_hemisphere: bool = True, title: str = 'AERMOD scenario', palette: Optional[Sequence[str]] = None) -> Path
Serialize an AERMOD scenario to a Google-Earth-compatible KMZ.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
Union[str, Path]
|
Path to the .kmz file to create. Parent directories are created automatically. |
required |
sources
|
Optional[Iterable]
|
Iterable of AERMOD source dataclass instances. Each source must
expose |
None
|
receptors
|
Optional[Iterable[Tuple[float, float, float]]]
|
Iterable of |
None
|
contours
|
Optional[Iterable[ContourPolygon]]
|
Iterable of :class: |
None
|
utm_zone
|
Optional[int]
|
Optional UTM zone for sources/receptors. If supplied, all
source + receptor coordinates are reprojected from UTM to
WGS84 lon/lat. Requires |
None
|
northern_hemisphere
|
bool
|
Whether the UTM zone is northern (default) or southern. |
True
|
title
|
str
|
Document title written to the KMZ. |
'AERMOD scenario'
|
palette
|
Optional[Sequence[str]]
|
Optional list of KML AABBGGRR color codes for contour levels. Defaults to a 6-level cyan-to-magenta palette; cycles when more levels are present. |
None
|
Returns:
| Type | Description |
|---|---|
The output path as a :class:`Path`.
|
|