gemgis.raster.sample_interfaces#

gemgis.raster.sample_interfaces(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, point_x: Union[float, int, list, numpy.ndarray] = None, point_y: Union[float, int, list, numpy.ndarray] = None, random_samples: int = None, formation: str = None, seed: int = None, sample_outside_extent: bool = False, crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None) geopandas.geodataframe.GeoDataFrame#

Sampling interfaces from a raster

Parameters
  • raster (Union[np.ndarray, rasterio.io.DatasetReader) – Raster or arrays from which points are being sampled

  • extent (List[Union[int, float]]) – List containing the extent of the raster (minx, maxx, miny, maxy), e.g. extent=[0, 972, 0, 1069]

  • point_x (Union[float, int, list, np.ndarray]) – Object containing the x coordinates of a point or points at which the array value is obtained, e.g. point_x=100, default is None

  • point_y (Union[float, int, list, np.ndarray]) – Object containing the y coordinates of a point or points at which the array value is obtained, e.g. point_y=100, default is None

  • random_samples (int) – Number of random samples to be drawn, e.g. random_samples=10, default is None

  • formation (str) – Name of the formation the raster belongs to, e.g. formation='Layer1', default is None

  • seed (int) – Integer to set a seed for the drawing of random values, e.g. seed=1, default is None

  • sample_outside_extent (bool) – Allow sampling outside the extent of the rasterio object. Options include: True or False, default is False

  • crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – Coordinate reference system to be passed to the GeoDataFrame upon creation, e.g. crs='EPSG:4647

Returns

gdf – GeoDataFrame containing the sampled interfaces

Return type

gpd.geodataframe.GeoDataFrame

New in version 1.0.x.

Example

>>> # Loading Libraries and File
>>> import gemgis as gg
>>> import rasterio
>>> raster = rasterio.open(fp='raster.tif')
>>> # Sampling interfaces from an array or rasterio object
>>> gdf = gg.raster.sample_interfaces(raster=raster, point_x=500, point_y=500)
>>> gdf
    X       Y       Z       geometry
0   500.00  500.00  561.65  POINT (500.000 500.000)

See also

sample_from_array

Sample values from NumPy array

sample_from_rasterio

Sample values from rasterio object

sample_randomly

Sample randomly from rasterio object or NumPy array

sample_orientations

Sample orientations from raster