Access Individual Geometry Columns | teradataml GeoDataFrameColumn | Vantage - Access Individual Geometry Columns - Teradata Package for Python

Teradata® Package for Python User Guide

Product
Teradata Package for Python
Release Number
17.10
Published
May 2022
Language
English (United States)
Last Update
2022-08-18
dita:mapPath
rsu1641592952675.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

GeoDataFrame object can have non-geometry columns and at least one geometry column. Similar to teradataml DataFrame, teradataml GeoDataFrame allows user to access individual columns in a using df_object.<column_name>.

The following are two ways to access individual geometry columns in a GeoDataFrame.

Access columns similar to teradataml DataFrame column access

A GeoDataFrame can contain multiple columns with Geospatial data.

In the following example, GeoDataFrame contains two columns with geometry type 'geom_col1' and 'geom_col1'. The following shows how to access geometry columns.

  • Create GeoDataFrame on a table containing Geospatial data.
    geoDF = GeoDataFrame("sample_shapes")
  • Access column 'geom_col1'.
    The following function returns an object of class GeoDataFrameColumn.
    geoDF.geom_col1  
  • Access column 'geom_col2'.
    geoDF.geom_col2

Access using 'geometry' property

The most generic way to access the geometry data in any GeoDataFrame is using the 'geometry' property of a GeoDataFrame. This property always points to a column containing geometry data. Regardless of the column name, user can access the column with this property.

  • If GeoDataFrame contains multiple columns with Geospatial data, then 'geometry' property points to only one of the columns.

    When GeoDataFrame is created, 'geometry' property automatically refers to the first geometry column encountered in the GeoDataFrame.

  • User is allowed to set the 'geometry' property to point to another column of teradatasqlalchemy type Geometry in the same GeoDataFrame.

A GeoDataFrame can contain multiple columns with Geospatial data. In the following example, there are two columns with geometry type 'geom_col1' and 'geom_col1'. The following shows how to access geometry column, using 'geometry' property.

  • Create GeoDataFrame on a table containing Geospatial data.
    geoDF = GeoDataFrame("sample_shapes")
  • Access the geometry data in GeoDataFrame using 'geometry' property.
    This returns an object of class GeoDataFrameColumn for one of the column 'geom_col1' or 'geom_col2'.
    geoDF.geometry
  • To identify the name of the column the 'geometry' property points to, use 'name' property of GeoDataFrameColumn.
    geoDF.geometry.name
    If it returns 'geom_col1', that means geoDF.geometry is same as geoDF.geom_col1.
  • User can change the geometry column to point to a different column.
    For example, run the following command to point to 'geom_col2'.
    geoDF.geometry = "geom_col2"