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.Rasterare: - 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:
intorfloat 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.Rasterandgeoutils.SatelliteImageclasses.- 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.
astype(dtype[, inplace])Convert data type of the raster.
coords([offset, grid])Get coordinates (x,y) of all pixels in the raster.
copy([new_array])Copy the DEM, possibly updating the data array.
crop(crop_geom[, mode, inplace])Crop the raster to a given extent.
from_array(data, transform, crs[, nodata, vcrs])Create a DEM from a numpy array and the georeferencing information.
georeferenced_grid_equal(raster)Check that raster shape, geotransform and CRS are equal.
get_bounds_projected(out_crs[, densify_pts])Get raster bounds projected in a specified CRS.
get_footprint_projected(out_crs[, densify_pts])Get raster footprint projected in a specified CRS.
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.
ij2xy(i, j[, offset])Get coordinates (x,y) of indexes (row,column).
info([stats])Summarize information about the raster.
interp_points(pts[, input_latlon, mode, ...])Interpolate raster values at a set of points.
intersection(rst[, match_ref])Returns the bounding box of intersection between this image and another.
load([indexes])Load the raster array from disk.
outside_image(xi, yj[, index])Check whether a given point falls outside the raster.
polygonize([target_values])Polygonize the raster into a vector.
proximity([vector, target_values, ...])Compute proximity distances to the raster target pixels, or to a vector geometry on the raster grid.
raster_equal(other)Check if two rasters are equal.
reproject([dst_ref, dst_crs, dst_size, ...])Reproject raster to a different geotransform (resolution, bounds) and/or coordinate reference system (CRS).
save(filename[, driver, dtype, nodata, ...])Write the raster to file.
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])Shift the raster by a (x,y) offset.
show([index, cmap, vmin, vmax, alpha, ...])Plot the raster, with axes in projection of image.
split_bands([copy, subset])Split the bands into separate rasters.
subsample(subsample[, return_indices, ...])Randomly subsample the raster.
to_points([subset, as_array, pixel_offset])Convert raster to points.
to_rio_dataset()Export to a Rasterio in-memory dataset.
to_vcrs(dst_vcrs[, src_vcrs])Convert the DEM to another vertical coordinate reference system.
to_xarray([name])Convert raster to a xarray.DataArray.
value_at_coords(x, y[, latlon, index, ...])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
boundsBounding coordinates of the raster.
Compound horizontal and vertical coordinate reference system of the DEM.
countCount of bands loaded in memory if they are, otherwise the one on disk.
count_on_diskCount of bands on disk if it exists.
crsCoordinate reference system of the raster.
dataArray of the raster.
datetimedriverDriver used to read a file on disk.
dtypesData type for each raster band (string representation).
heightHeight of the raster in pixels.
indexesIndexes of bands loaded in memory if they are, otherwise on disk.
indexes_on_diskIndexes of bands on disk if it exists.
is_loadedWhether the raster array is loaded.
is_modifiedWhether the array has been modified since it was loaded from disk.
nameName of the file on disk, if it exists.
nodataNodata value of the raster.
productresResolution (X, Y) of the raster in georeferenced units.
satellitesensorshapeShape (i.e., height, width) of the raster in pixels.
tile_nametransformGeotransform of the raster.
Vertical coordinate reference system of the DEM.
vcrs_gridGrid path of vertical coordinate reference system of the DEM.
vcrs_nameName of vertical coordinate reference system of the DEM.
versionwidthWidth of the raster in pixels.
- The DEM has a single main attribute in addition to that inherited from