oraclesai.SpatialDataFrame
- class SpatialDataFrame(dataset: SpatialDataset)
A pandas-like interface for handling spatial vector data as if the data were in memory regardless of the data location.
An instance of
SpatialDataFrame
is created using the create method.The create method takes in an instance of
oraclesai.SpatialDataset
which is used to describe the dataset to be associated to the proxy.The following example shows how to create a SpatialDataFrame for a spatial table in Oracle database.
>>> from oraclesai import SpatialDataFrame, DBSpatialDataset >>> dataset = DBSpatialDataset(cursor=oracledb_cursor, table='chicago_accidents') >>> sdf = SpatialDataFrame.create(dataset) >>> sdf.head() OGR_FID REPORT_TYP geometry 0 657 ON SCENE POINT (-9755760.901 5133215.436) 1 659 ON SCENE POINT (-9758088.412 5156991.966) 661 NOT ON SCENE (DESK REPORT) POINT (-9758162.478 5125561.017)
More
SpatialDataset
implementations can be used to load data from Oracle Object Storage, local files, and from an existinggeopandas.GeoDataFrame
.Once an instance of
SpatialDataFrame
has been created, it can be used to apply spatial transformations. If the data is located in Oracle database, The in-database Oracle Spatial engine will be used to perform spatial operations.A
SpatialDataFrame
is immutable so each transformation will result in a new instance ofSpatialDataFrame
.When a
SpatialDataFrame
is created for data residing in Oracle database, the data is downloaded (materialized) until it is needed in memory, for example, when it is transformed to ageopandas.GeoDataFrame
by callingoraclesai.SpatialDataFrame.as_geodataframe()
ororaclesai.SpatialDataFrame.head()
, or when the data is written to another source such as Oracle Object Storage or to a file system using the methodoraclesai.SpatialDataFrame.write()
.Methods
__init__
(dataset)add_column
(column_name, series)Add series as a new column to the current proxy.
area
([tolerance, area_col])Get the area for each geometry from the current SpatialDataFrame.
Convert the current SpatialDataFrame to
geopandas.GeoDataFrame
.Transform the current SpatialDataFrame to an instance of
oml.DataFrame
buffer
(distance)Construct a buffer around each geometry.
combine
(tgt[, combine_op, tolerance, how, ...])Combines the geometries from the current SpatialDataFrame with the geometries in tgt.
create
(dataset)Creates a SpatialDataFrame instance based on the dataset type.
distance
(qry_win[, distance_col, tolerance, ...])Get the distance between the geometries from the current SpatialDataFrame and qry_win.
drop
(columns)Return a new SpatialDataFrame without the columns specified by the columns parameter.
dropna
()Remove rows containing missing values.
filter
(qry_win[, tolerance])Executes a primary spatial filter on a SpatialDataFrame.
get_max_scored_class
(*args)get_values
([include_geometry])Return the content of the SpatialDataFrame as numpy array.
groupby
(by)Group data by one or more columns.
head
([n])Return the first n rows from the referenced data.
iterrows
([chunk_size])Iterates through all the rows of the current instance.
length
([tolerance, length_col])Computes the length of each geometry from the current SpatialDataFrame.
merge
(right[, how, on, left_on, right_on, ...])Join two SpatialDataFrame objects by comparing the given joining keys.
merge_oml_dataframe
(oml_df[, on, left_on, ...])Merge the current SpatialDataFrame with an existing
oml.DataFrame
based on a key.nearest_neighbors
(qry_win[, num_neighbors, ...])Returns a SpatialDataFrame containing records which are closer to a given location specified as a shapely geometry or another SpatialDataFrame.
plot
(**plot_geometries_extra_kwargs)Plot a SpatialDataFrame using matplolib.
relate
(qry_win[, mask, tolerance, ...])Perform spatial filtering using the specified spatial operator.
replace
(to_replace, values)sort_values
(by[, ascending])Returns a SpatialDataFrame sorted by the values of the columns specified.
tail
([n])Return the last n rows from the referenced data.
to_crs
(crs)Return a new SpatialDataFrame containing the geometries in the specified CRS.
within_distance
(qry_win, distance[, ...])Returns a SpatialDataFrame containing only records which are within a certain distance from a query window specified as a shapely query window or another SpatialDataFrame.
write
(dataset[, if_exists, ...])Writes the current SpatialDataFrame data into the destination specified by the dataset argument.
Attributes
Return a list of column names.
Return the coordinate reference system associated to the geometry layer.
Dimensionality of the SpatialDataFrame.
Calculate the minimum bounding rectangle enclosing all the data.