Methods | teradataml GeoDataFrame | Teradata Vantage - GeoDataFrame Methods - 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

The following tables list methods of teradataml GeoDataFrame. For more details and examples, see Teradata Package for Python Function Reference on VantageCloud Lake.

MBB and MBR are only supported on the Block File System on the primary cluster. They are not available for the Object File System.

Generic Usage: Single Geospatial Function Usage

# Create GeoDataFrame on a table containing Geospatial data.
geoDF = GeoDataFrame("sample_shapes")
# Assumption:
#   geoDF.geometry points to "geom_col1"
 
# Invoke "intersects" function on GeoDataFrame and pass the argument as ColumnExpression a.k.a. GeoDataFrameColumn object of a column 'geom_col2'.
geoDF.intersects(geoDF.geom_col2)
#   where,
#       geoDF.geom_col2 is a ColumnExpression, i.e., GeoDataFrameColumn object for 'geom_col2'.
 
# Instead of passing GeoDataFrameColumn object for 'geom_col2', user can pass the column name as is.
geoDF.intersects("geom_col2")

Methods inherited from teradataml DataFrame

Method Method Signature Purpose Return
__init__ __init__(self, table_name=None, index=True, index_label=None, query=None, materialize=False) Constructor for teradataml GeoDataFrame. teradataml GeoDataFrame
from_table from_table(cls, table_name, index=True, index_label=None) Class method for creating a GeoDataFrame from a table or a view. teradataml GeoDataFrame
from_query from_query(cls, query, index=True, index_label=None, materialize=False) Class method for creating a GeoDataFrame using a query. teradataml GeoDataFrame
__getattr__ __getattr__(self, name) Return an attribute of the GeoDataFrame. Return the value of the named attribute of object (if found).
__getitem__ __getitem__(self, key) Return a column from the GeoDataFrame or filter the GeoDataFrame using an expression.
The following operators are supported:
  • comparison: ==, !=, <, <=, >, >=
  • boolean: & (and), | (or), ~ (not), ^ (xor)

Operands can be Python literals and instances of ColumnExpressions from the GeoDataFrame.

GeoDataFrame or ColumnExpression instance
assign assign(self, drop_columns = False, **kwargs) Assign new columns to a teradataml GeoDataFrame. teradataml GeoDataFrame
A new GeoDataFrame is returned with:
  • New columns in addition to all the existing columns if "drop_columns" is False.
  • Only new columns if "drop_columns" is True.
  • New columns in addition to group by columns, i.e., columns used for grouping, if assign() is run on GeoDataFrame.groupby().
concat concat(self, other, join='OUTER', allow_duplicates=True, sort=False, ignore_index=False) Concatenates two teradataml GeoDataFrames along the index axis. teradataml GeoDataFrame
drop drop(self, labels=None, axis=0, columns=None) Drop specified labels from rows or columns. teradataml GeoDataFrame
dropna dropna(self, how='any', thresh=None, subset=None) Removes rows with null values. teradataml GeoDataFrame
filter filter(self, items = None, like = None, regex = None, axis = 1, **kw) Filter rows or columns of GeoDataFrame according to labels in the specified index.

The filter is applied to the columns of the index when axis is set to 'rows'.

teradataml GeoDataFrame
get get(self, key) Retrieve required columns from GeoDataFrame using column name(s) as key.

Return a new teradataml GeoDataFrame with requested columns only.

teradataml GeoDataFrame
get_values get_values(self, num_rows = 99999) Retrieve all values (only) present in a teradataml GeoDataFrame.

Values are retrieved as per a numpy.ndarray representation of a teradataml GeoDataFrame.

This format is equivalent to the get_values() representation of a Pandas GeoDataFrame.

Numpy.ndarray representation of a teradataml GeoDataFrame
groupby groupby(self, columns_expr) Apply GroupBy to one or more columns of a teradataml GeoDataFrame.

The result will always behaves like calling groupby with as_index=False

in pandas.

teradataml DataFrameGroupBy Object
head head(self, n=display.max_rows) Print the first n rows of the sorted teradataml GeoDataFrame. teradataml GeoDataFrame
info info(self, verbose=True, buf=None, max_cols=None, null_counts=False) Print a summary of the GeoDataFrame. None
join join(self, other, on=None, how="left", lsuffix=None, rsuffix=None) Join two different teradataml GeoDataFrames together based on column comparisons specified in argument 'on' and type of join is specified in the argument 'how'. teradataml GeoDataFrame
keys keys(self) Get the column names of a GeoDataFrame. List containing the column names
merge merge(self, right, on=None, how="inner", left_on=None, right_on=None, use_index=False, lsuffix=None, rsuffix=None) Merge two teradataml GeoDataFrames together. teradataml GeoDataFrame
sample sample(self, n = None, frac = None, replace = False, randomize = False, case_when_then = None, case_else = None) Allow to sample few rows from GeoDataFrame directly or based on conditions.

