Teradata Package for Python Function Reference | 17.10 - within_mbb - Teradata Package for Python
Teradata® Package for Python Function Reference
- Product
- Teradata Package for Python
- Release Number
- 17.10
- Published
- April 2022
- Language
- English (United States)
- Last Update
- 2022-08-19
- Product Category
- Teradata Vantage
- teradataml.geospatial.geodataframecolumn.GeoDataFrameColumn.within_mbb = within_mbb(self, geom_column)
- DESCRIPTION:
Tests whether a 3D geometry is spatially within the bounds of a
specified MBB.
PARAMETERS:
geom_column:
Required Argument.
Specifies a minimum bounding box.
Types: str, ColumnExpression, GeometryType
SUPPORTED GEOMETRY TYPES:
All 3D Geometry types.
RAISES:
TypeError, ValueError, TeradataMlException
RETURNS:
GeoDataFrameColumn
Resultant column contains:
* 1, if the input 3D geometry is spatially within MBB argument.
* 0, if the input 3D geometry is not spatially within the MBB
argument.
* Returns an error if the input geometry is not 3D (does not
have a z coordinate).
EXAMPLES:
from teradataml import GeoDataFrame, load_example_data
from teradataml import Point, LineString, Polygon, GeometryCollection
# Load example data.
load_example_data("geodataframe", "sample_shapes")
# Create a GeoDataFrame.
geodf = GeoDataFrame("sample_shapes")
print(geodf)
# Example 1: Check whether the geometries in column 'points' is within the
# specified MBB geometries or not.
# Let's select only few columns from GeoDataFrame and filter only 3D rows.
geodfmbb = geodf.select(["skey", "points"]).mbb()[geodf.points.is_3D == 1]
# Join the GeoDataFrameColumn with self.
geodfmbb = geodfmbb.join(geodfmbb, how="cross", lsuffix="l", rsuffix="r")
geodfmbb.assign(res = geodfmbb.l_points.within_mbb(geom_column=geodfmbb.r_mbb_points_geom))
# Example 1: Filter all rows where the geometries in column 'points' is within the
# specified MBB geometry.
geodfmbb[geodfmbb.l_points.within_mbb(geom_column=geodfmbb.r_mbb_points_geom) == 1]