geolime.operations.grid.geometry_calculations

Classes:

BlockModel(data, metadata)

Polygon(data, metadata)

SortingRank(value)

An enumeration.

StatKind(value)

An enumeration.

Surface(data, mesh, metadata)

Data:

List

The central part of internal API.

Functions:

check_grid_above_surf(bm, surface, …)

Write in a dataframe for each block if above or under a surface

create_mplcontour_from_grid(bm, column[, …])

Creates a matplotlib contour from a bm and a property.

df_xy_to_arr2d(bm[, attribute])

Take x,y,z column of bm to make a 2D array, with attribute as values.

extend_grid_2d(bm, extension)

Extends a regular 2d bm with a given extension.

flatten_grid(bm[, sorting_type])

Flatten a DataFrame that has many rows with same (x,y).

gdf_from_image(image, pixel_resolution, origin)

Transform image (numpy 2D array) into a geopandas dataframe.

guess_dx_dy(x_array[, y_array, z_array])

Return the dx,dy of a grid guess from the x,y values

polygon_from_bm(bm, column, crs[, classes, …])

Creates Polygon object from a 3D BlockModel, a property, a CRS, and list of thresholds (ie: cut off grades).

vertical_intersection(x, y, surface)

Compute the z coordinates of the vertical intersection between a Trimesh triangulated mesh and a (x,y) coordinates.

geolime.operations.grid.geometry_calculations.check_grid_above_surf(bm: geolime.objects.blockmodel.BlockModel, surface: geolime.objects.surface.Surface, new_column_name: str)

Write in a dataframe for each block if above or under a surface

Parameters
  • bm (BlockModel) – GeoLime 2 dimensions BlockModel object

  • surface (Surface) – GeoLime surface Object

  • new_column_name (str) – Name of the created column, eg : above_surface

Returns

bm – GeoLime 2 dimensions BlockModel object with new column filled with 1 if block is above surface and 0 if under surface

Return type

Grid2d

geolime.operations.grid.geometry_calculations.create_mplcontour_from_grid(bm: geolime.objects.blockmodel.BlockModel, column: str, sorting_type: geolime.enumerator.enumerator.SortingRank = <SortingRank.ASCENDING: 'ASCENDING'>, single_line: int = -1)

Creates a matplotlib contour from a bm and a property. Returns a matplotlib contour with as many contours as the number of values of the property If a number if specified for single_line the contour created will have only one contour corrresponding to a threshold set by the number SortingRank is used to specify how property values are ranked : grade values are ranked in ascending order, but classification values are ranked in descending order (4 is worse, 1 is better)

Parameters
  • bm (BlockModel) – GeoLime 3 dimensions BlockModel object

  • column (str) – Property name used for creating the contour

  • sorting_type (SortingRank, optional) – Type of how the values are ranked : - SortingRank.ASCENDING : ascending order taken (eg : grade) - SortingRank.DESCENDING : descending order taken (eg : classification)

  • single_line (int, optional) – Threshold value

Returns

contour – Matplotlib contour

Return type

matplotlib.contour.QuadContourSet

geolime.operations.grid.geometry_calculations.gdf_from_image(image: numpy.ndarray, pixel_resolution: List[float], origin: List[float], crs: str = None)

Transform image (numpy 2D array) into a geopandas dataframe. Use rasterio in order to extract feature from the image. Pixel resolutionm orign coordinates and crs are used in order to compute true locations of output polygons.

Parameters
  • image (np.ndarray) – 2D array

  • pixel_resolution (List[float]) – [x_size, y_size] pixel size

  • origin (List[float]) – [x,y] Location of bottom left pixel

  • crs (str, optional) – Coordinates Reference System

Returns

Geopandas Dataframe with extracted polygons

Return type

gpd.GeoDataFrame

geolime.operations.grid.geometry_calculations.polygon_from_bm(bm: geolime.objects.blockmodel.BlockModel, column: str, crs: str, classes: List = None, sorting_type: geolime.enumerator.enumerator.SortingRank = <SortingRank.ASCENDING: 'ASCENDING'>)

Creates Polygon object from a 3D BlockModel, a property, a CRS, and list of thresholds (ie: cut off grades). Classes is used to transform continuous information into categorical ones. If None, it takes existing values. SortingRank is used to specify how property values are ranked : grade values are ranked in ascending order, but classification values are ranked in descending order (4 is worse, 1 is better)

Parameters
  • bm (BlockModel) – GeoLime 3 dimensions BlockModel object

  • column (str) – Property name used for creating the contour

  • crs (str) – Coordinates Reference System

  • classes (List, None) – List of thresholds used for polygons

  • sorting_type (SortingRank, optional) – Type of how the values are ranked : - SortingRank.ASCENDING : ascending order taken (eg : grade) - SortingRank.DESCENDING : descending order taken (eg : classification)

Returns

Deeplime Polygon object

Return type

Polygon