Filtering using Geospatial Functions | Teradata Vantage - Use Case 3: Filtering using Geospatial Functions - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-09
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

User can run Geospatial functions to filter the data.

In the following example, there are two tables: 'sample_cities' and 'sample_streets'. Both contain a geometry column 'cityShape' and 'streetShape' respectively. The following steps return the street name and city name, if 'cityShape' contains a 'streetShape'.

# Create GeoDataFrame on tables containing Geospatial data.
cities = GeoDataFrame("sample_cities")
streets = GeoDataFrame("sample_streets")
# First we must perform cross join between the two GeoDataFrames.
city_streets = cities.join(streets, how="cross")
# Apply slice filter and invoke Geospatial function contains in the filter and use the same as predicate.
city_streets[city_streets.cityShape.contains(city_streets.streetShape) == 1].select("streetName", "cityName")
# Slice filtering with Geometry Type object passed for comparison.
# Create a LineString object.
line_object = LineString([(2,2), (3,2), (4,1)])
streets[streets.streetShape == line_object]
  • User can use 'city_streets.geometry' property to invoke GeoDataFrameColumn method instead of 'city_streets.cityShape', if geometry points to 'cityShape'.
  • User can pass column name as string, that is, 'streetShape' instead of GeoDataFrameColumn object of the column.