Create a new column 'sampleid' which has a unique id for each sample sampled, it helps to uniquely identify each sample.

teradataml GeoDataFrame
select select(self, select_expression) Select required columns from GeoDataFrame using an expression.

Return a new teradataml GeoDataFrame with selected columns only.

teradataml GeoDataFrame/DataFrame
set_index set_index(self, keys, drop = True, append = False) Assign one or more existing columns as the new index to a teradataml GeoDataFrame. teradataml GeoDataFrame
show_query show_query(self, full_query = False) Return underlying SQL for the teradataml GeoDataFrame. It is the same SQL that is used to view the data for a teradataml GeoDataFrame. String
sort sort(self, columns, ascending=True) Get sorted data by one or more columns in either ascending or descending order for a GeoDataFrame. teradataml GeoDataFrame
sort_index sort_index(self, axis=0, ascending=True, kind='quicksort') Gets sorted object by labels (along an axis) in either ascending or descending order for a teradataml GeoDataFrame. teradataml GeoDataFrame
squeeze squeeze(self, axis=None) Squeeze one-dimensional axis objects into scalars.
  • teradataml GeoDataFrames with a single element are squeezed to a scalar.
  • teradataml GeoDataFrames with a single column are squeezed to a Series.
  • Otherwise the object is unchanged.

teradataml GeoDataFrame, teradataml Series, or scalar,

the projection after squeezing 'axis' or all the axes.

tail tail(self, n=display.max_rows) Print the last n rows of the sorted teradataml GeoDataFrame. teradataml GeoDataFrame
to_csv to_csv Get the data exported to CSV file. None
to_pandas to_pandas(self, index_column=None, num_rows=99999, all_rows=False, fastexport=False, catch_errors_warnings=False, **kwargs) Return a Pandas GeoDataFrame for the corresponding teradataml GeoDataFrame Object.
When "catch_errors_warnings" is set to True and if protocol used for data transfer is fastexport, then the function returns a tuple containing:
  • Pandas GeoDataFrame.
  • Errors, if any, thrown by fastexport in a list of strings.
  • Warnings, if any, thrown by fastexport in a list of strings.

Only Pandas GeoDataFrame otherwise.

to_sql to_sql(self, table_name, if_exists='fail', primary_index=None, temporary=False, schema_name=None, types = None, primary_time_index_name=None, timecode_column=None, timebucket_duration=None, timezero_date=None, columns_list=None, sequence_column=None, seq_max=None, set_table=False) Write records stored in a teradataml GeoDataFrame to Teradata Vantage. None

Methods specific to Geospatial Data (All Geometry Types)

Method Method Signature Purpose Return
buffer buffer(self, distance) Return all points whose distance from a Geometry value is less than or equal to a specified distance. teradataml GeoDataFrame
contains contains(self, geom_column) Test if a Geometry value spatially contains another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the input geometry contains other geometry
  • 0, if the input geometry does not contain other geometry
crosses crosses(self, geom_column) Test if a Geometry value spatially crosses another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometries cross
  • 0, if the geometries do not cross
difference difference(self, geom_column) Return a Geometry value that represents the point set difference of two Geometry values. teradataml GeoDataFrame
disjoint disjoint(self, geom_column) Test if a Geometry value is spatially disjoint from another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometries are spatially disjoint
  • 0, if the geometries are not spatially disjoint
distance distance(self, geom_column) Return the distance between two Geometry values. teradataml GeoDataFrame
distance_3D distance_3D(self, geom_column) Return the distance between two Geometry values. Function considers Z coordinate values, if they exist in the geometries passed to it. GeoDataFrame
Resultant column contains:
  • a NULL, if the Geometry is an empty set.
  • 0, if the two geometries intersect.
  • a float in all other cases. The distance units are those of the two input geometries.
envelope envelope(self) Return the bounding rectangle for the Geometry value. GeoDataFrame with result column containing Geometry values
geom_equals geom_equals(self, geom_column) Test if a Geometry value is spatially equal to another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometries are spatially equal
  • 0, if the geometries are not spatially equal
intersection intersection(self, geom_column) Return a Geometry type where the value represents the point set intersection of two Geometry values. teradataml GeoDataFrame
intersects intersects(self, geom_column) Test if a Geometry value spatially intersects another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometries intersect
  • 0, if the geometries do not intersect
