Oracle Spatial Based Analysis
Spatial AI provides a basic Python API for geometry data in Oracle Spatial database.
This enables Spatial database-based analysis using the Python API provided by
            the oraclesai.data package which is implemented in the
                SpatialDataFrame class. It provides data access to Oracle
            Spatial and also data processing functionalities from Oracle Spatial.
               
These analyses include basic spatial operations, such as geometry computation, spatial query, aggregation, summary, join, and optimization. They are provided by Python calls to the Oracle Spatial database, which also enables in-database processing.
If the dataset is from the database, then the methods of the
                SpatialDataFrame class will push all the operations to Oracle
            Spatial and do in-database processing. Otherwise, all the operations are executed in
            memory.
               
The following table describes some of the techniques for spatial analysis.
| Operation | Description | 
|---|---|
| aggregate | Operation is executed over columns, and the supported functions are count,avg,sum,
                            andmbr. The result is aSpatialDataFrameobject. | 
| area | Returns a new SpatialDataFrameinstance
                            containing the areas of each geometry. | 
| buffer | Constructs a buffer around each geometry. The result contains the same rows and columns but with the geometry buffered. | 
| combine | Combines the geometries from the current SpatialDataFrameinstance with the geometries
                            from the parametertgt. The result is aSpatialDataFrameobject with the combined
                            geometries. | 
| crs | Returns the coordinate reference system associated to the geometry. | 
| groupby | Involves splitting a SpatialDataFrameobject by
                            the given criteria, applying a function, and combining the
                            results. | 
| length | Returns a new SpatialDataFrameobject with the
                            lengths of the geometries. | 
| merge | Joins two instances of SpatialDataFrameby
                            comparing the joining keys. The result is anotherSpatialDataFramewith columns from both the
                            instances. It allows to specify the joining keys and how the join is
                            executed. It is also possible to define the geometry column for the
                            resulting object. | 
| nearest_neighbors | Returns a SpatialDataFrameobject with
                            observations that are closer to a given location, which can be either a
                            shapely geometry or another instance ofSpatialDataFrame. For the latter, the result
                            will contain observations containing information from bothSpatialDataFrameobjects. | 
| relate | Executes a primary spatial filter based on a specified
                            spatial operator from { anyinteract,inside,contains,equal,coveredby,on,covers,overlapbyintersect,overlapbydisjoint}. It returns a newSpatialDataFrameinstance. | 
| spatial_join | Joins two instances of
                                     
 The resulting object contains data from both input objects and the geometry from the calling instance is used as the geometry in the result. | 
| total_bounds | The total_boundsproperty calculates the minimum
                            bounding rectangle enclosing all the data. It returns the result as a
                            tuple with the following elements(min_x, min_y, max_x,
                                max_y). | 
| to_crs | Returns a new SpatialDataFrameobject with the geometries in the specified CRS | 
| within_distance | Returns a SpatialDataFrameobject containing
                            only observations located within a certain distance from a query window
                            specified as a shapely query window or another. | 
| distance | Returns a new SpatialDataFramewith the distance
                            between the geometries of the current instance and the parameterqry_win. | 
See the SpatialDataFrame class in Python API Reference for Oracle Spatial AI for more information.
The following example creates an instance of SpatialDataFrame
            containing the name and location of schools in Los Angeles. It uses a
                    DBSpatialDataset to get the data from the
                    schools table.
               
import oml
from oraclesai import SpatialDataFrame, DBSpatialDataset
schools = SpatialDataFrame.create(DBSpatialDataset(table='schools', schema='oml_user'))Then, using the block_groups
                  SpatialDataFrame, the within_distance and the
                groupby operations, the example computes the number of schools
            within two kilometers of each block group, and stores the result in another
                SpatialDataFrame. The index comes from the column
                    GEOID.
               
schools_counts = block_groups.within_distance(schools, distance=2000).groupby('GEOID').aggregate(count={'GEOID': 'SCHOOLS_COUNT'})
print(schools_counts["SCHOOLS_COUNT"])By printing the resulting SpatialDataFrame, note the
                    SCHOOLS_COUNT column, which indicates the number of
            schools within two kilometers from a block group.
               
      SCHOOLS_COUNT                                           geometry
0                 5  POLYGON ((-118.29131 34.26285, -118.29132 34.2...
1                 5  POLYGON ((-118.30075 34.25961, -118.30229 34.2...
2                 4  POLYGON ((-118.30076 34.26321, -118.30075 34.2...
3                 4  POLYGON ((-118.30320 34.27333, -118.30275 34.2...
4                 5  POLYGON ((-118.29069 34.27071, -118.29078 34.2...
...             ...                                                ...
3412             15  POLYGON ((-118.34312 33.99558, -118.34343 33.9...
3413             13  POLYGON ((-118.34930 33.99942, -118.34929 33.9...
3414             14  POLYGON ((-118.34432 33.99074, -118.34486 33.9...
3415             26  POLYGON ((-118.25165 34.08038, -118.25124 34.0...
3416             22  POLYGON ((-118.51849 34.18498, -118.51849 34.1...