eradiate.scenes.surface.mesh_from_dem#
- eradiate.scenes.surface.mesh_from_dem(da, geometry, planet_radius=None, add_texcoords=False)[source]#
Construct a DEM surface mesh from a data array holding elevation data.
This function has 4 modes of operations, depending on 2 parameters:
the selected geometry type (plane-parallel or spherical-shell);
the coordinates of the input dataset (longitude/latitude or x/y).
Alongside the generated mesh, this function returns extents that can be used to position a background stencil around the produced shape (see the notes for details).
- Parameters:
da (
DataArray
) – Data array with elevation data, indexed either by latitude and longitude coordinates or x and y coordinates.geometry (
SceneGeometry
ordict
orstr
) – Scene geometry configuration. The value is pre-processed by theSceneGeometry.convert()
converter.planet_radius (
quantity
orfloat
, default:EARTH_RADIUS
) – Planet radius used to convert latitude/longitude to x/y whengeometry
is aPlaneParallelGeometry
instance. This parameter is unused otherwise. If a unitless value is passed, it is interpreted using default config length units.add_texcoords (
bool
, default:False
) – IfTrue
, texture coordinates are added to the created mesh.
- Returns:
mesh (
BufferMeshShape
) – A triangulated mesh representing the DEM.xlon_lim (
quantity
) – Limits of DEM on the x/longitude axis, in length (resp. angle) units for plane-parallel (resp. spherical-shell) geometries.ylat_lim (
quantity
) – Limits of DEM on the y/latitude axis, in length (resp. angle) units for plane-parallel (resp. spherical-shell) geometries.
Notes
The
da
parameter may use the following formats:with longitude / latitude coordinates, then named
"lon"
and"lat"
respectively;with x / y coordinates, then named
"x"
and"y"
respectively.
Coordinate and variable units are specified using the
units
xarray attributes and are expected to be consistent with coordinate names.The mesh generation algorithm operates in four modes, two of which exist for testing purposes and not recommended for quantitative applications:
Plane-parallel / xy mode: The mesh is generated using vertices positioned at grid points, then offset to center it at the origin location of the local frame. The returned extent is in length units.
Spherical-shell / lonlat mode: Coordinates are straightforwardly converted to an ECEF frame. The resulting mesh is positioned where it should fit on the reference geoid (currently a perfect sphere). The returned extent is in longitude/latitude.
Plane-parallel / lonlat mode: The input data is interpreted using a Mercator projection, and generated vertices are offset to center the mesh at the origin of the local frame. The returned extent is in length units. The projection is highly distorting and should not be used for quantitative applications.
Spherical-shell / xy mode: Coordinates are converted to longitude and latitude using an inverse Mercator projection, assuming that the dataset is centred at the equator, then reinterpreted in an ECEF frame. The returned extent is in longitude/latitude. The projection is highly distorting and should not be used for quantitative applications.
The generated mesh can optionally be assigned texture coordinates used to map spatially-varying data (e.g. textured reflectance value for a Lambertian BSDF).