source_importers¶
source_importers ¶
Source importers from GIS / CAD formats.
Permit consultants typically receive site plans as Esri shapefiles
(.shp) from GIS staff and AutoCAD drawings (.dxf) from civil and
mechanical engineers. This module turns either into pyaermod source
dataclasses, ready to drop into a :class:SourcePathway.
Two importers are exposed:
- :func:
from_shapefile— depends on thegeoextra (geopandas). - :func:
from_dxf— depends on thecadextra (ezdxf), which is lightweight (~5 MB, MIT-licensed, pure Python).
The mapping from geometry to source type follows EPA convention:
============================== ==============================
Geometry Default pyaermod source type
============================== ==============================
Point / Point Z :class:PointSource
Polygon / Polygon Z :class:AreaPolySource
LineString / LineString Z :class:LineSource
============================== ==============================
Caller can override the default via source_type= to map every
imported feature to a specific class (e.g. RLineSource instead
of LineSource for roadway centerlines). Per-feature attribute
columns (emission_rate, stack_height, etc.) are looked up by name
on each feature; missing columns fall back to the keyword defaults
on the dataclass.
VolumeSource
dataclass
¶
AERMOD volume source
Represents a three-dimensional volume with initial dispersion. Useful for modeling emissions from buildings, structures, or areas with significant initial mixing.
from_shapefile ¶
from_shapefile(path: Union[str, Path], *, src_id_field: str = 'source_id', source_type: Optional[Type] = None, attribute_map: Optional[dict] = None, layer: Optional[str] = None) -> List
Import sources from an Esri shapefile (or any geopandas-readable file).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Path to the .shp (or .gpkg / .geojson / etc.). Anything
|
required |
src_id_field
|
str
|
Attribute column to use for the source_id. Falls back to
|
'source_id'
|
source_type
|
Optional[Type]
|
Override default geometry → source class mapping. For example
pass |
None
|
attribute_map
|
Optional[dict]
|
Optional mapping of {shapefile_attribute: source_field}, e.g.
|
None
|
layer
|
Optional[str]
|
For multi-layer formats (e.g. GPKG), the layer name to read. |
None
|
Returns:
| Type | Description |
|---|---|
list of source dataclass instances ready for SourcePathway(sources=[...]).
|
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If geopandas is not installed (pip install pyaermod[geo]). |
from_dxf ¶
from_dxf(path: Union[str, Path], *, layer: Optional[str] = None, src_id_prefix: str = 'DXF', source_type: Optional[Type] = None, z_as_height: bool = False) -> List
Import sources from an AutoCAD DXF file.
Maps DXF geometry to pyaermod sources::
POINT -> PointSource (or VolumeSource when source_type passed)
LWPOLYLINE -> AreaPolySource (closed) or LineSource (open)
POLYLINE -> same as LWPOLYLINE
LINE -> LineSource
CIRCLE -> AreaPolySource (16-vertex approximation)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Union[str, Path]
|
Path to the .dxf file. |
required |
layer
|
Optional[str]
|
Restrict import to entities on a single named DXF layer. |
None
|
src_id_prefix
|
str
|
Prefix for synthesized source IDs (DXF doesn't natively carry source_id-like attributes). |
'DXF'
|
source_type
|
Optional[Type]
|
Override default geometry → source class mapping. |
None
|
z_as_height
|
bool
|
When True, treat each entity's z elevation (or polyline's
const_z) as |
False
|
Returns:
| Type | Description |
|---|---|
list of source dataclass instances.
|
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If ezdxf is not installed (pip install pyaermod[cad]). |