make_2D make_2D(self, validate=False) Converts a 3D Geometry value to a 2D Geometry value, and optionally validates that the 2D geometry is well-formed. This method strips the z coordinate from 3D geometries. teradataml GeoDataFrame
mbb mbb(self) Return the 3D minimum bounding box (MBB) that encloses a 3D Geometry. teradataml GeoDataFrame
mbr mbr(self) Return the minimum bounding rectangle (MBR) of a Geometry value. teradataml GeoDataFrame
overlaps overlaps(self, geom_column) Test if a Geometry value spatially overlaps another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometries overlap
  • 0, if the geometries do not overlap
relates relates(self, geom_column, amatrix) Test if a Geometry value is spatially related to another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the spatial relationship between the geometries corresponds

    to one of the acceptable values represented by "amatrix"

  • 0, if the spatial relationship between the geometries does not correspond to one of the acceptable values represented by "amatrix"
set_srid set_srid(self, srid) Set the spatial reference system identifier of the Geometry value. GeoDataFrame

Resultant column contains the Geometry with the spatial reference system identifier set to the specified spatial reference system.

simplify simplify(self, tolerance) Simplify a geometry by removing points that would fall within a specified distance tolerance. teradataml GeoDataFrame
sym_difference sym_difference(self, geom_column) Return a Geometry value that represents the point set symmetric difference of two Geometry values. teradataml GeoDataFrame
to_binary to_binary(self) Return the well-known binary (WKB) representation of a Geometry value. GeoDataFrame with result column containing BLOB value
to_text to_text(self) Return the well-known text (WKT) representation of a Geometry value. GeoDataFrame with result column containing CLOB value
touches touches(self, geom_column) Test if a Geometry value spatially touches another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometries touch
  • 0, if the geometries do not touch
transform transform(self, to_wkt_srs, from_wkt_srs, to_srsid=-12345) Return a Geometry value transformed to the specified spatial reference system. teradataml GeoDataFrame
union union(self, geom_column) Return a Geometry value that represents the point set union of two Geometry values. teradataml GeoDataFrame
within within(self, geom_column) Test if a Geometry value is spatially within another Geometry value. GeoDataFrame
Resultant column contains:
  • 1, if the geometry is within other geometry
  • 0, if the geometry is not within other geometry
wkb_geom_to_sql wkb_geom_to_sql(self, column) Return a specified Geometry value. teradataml GeoDataFrame
wkt_geom_to_sql wkt_geom_to_sql(self, column) Return a specified Geometry value. teradataml GeoDataFrame

Methods for Point Geometry

Method Method Signature Purpose Return
spherical_buffer spherical_buffer(self, distance, radius=6371000.0) Return an MBR that represents the minimum and maximum latitude and longitude of all points within a given distance from a point. The earth is modeled as a sphere. teradataml GeoDataFrame
spherical_distance spherical_distance(self, geom_column) Return the spherical distance between two spherical coordinates on the planet using the Haversine Formula. Both coordinates must be specified as ST_Point values. teradataml GeoDataFrame
spheroidal_buffer spheroidal_buffer(self, distance, semimajor=6378137.0, invflattening=298.257223563) Return an MBR that represents the minimum and maximum latitude and longitude of all points within a given distance from the point. The earth is modeled as a spheroid. teradataml GeoDataFrame
spheroidal_distance spheroidal_distance(self, geom_column, semimajor=6378137.0, invflattening=298.257223563) Return the distance, in meters, between two spherical coordinates. teradataml GeoDataFrame
set_x set_x(self, xcoord) Set the X coordinate of an ST_Point value. teradataml GeoDataFrame
set_y set_y(self, ycoord) Set the Y coordinate of an ST_Point value. teradataml GeoDataFrame
set_z set_z(self, zcoord) Set the Z coordinate of an ST_Point value. teradataml GeoDataFrame

Methods for LineString Geometry

Method Method Signature Purpose Return
end_point end_point(self) Return the end point of an ST_LineString or GeoSequence value. GeoDataFrame

Resultant column contains a NULL, if the Geometry is an empty set.

length length(self) Return the length measurement of a Geometry type that represents an ST_LineString, GeoSequence, or ST_MultiLineString value. teradataml GeoDataFrame
length_3D length_3D(self) Return the length of a 3D LineString or MultiLineString, taking into account the Z coordinates in the calculation. GeoDataFrame

Resultant column contains a 0, if the LineString or MultiLineString is an empty set.

