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

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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.