xdem.DEM#
- class xdem.DEM(filename_or_dataset, vcrs=None, silent=True, **kwargs)[source]#
The digital elevation model.
- The DEM has a single main attribute in addition to that inherited from
geoutils.Raster
: - vcrs:
pyproj.VerticalCRS
Vertical coordinate reference system of the DEM.
- vcrs:
- Other derivative attributes are:
- The attributes inherited from
geoutils.Raster
are: - data:
np.ndarray
Data array of the DEM, with dimensions corresponding to (count, height, width).
- transform:
affine.Affine
Geotransform of the DEM.
- crs:
pyproj.crs.CRS
Coordinate reference system of the DEM.
- nodata:
int
orfloat
Nodata value of the DEM.
- data:
All other attributes are derivatives of those attributes, or read from the file on disk. See the API for more details.
- __init__(filename_or_dataset, vcrs=None, silent=True, **kwargs)[source]#
Instantiate a digital elevation model.
The vertical reference of the DEM can be defined by passing the vcrs argument. Otherwise, a vertical reference is tentatively parsed from the DEM product name.
Inherits all attributes from the
geoutils.Raster
andgeoutils.SatelliteImage
classes.- Parameters:
filename_or_dataset (
Union
[str
,TypeVar
(RasterType
, bound= Raster),DatasetReader
,MemoryFile
]) – The filename of the dataset.vcrs (
Union
[Literal
['Ellipsoid'
],Literal
['EGM08'
],Literal
['EGM96'
],VerticalCRS
,str
,Path
,int
,None
]) – Vertical coordinate reference system either as a name (“WGS84”, “EGM08”, “EGM96”), an EPSG code or pyproj.crs.VerticalCRS, or a path to a PROJ grid file (OSGeo/PROJ-data).silent (
bool
) – Whether to display vertical reference parsing.
Methods
__init__
(filename_or_dataset[, vcrs, silent])Instantiate a digital elevation model.
aspect
([method, degrees, use_richdem])Calculate the aspect of each cell in a DEM, returned in degrees by default.
astype
(dtype[, convert_nodata, inplace])Convert data type of the raster.
coords
([grid, shift_area_or_point, force_offset])Get coordinates (x,y) of all pixels in the raster.
copy
([new_array])Copy the DEM, possibly updating the data array.
coregister_3d
(reference_elev[, ...])Coregister DEM to a reference DEM in three dimensions.
crop
(crop_geom[, mode, inplace])Crop the raster to a given extent.
curvature
([use_richdem])Calculate the terrain curvature (second derivative of elevation) in m-1 multiplied by 100.
estimate_uncertainty
(other_dem[, ...])Estimate uncertainty of DEM.
fractal_roughness
([window_size])Calculates the fractal roughness, the local 3D fractal dimension.
from_array
(data, transform, crs[, nodata, ...])Create a DEM from a numpy array and the georeferencing information.
from_xarray
(ds[, dtype])Create raster from a xarray.DataArray.
georeferenced_grid_equal
(raster)Check that raster shape, geotransform and CRS are equal.
get_bounds_projected
(out_crs[, densify_points])Get raster bounds projected in a specified CRS.
get_footprint_projected
(out_crs[, ...])Get raster footprint projected in a specified CRS.
get_mask
()Get mask of invalid values from the raster.
get_metric_crs
([local_crs_type, method])Get local metric coordinate reference system for the raster (UTM, UPS, or custom Mercator or Polar).
get_nanarray
([return_mask])Get NaN array from the raster.
get_terrain_attribute
(attribute, **kwargs)Derive one or multiple terrain attributes from a DEM.
hillshade
([method, azimuth, altitude, ...])Generate a hillshade from the given DEM.
ij2xy
(i, j[, shift_area_or_point, force_offset])Get coordinates (x,y) of indexes (row,column).
info
([stats, verbose])Print summary information about the raster.
interp_points
(points[, method, band, ...])Interpolate raster values at a set of points.
intersection
(raster[, match_ref])Returns the bounding box of intersection between this image and another.
load
([bands])Load the raster array from disk.
maximum_curvature
([use_richdem])Calculate the signed maximum profile or planform curvature parallel to the direction of the slope in m-1 multiplied by 100.
outside_image
(xi, yj[, index])Check whether a given point falls outside the raster.
planform_curvature
([use_richdem])Calculate the terrain curvature perpendicular to the direction of the slope in m-1 multiplied by 100.
plot
([bands, cmap, vmin, vmax, alpha, ...])Plot the raster, with axes in projection of image.
polygonize
([target_values])Polygonize the raster into a vector.
profile_curvature
([use_richdem])Calculate the terrain curvature parallel to the direction of the slope in m-1 multiplied by 100.
proximity
([vector, target_values, ...])Compute proximity distances to the raster target pixels, or to a vector geometry on the raster grid.
raster_equal
(other[, strict_masked, ...])Check if two rasters are equal.
reproject
([ref, crs, res, grid_size, ...])Reproject raster to a different geotransform (resolution, bounds) and/or coordinate reference system (CRS).
roughness
([window_size])Calculates the roughness, the maximum difference between neighbouring pixels, for any window size.
rugosity
()Calculates the rugosity, the ratio between real area and planimetric area.
save
(filename[, driver, dtype, nodata, ...])Write the raster to file.
set_area_or_point
(new_area_or_point[, ...])Set new pixel interpretation of the raster.
set_mask
(mask)Set a mask on the raster array.
set_nodata
(new_nodata[, update_array, ...])Set a new nodata value for all bands.
set_vcrs
(new_vcrs)Set the vertical coordinate reference system of the DEM.
shift
(xoff, yoff[, distance_unit, inplace])Shift a raster by a (x,y) offset.
slope
([method, degrees, use_richdem])Generate a slope map for a DEM, returned in degrees by default.
split_bands
([copy, bands])Split the bands into separate rasters.
subsample
(subsample[, return_indices, ...])Randomly sample the raster.
terrain_ruggedness_index
([method, window_size])Calculates the Terrain Ruggedness Index, the cumulated differences to neighbouring pixels.
to_pointcloud
([data_column_name, data_band, ...])Convert raster to point cloud.
to_points
(**kwargs)to_rio_dataset
()Export to a Rasterio in-memory dataset.
to_vcrs
(vcrs[, force_source_vcrs])Convert the DEM to another vertical coordinate reference system.
to_xarray
([name])Convert raster to a xarray.DataArray.
topographic_position_index
([window_size])Calculates the Topographic Position Index, the difference to the average of neighbouring pixels.
value_at_coords
(x, y[, latlon, band, ...])Extract raster values at the nearest pixels from the specified coordinates, or reduced (e.g., mean of pixels) from a window around the specified coordinates.
xy2ij
(x, y[, op, precision, shift_area_or_point])Get indexes (row,column) of coordinates (x,y).
Attributes
area_or_point
Pixel interpretation of the raster.
bands
Band indexes loaded in memory if they are, otherwise on disk.
bands_on_disk
Band indexes on disk if a file exists.
bounds
Bounding coordinates of the raster.
ccrs
Compound horizontal and vertical coordinate reference system of the DEM.
count
Count of bands loaded in memory if they are, otherwise the one on disk.
count_on_disk
Count of bands on disk if it exists.
Coordinate reference system of the raster.
Array of the raster.
datetime
driver
Driver used to read a file on disk.
dtype
Data type of the raster (string representation).
height
Height of the raster in pixels.
indexes
Band indexes (duplicate of .bands attribute, mirroring Rasterio naming "indexes").
is_loaded
Whether the raster array is loaded.
is_modified
Whether the array has been modified since it was loaded from disk.
name
Name of the file on disk, if it exists.
Nodata value of the raster.
product
res
Resolution (X, Y) of the raster in georeferenced units.
satellite
sensor
shape
Shape (i.e., height, width) of the raster in pixels.
tile_name
Geotransform of the raster.
Vertical coordinate reference system of the DEM.
vcrs_grid
Grid path of vertical coordinate reference system of the DEM.
vcrs_name
Name of vertical coordinate reference system of the DEM.
version
width
Width of the raster in pixels.
date
- The DEM has a single main attribute in addition to that inherited from