Teradata Package for Python Function Reference | 17.10 - within - 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.geodataframe.GeoDataFrame.within = within(self, geom_column)
- DESCRIPTION:
Tests if a Geometry value is spatially within another Geometry value.
Note:
* Using a geospatial index can greatly improve the performance of
queries that use this method.
PARAMETERS:
geom_column:
Required Argument.
Specifies the other Geometry value.
Types: str, ColumnExpression, GeometryType
SUPPORTED GEOMETRY TYPES:
All Geometry types except geometry collections.
Note:
This method can be called on 3D geometries (those that include Z
coordinates). However, the Z coordinate is ignored in method
calculations.
RAISES:
TypeError, ValueError, TeradataMlException
RETURNS:
GeoDataFrame
Resultant column contains:
* 1, if the geometry is within other geometry
* 0, if the geometry is not within other geometry
EXAMPLES:
from teradataml import GeoDataFrame, load_example_data
from teradataml import Point, LineString, Polygon
# 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.
pols_lines = geodf.select(["skey", "polygons", "linestrings"])
# Example 1: Check whether geometries in column 'linestrings' is spatially within
# the geometries in column 'polygons'.
# Set the geometry property of GeoDataFrame to point to 'linestrings' column.
pols_lines.geometry = pols_lines.linestrings
pols_lines.within(geom_column=pols_lines.polygons)
# Example 2: Check whether geometries in column 'linestrings' is spatially within
# the geometries specified by Polygon geometry type.
# Create an object of Polygon GeometryType.
po1 = Polygon([(0, 0), (0, 20), (20, 20), (20, 0), (0, 0)])
# Pass the Polygon() GeometryType object as input to "geom_column" argument.
pols_lines.within(geom_column=po1)