line_interpolate_point line_interpolate_point(self, proportion) Return a point interpolated along a Geometry type that represents an ST_LineString or GeoSequence value, given a proportional distance along that line. GeoDataFrame with result column containing ST_Point Geometry values
num_points num_points(self) Return the number of points in a Geometry type that represents an ST_LineString or GeoSequence value. GeoDataFrame

Resultant column contains a NULL, if the Geometry is an empty set.

point point(self, position) Return the specified point from a Geometry type that represents an ST_LineString or GeoSequence value. teradataml GeoDataFrame
start_point start_point(self) Return the start point of an ST_LineString or GeoSequence value.
This method returns a point having a Z coordinate if the input geometry is three-dimensional.
teradataml GeoDataFrame

Methods for Polygon Geometry

Method Method Signature Purpose Return
interiors interiors(self, position) Return the specified interior ring of a Geometry type that represents an ST_Polygon value. GeoDataFrame with result column containing ST_LineString Geometry values
num_interior_ring num_interior_ring(self) Return the number of interior rings of a Geometry type that represents an ST_Polygon value. teradataml GeoDataFrame
point_on_surface point_on_surface(self) Return a point that is guaranteed to spatially intersect an ST_Polygon, or at least one of the component polygons of an ST_MultiPolygon. teradataml GeoDataFrame

Methods for GeometryCollection Geometry

Method Method Signature Purpose Return
geom_component geom_component(self, position) Return the geometry of one component member of a composite geometry type (ST_GeomCollection, ST_MultiPoint, ST_MultiLineString, or ST_MultiPolygon). The element to be returned is specified by position with the collection. teradataml GeoDataFrame
num_geometry num_geometry(self) Return the number of distinct geometries that constitute a composite geometry type (ST_GeomCollection, ST_MultiPoint, ST_MultiLineString, or ST_MultiPolygon). teradataml GeoDataFrame

Methods for GeoSequence Geometry

Method Method Signature Purpose Return
clip clip(self, start_timestamp, end_timestamp) Return a GeoSequence type containing the subset of points and associated data that lie between the two timestamp input arguments. teradataml GeoDataFrame
get_final_timestamp get_final_timestamp(self) Return the TimeStamp of the last point of a GeoSequence. teradataml GeoDataFrame
get_init_timestamp get_init_timestamp(self) Return the TimeStamp of the first point of a GeoSequence. teradataml GeoDataFrame
get_link get_link(self, index) Get the link ID of a specified point in a GeoSequence. teradataml GeoDataFrame
get_user_field get_user_field(self, field_index, index) Return the user field specified by "field_index" for the point specified by "index" for a GeoSequence type. teradataml GeoDataFrame
get_user_field_count get_user_field_count(self) Return the number of user fields associated with each point of a GeoSequence. teradataml GeoDataFrame
point_heading point_heading(self, index) Return the heading for the specified point of a GeoSequence.

The value is calculated as the angle (in degrees) between a vertical line and the line segment from the specified point to the next point clockwise from the North.

teradataml GeoDataFrame
set_link set_link(self, index, link_id) Set the link ID of a specified point in a GeoSequence. teradataml GeoDataFrame
speed speed(self, index=None, begin_index=None, end_index=None) Return the approximate speed at a specified point (speed(index INTEGER)) or between two points (speed(iBegin INTEGER, iEnd INTEGER)) for a GeoSequence type. teradataml GeoDataFrame

Filtering Functions and Methods

Method Method Signature Purpose Return
intersects_mbb intersects_mbb(self, geom_column) Test whether a 3D geometry spatially intersects a specified MBB. GeoDataFrame
Resultant column contains:
  • 1, if the input 3D geometry intersects the MBB argument.
  • 0, if the input 3D geometry does not intersect the MBB argument.
  • Return an error if the input geometry is not 3D (does not have a z coordinate).
mbb_filter mbb_filter(self, geom_column) Test whether the MBBs of two 3D geometries spatially intersect. GeoDataFrame
Resultant column contains:
  • 1, if the MBB of the input 3D geometry intersects the MBB of the geometry passed to the method.
  • 0, if the MBB of the input 3D geometry does not intersect the MBB of the geometry passed to the method.
  • Return an error if either geometry is not 3D (does not have a z coordinate).
mbr_filter mbr_filter(self, geom_column) Test whether the MBRs of two 2D geometries spatially intersect. GeoDataFrame
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.
within_mbb within_mbb(self, geom_column) Test whether a 3D geometry is spatially within the bounds of a specified MBB. GeoDataFrame
Resultant column contains:
  • 1, if the input 3D geometry is spatially within MBB argument.
  • 0, if the input 3D geometry is not spatially within the MBB argument.
  • Return an error if the input geometry is not 3D (does not have a z coordinate).