Teradata Package for Python Function Reference | 17.10 - mbr_filter - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the 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
lifecycle
previous
Product Category
Teradata Vantage
teradataml.geospatial.geodataframecolumn.GeoDataFrameColumn.mbr_filter = mbr_filter(self, geom_column)
DESCRIPTION:
    Tests whether the MBRs of two 2D geometries spatially intersect.
 
PARAMETERS:
    geom_column:
        Required Argument.
        Specifies a 2D Geometry.
        Types: str, ColumnExpression, GeometryType
 
SUPPORTED GEOMETRY TYPES:
    All 2D Geometry types.
    Although mbr_filter() will accept 3D geometries, the Z coordinates
    are ignored in the calculations.
 
RAISES:
    TypeError, ValueError, TeradataMlException
 
RETURNS:
    GeoDataFrameColumn
    Resultant column contains:
        * 1, if the MBR of the input geometry intersects the
          MBR of the geometry passed to the method.
        * 0, if the MBR of the input geometry does not intersect
          the MBR of the geometry passed to the method.
 
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)
    
    # Let's select only few columns from GeoDataFrame.
    points_lines = geodf[geodf.skey.isin([1004, 1005, 1006])].select(["skey", "points", "linestrings"])
 
    # Example 1: Check whether MBRs of geometries in column 'points' and 'lienstrings'
    #            spatially intersect or not.
    points_lines.assign(res = points_lines.points.mbr_filter(points_lines.linestrings))
 
    # Example 2: Get all rows where MBRs of geometries in column 'linestrings' and GeometryType object
    #            Linestring spatially intersect.
    # Create an object of Linestring GeometryType.
    l1 = LineString([(1,3,6), (3,0,6), (6,0,1)])
    # Pass the LineString() GeometryType object as input to "geom_column" argument.
    points_lines[points_lines.linestrings.mbr_filter(l1) == 1]