You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2024/04/29 07:47:23 UTC

(sedona) branch SEDONA-551 created (now 5975d8ac2)

This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a change to branch SEDONA-551
in repository https://gitbox.apache.org/repos/asf/sedona.git


      at 5975d8ac2 Initial upgrade

This branch includes the following new commits:

     new 5975d8ac2 Initial upgrade

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(sedona) 01/01: Initial upgrade

Posted by ji...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch SEDONA-551
in repository https://gitbox.apache.org/repos/asf/sedona.git

commit 5975d8ac209a1b4288bc9e9250ef537a6d5a6cb0
Author: Jia Yu <ji...@apache.org>
AuthorDate: Mon Apr 29 00:47:13 2024 -0700

    Initial upgrade
---
 .github/workflows/java.yml                         | 20 +++++---------
 .github/workflows/python.yml                       |  2 +-
 .github/workflows/r.yml                            |  2 +-
 .../apache/sedona/common/FunctionsGeoTools.java    | 10 +++----
 .../sedona/common/raster/GeometryFunctions.java    |  8 +++---
 .../sedona/common/raster/PixelFunctionEditors.java |  9 +++----
 .../sedona/common/raster/PixelFunctions.java       | 11 ++++----
 .../sedona/common/raster/RasterAccessors.java      |  8 +++---
 .../sedona/common/raster/RasterBandAccessors.java  |  2 +-
 .../sedona/common/raster/RasterBandEditors.java    |  6 ++---
 .../sedona/common/raster/RasterConstructors.java   | 28 +++++++++----------
 .../raster/RasterConstructorsForTesting.java       |  6 ++---
 .../apache/sedona/common/raster/RasterEditors.java | 22 +++++++--------
 .../apache/sedona/common/raster/RasterOutputs.java |  6 ++---
 .../sedona/common/raster/RasterPredicates.java     | 12 ++++-----
 .../sedona/common/raster/netcdf/NetCdfReader.java  |  4 +--
 .../sedona/common/raster/serde/CRSSerializer.java  |  4 +--
 .../apache/sedona/common/raster/serde/Serde.java   |  2 +-
 .../common/utils/CachedCRSTransformFinder.java     |  6 ++---
 .../apache/sedona/common/utils/RasterUtils.java    | 23 ++++++++--------
 .../org/apache/sedona/common/FunctionsTest.java    |  4 +--
 .../sedona/common/raster/FunctionEditorsTest.java  |  4 +--
 .../apache/sedona/common/raster/FunctionsTest.java |  4 +--
 .../common/raster/GeometryFunctionsTest.java       |  4 +--
 .../sedona/common/raster/MapAlgebraTest.java       |  2 +-
 .../sedona/common/raster/RasterAccessorsTest.java  |  4 +--
 .../common/raster/RasterBandAccessorsTest.java     |  4 +--
 .../common/raster/RasterBandEditorsTest.java       |  4 +--
 .../common/raster/RasterConstructorsTest.java      | 12 ++++-----
 .../sedona/common/raster/RasterEditorsTest.java    | 22 +++++++--------
 .../sedona/common/raster/RasterOutputTest.java     |  2 +-
 .../sedona/common/raster/RasterPredicatesTest.java |  8 +++---
 .../sedona/common/raster/RasterTestBase.java       | 31 +++++++++++-----------
 .../common/raster/serde/CRSSerializerTest.java     |  4 +--
 .../sedona/common/raster/serde/SerdeTest.java      |  2 +-
 .../apache/sedona/flink/expressions/Functions.java |  9 +++----
 .../flink/expressions/FunctionsGeoTools.java       |  4 +--
 .../java/org/apache/sedona/flink/FunctionTest.java |  4 +--
 pom.xml                                            |  2 +-
 .../sedona/snowflake/snowsql/GeoToolsWrapper.java  |  4 +--
 .../sedona/core/spatialOperator/KNNQuery.java      |  4 +--
 .../strategy/join/JoinedGeometryRaster.scala       | 11 ++++----
 .../shapefileParser/shapes/ShapefileRDDTest.java   | 12 ++++-----
 .../shapes/ShapefileReaderTest.java                | 14 +++++-----
 .../org/apache/sedona/sql/functionTestScala.scala  |  2 +-
 45 files changed, 176 insertions(+), 192 deletions(-)

diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml
index 3d780c7ae..616e3e2d1 100644
--- a/.github/workflows/java.yml
+++ b/.github/workflows/java.yml
@@ -41,11 +41,7 @@ jobs:
         include:
           - spark: 3.5.0
             scala: 2.13.8
-            jdk: '8'
-            skipTests: ''
-          - spark: 3.5.0
-            scala: 2.12.15
-            jdk: '8'
+            jdk: '11'
             skipTests: ''
           - spark: 3.5.0
             scala: 2.12.15
@@ -53,11 +49,7 @@ jobs:
             skipTests: ''
           - spark: 3.4.0
             scala: 2.13.8
-            jdk: '8'
-            skipTests: ''
-          - spark: 3.4.0
-            scala: 2.12.15
-            jdk: '8'
+            jdk: '11'
             skipTests: ''
           - spark: 3.4.0
             scala: 2.12.15
@@ -65,19 +57,19 @@ jobs:
             skipTests: ''
           - spark: 3.3.0
             scala: 2.12.15
-            jdk: '8'
+            jdk: '11'
             skipTests: ''
           - spark: 3.2.3
             scala: 2.12.15
-            jdk: '8'
+            jdk: '11'
             skipTests: ''
           - spark: 3.1.2
             scala: 2.12.15
-            jdk: '8'
+            jdk: '11'
             skipTests: ''
           - spark: 3.0.3
             scala: 2.12.15
-            jdk: '8'
+            jdk: '11'
             skipTests: ''
 
     steps:
diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml
index 9e5546677..a5d623dd5 100644
--- a/.github/workflows/python.yml
+++ b/.github/workflows/python.yml
@@ -97,7 +97,7 @@ jobs:
     - uses: actions/setup-java@v4
       with:
         distribution: 'zulu'
-        java-version: '8'
+        java-version: '11'
     - uses: actions/setup-python@v5
       with:
         python-version: ${{ matrix.python }}
diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml
index 199e03077..aa28e7f19 100644
--- a/.github/workflows/r.yml
+++ b/.github/workflows/r.yml
@@ -86,7 +86,7 @@ jobs:
       - uses: actions/setup-java@v4
         with:
           distribution: 'temurin'
-          java-version: '8'
+          java-version: '11'
           cache: 'maven'
       - name: Get OS name
         id: os-name
diff --git a/common/src/main/java/org/apache/sedona/common/FunctionsGeoTools.java b/common/src/main/java/org/apache/sedona/common/FunctionsGeoTools.java
index b47c5ce8f..4b15a639c 100644
--- a/common/src/main/java/org/apache/sedona/common/FunctionsGeoTools.java
+++ b/common/src/main/java/org/apache/sedona/common/FunctionsGeoTools.java
@@ -23,11 +23,11 @@ import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.operation.buffer.BufferOp;
 import org.locationtech.jts.operation.buffer.BufferParameters;
 import org.locationtech.jts.triangulate.VoronoiDiagramBuilder;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.NoSuchAuthorityCodeException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.NoSuchAuthorityCodeException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.TransformException;
 
 
 
diff --git a/common/src/main/java/org/apache/sedona/common/raster/GeometryFunctions.java b/common/src/main/java/org/apache/sedona/common/raster/GeometryFunctions.java
index a2c91fbd8..ff215776c 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/GeometryFunctions.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/GeometryFunctions.java
@@ -22,11 +22,11 @@ package org.apache.sedona.common.raster;
 import org.apache.sedona.common.utils.RasterUtils;
 import org.geotools.coverage.grid.GridCoordinates2D;
 import org.geotools.coverage.grid.GridCoverage2D;
-import org.geotools.geometry.Envelope2D;
+import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.locationtech.jts.geom.*;
 import org.locationtech.jts.geom.impl.CoordinateArraySequence;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.awt.geom.Point2D;
 
@@ -118,7 +118,7 @@ public class GeometryFunctions {
     }
 
     public static Geometry envelope(GridCoverage2D raster) throws FactoryException {
-        Envelope2D envelope2D = raster.getEnvelope2D();
+        ReferencedEnvelope envelope2D = raster.getEnvelope2D();
 
         Envelope envelope = new Envelope(envelope2D.getMinX(), envelope2D.getMaxX(), envelope2D.getMinY(), envelope2D.getMaxY());
         int srid = RasterAccessors.srid(raster);
diff --git a/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java b/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java
index 9e5f8456c..88afdb867 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/PixelFunctionEditors.java
@@ -19,14 +19,13 @@
 package org.apache.sedona.common.raster;
 
 import org.apache.commons.lang3.tuple.Pair;
-import org.apache.sedona.common.Functions;
 import org.apache.sedona.common.utils.RasterUtils;
 import org.geotools.coverage.grid.GridCoverage2D;
-import org.geotools.geometry.DirectPosition2D;
+import org.geotools.geometry.Position2D;
 import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import javax.media.jai.RasterFactory;
 import java.awt.*;
@@ -143,7 +142,7 @@ public class PixelFunctionEditors {
         if (geometryType.equalsIgnoreCase(Geometry.TYPENAME_POINT) || geometryType.equalsIgnoreCase(Geometry.TYPENAME_MULTIPOINT)) {
             Coordinate[] coordinates = geom.getCoordinates();
             for (Coordinate pointCoordinate: coordinates) {
-                int[] pointLocation = raster.getGridGeometry().worldToGrid(new DirectPosition2D(pointCoordinate.x, pointCoordinate.y)).getCoordinateValues();
+                int[] pointLocation = raster.getGridGeometry().worldToGrid(new Position2D(pointCoordinate.x, pointCoordinate.y)).getCoordinateValues();
                 double[] pixel = rasterCopied.getPixel(pointLocation[0], pointLocation[1], (double[]) null);
                 pixel[band - 1] = rasterizedGeomData.getPixel(0, 0, (double[]) null)[0];
                 rasterCopied.setPixel(pointLocation[0], pointLocation[1], pixel);
diff --git a/common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java b/common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java
index 65d0a040d..c6757b638 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/PixelFunctions.java
@@ -23,13 +23,12 @@ import org.apache.sedona.common.Functions;
 import org.apache.sedona.common.utils.RasterUtils;
 import org.geotools.coverage.grid.GridCoordinates2D;
 import org.geotools.coverage.grid.GridCoverage2D;
-import org.geotools.geometry.DirectPosition2D;
+import org.geotools.geometry.Position2D;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.locationtech.jts.geom.*;
-import org.opengis.coverage.PointOutsideCoverageException;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.coverage.PointOutsideCoverageException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.awt.geom.Point2D;
 import java.awt.image.Raster;
@@ -277,7 +276,7 @@ public class PixelFunctions
                 result.add(null);
             } else {
                 Point point = ensurePoint(geom);
-                DirectPosition directPosition2D = new DirectPosition2D(point.getX(), point.getY());
+                Point2D.Double directPosition2D = new Point2D.Double(point.getX(), point.getY());
                 try {
                     rasterGeom.evaluate(directPosition2D, pixelBuffer);
                     double pixel = pixelBuffer[band - 1];
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterAccessors.java b/common/src/main/java/org/apache/sedona/common/raster/RasterAccessors.java
index 4d04bd0a5..61a9cef0e 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterAccessors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterAccessors.java
@@ -27,10 +27,10 @@ import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.geom.Point;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.ReferenceIdentifier;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.ReferenceIdentifier;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.awt.geom.Point2D;
 import java.util.Arrays;
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterBandAccessors.java b/common/src/main/java/org/apache/sedona/common/raster/RasterBandAccessors.java
index 7022a503c..62fa7f0cb 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterBandAccessors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterBandAccessors.java
@@ -26,7 +26,7 @@ import org.apache.sedona.common.utils.RasterUtils;
 import org.geotools.coverage.GridSampleDimension;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
+import org.geotools.api.referencing.FactoryException;
 
 import javax.media.jai.RasterFactory;
 import java.awt.image.Raster;
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterBandEditors.java b/common/src/main/java/org/apache/sedona/common/raster/RasterBandEditors.java
index 68feb92d2..8d39ed370 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterBandEditors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterBandEditors.java
@@ -25,9 +25,9 @@ import org.geotools.coverage.GridSampleDimension;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.processing.operation.Crop;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.parameter.ParameterValueGroup;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import javax.media.jai.RasterFactory;
 import java.awt.geom.Point2D;
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterConstructors.java b/common/src/main/java/org/apache/sedona/common/raster/RasterConstructors.java
index c7635c70b..67b3ad812 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterConstructors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterConstructors.java
@@ -27,7 +27,6 @@ import org.geotools.feature.simple.SimpleFeatureBuilder;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.gce.arcgrid.ArcGridReader;
 import org.geotools.gce.geotiff.GeoTiffReader;
-import org.geotools.geometry.Envelope2D;
 import org.geotools.geometry.jts.JTS;
 import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.geotools.process.vector.VectorToRasterProcess;
@@ -36,13 +35,13 @@ import org.geotools.referencing.crs.DefaultEngineeringCRS;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.geotools.util.factory.Hints;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-import org.opengis.metadata.spatial.PixelOrientation;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.datum.PixelInCell;
-import org.opengis.referencing.operation.MathTransform;
+import org.geotools.api.feature.simple.SimpleFeature;
+import org.geotools.api.feature.simple.SimpleFeatureType;
+import org.geotools.api.metadata.spatial.PixelOrientation;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.datum.PixelInCell;
+import org.geotools.api.referencing.operation.MathTransform;
 import ucar.nc2.NetcdfFile;
 import ucar.nc2.NetcdfFiles;
 
@@ -176,26 +175,25 @@ public class RasterConstructors
             throw new IllegalArgumentException(String.format("SkewY %d of the raster is not zero.", metadata[7]));
         }
 
-        Envelope2D bound = null;
+        ReferencedEnvelope bound = null;
 
         if (useGeometryExtent) {
-            bound = JTS.getEnvelope2D(geom.getEnvelopeInternal(), raster.getCoordinateReferenceSystem2D());
+            bound = ReferencedEnvelope.envelope(geom.getEnvelopeInternal(), raster.getCoordinateReferenceSystem2D());
         } else {
-            ReferencedEnvelope envelope = ReferencedEnvelope.create(raster.getEnvelope(), raster.getCoordinateReferenceSystem());
-            bound = JTS.getEnvelope2D(envelope, raster.getCoordinateReferenceSystem2D());
+            bound = ReferencedEnvelope.create(raster.getEnvelope(), raster.getCoordinateReferenceSystem());
         }
 
         double scaleX = Math.abs(metadata[4]), scaleY = Math.abs(metadata[5]);
         int width = (int) bound.getWidth(), height = (int) bound.getHeight();
         if (width == 0 && height == 0) {
-            bound = new Envelope2D(bound.getCoordinateReferenceSystem(), bound.getCenterX() - scaleX * 0.5, bound.getCenterY() - scaleY * 0.5, scaleX, scaleY);
+            bound = ReferencedEnvelope.rect(bound.getCenterX() - scaleX * 0.5, bound.getCenterY() - scaleY * 0.5, scaleX, scaleY, bound.getCoordinateReferenceSystem());
             width = 1;
             height = 1;
         } else if (height == 0) {
-            bound = new Envelope2D(bound.getCoordinateReferenceSystem(), bound.getCenterX() - scaleX * 0.5, bound.getCenterY() - scaleY * 0.5, width, scaleY);
+            bound = ReferencedEnvelope.rect(bound.getCenterX() - scaleX * 0.5, bound.getCenterY() - scaleY * 0.5, width, scaleY, bound.getCoordinateReferenceSystem());
             height = 1;
         } else if (width == 0) {
-            bound = new Envelope2D(bound.getCoordinateReferenceSystem(), bound.getCenterX() - scaleX * 0.5, bound.getCenterY() - scaleY * 0.5, scaleX, height);
+            bound = ReferencedEnvelope.rect(bound.getCenterX() - scaleX * 0.5, bound.getCenterY() - scaleY * 0.5, scaleX, height, bound.getCoordinateReferenceSystem());
             width = 1;
         } else {
             // To preserve scale of reference raster
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterConstructorsForTesting.java b/common/src/main/java/org/apache/sedona/common/raster/RasterConstructorsForTesting.java
index 47667b9b8..6890ee6db 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterConstructorsForTesting.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterConstructorsForTesting.java
@@ -24,9 +24,9 @@ import org.geotools.coverage.grid.GridEnvelope2D;
 import org.geotools.coverage.grid.GridGeometry2D;
 import org.geotools.referencing.crs.DefaultEngineeringCRS;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.datum.PixelInCell;
-import org.opengis.referencing.operation.MathTransform;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.datum.PixelInCell;
+import org.geotools.api.referencing.operation.MathTransform;
 
 import javax.media.jai.RasterFactory;
 import java.awt.Transparency;
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterEditors.java b/common/src/main/java/org/apache/sedona/common/raster/RasterEditors.java
index 235ae8cbd..fa9cefd9c 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterEditors.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterEditors.java
@@ -28,19 +28,19 @@ import org.geotools.coverage.grid.GridCoverageFactory;
 import org.geotools.coverage.grid.GridEnvelope2D;
 import org.geotools.coverage.grid.GridGeometry2D;
 import org.geotools.coverage.processing.Operations;
-import org.geotools.geometry.Envelope2D;
+import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.geotools.referencing.crs.DefaultEngineeringCRS;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.locationtech.jts.index.strtree.STRtree;
-import org.opengis.coverage.grid.GridCoverage;
-import org.opengis.coverage.grid.GridGeometry;
-import org.opengis.metadata.spatial.PixelOrientation;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.datum.PixelInCell;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.MathTransform2D;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.coverage.grid.GridCoverage;
+import org.geotools.api.coverage.grid.GridGeometry;
+import org.geotools.api.metadata.spatial.PixelOrientation;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.datum.PixelInCell;
+import org.geotools.api.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.MathTransform2D;
+import org.geotools.api.referencing.operation.TransformException;
 
 import javax.media.jai.Interpolation;
 import javax.media.jai.RasterFactory;
@@ -178,7 +178,7 @@ public class RasterEditors
         }
 
 
-        Envelope2D envelope2D = raster.getEnvelope2D();
+        ReferencedEnvelope envelope2D = raster.getEnvelope2D();
         //process scale changes due to changes in widthOrScale and heightOrScale
         if (!useScale) {
             newScaleX = (Math.abs(envelope2D.getMaxX() - envelope2D.getMinX())) / newWidth;
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterOutputs.java b/common/src/main/java/org/apache/sedona/common/raster/RasterOutputs.java
index ed585a015..42333d25c 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterOutputs.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterOutputs.java
@@ -25,9 +25,9 @@ import org.geotools.gce.arcgrid.ArcGridWriteParams;
 import org.geotools.gce.arcgrid.ArcGridWriter;
 import org.geotools.gce.geotiff.GeoTiffWriteParams;
 import org.geotools.gce.geotiff.GeoTiffWriter;
-import org.opengis.coverage.grid.GridCoverageWriter;
-import org.opengis.parameter.GeneralParameterValue;
-import org.opengis.parameter.ParameterValueGroup;
+import org.geotools.api.coverage.grid.GridCoverageWriter;
+import org.geotools.api.parameter.GeneralParameterValue;
+import org.geotools.api.parameter.ParameterValueGroup;
 
 import javax.imageio.ImageIO;
 import javax.imageio.ImageWriteParam;
diff --git a/common/src/main/java/org/apache/sedona/common/raster/RasterPredicates.java b/common/src/main/java/org/apache/sedona/common/raster/RasterPredicates.java
index c45db0bb1..e330475cf 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/RasterPredicates.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/RasterPredicates.java
@@ -30,12 +30,12 @@ import org.geotools.referencing.CRS;
 import org.geotools.referencing.crs.DefaultEngineeringCRS;
 import org.geotools.referencing.crs.DefaultGeographicCRS;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.ReferenceIdentifier;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.ReferenceIdentifier;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.crs.GeographicCRS;
+import org.geotools.api.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.TransformException;
 
 public class RasterPredicates {
     /**
diff --git a/common/src/main/java/org/apache/sedona/common/raster/netcdf/NetCdfReader.java b/common/src/main/java/org/apache/sedona/common/raster/netcdf/NetCdfReader.java
index ad8f42370..032aa5193 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/netcdf/NetCdfReader.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/netcdf/NetCdfReader.java
@@ -21,8 +21,8 @@ package org.apache.sedona.common.raster.netcdf;
 import com.google.common.collect.ImmutableList;
 import org.apache.sedona.common.raster.RasterConstructors;
 import org.geotools.coverage.grid.GridCoverage2D;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.datum.PixelInCell;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.datum.PixelInCell;
 import ucar.ma2.Array;
 import ucar.nc2.*;
 
diff --git a/common/src/main/java/org/apache/sedona/common/raster/serde/CRSSerializer.java b/common/src/main/java/org/apache/sedona/common/raster/serde/CRSSerializer.java
index 9c427e34f..7e3c9fdfd 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/serde/CRSSerializer.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/serde/CRSSerializer.java
@@ -23,8 +23,8 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
 import org.apache.commons.io.IOUtils;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.wkt.Formattable;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
 import si.uom.NonSI;
 import si.uom.SI;
 
diff --git a/common/src/main/java/org/apache/sedona/common/raster/serde/Serde.java b/common/src/main/java/org/apache/sedona/common/raster/serde/Serde.java
index 848c00b3f..e775ee46a 100644
--- a/common/src/main/java/org/apache/sedona/common/raster/serde/Serde.java
+++ b/common/src/main/java/org/apache/sedona/common/raster/serde/Serde.java
@@ -28,7 +28,7 @@ import org.geotools.coverage.grid.GridEnvelope2D;
 import org.geotools.coverage.grid.GridGeometry2D;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.objenesis.strategy.StdInstantiatorStrategy;
-import org.opengis.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.MathTransform;
 
 import javax.media.jai.RenderedImageAdapter;
 import java.awt.image.RenderedImage;
diff --git a/common/src/main/java/org/apache/sedona/common/utils/CachedCRSTransformFinder.java b/common/src/main/java/org/apache/sedona/common/utils/CachedCRSTransformFinder.java
index 7d0cd1117..c3305733a 100644
--- a/common/src/main/java/org/apache/sedona/common/utils/CachedCRSTransformFinder.java
+++ b/common/src/main/java/org/apache/sedona/common/utils/CachedCRSTransformFinder.java
@@ -21,9 +21,9 @@ package org.apache.sedona.common.utils;
 import com.github.benmanes.caffeine.cache.Caffeine;
 import com.github.benmanes.caffeine.cache.LoadingCache;
 import org.geotools.referencing.CRS;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.MathTransform;
 
 /**
  * A utility class for finding CRS transforms. It avoids the expensive equals() call on CRS objects
diff --git a/common/src/main/java/org/apache/sedona/common/utils/RasterUtils.java b/common/src/main/java/org/apache/sedona/common/utils/RasterUtils.java
index e6e51495a..7cc6c5080 100644
--- a/common/src/main/java/org/apache/sedona/common/utils/RasterUtils.java
+++ b/common/src/main/java/org/apache/sedona/common/utils/RasterUtils.java
@@ -34,20 +34,19 @@ import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;
 import org.geotools.coverage.grid.GridEnvelope2D;
 import org.geotools.coverage.grid.GridGeometry2D;
-import org.geotools.geometry.DirectPosition2D;
+import org.geotools.geometry.Position2D;
 import org.geotools.referencing.crs.DefaultEngineeringCRS;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.geotools.util.ClassChanger;
 import org.geotools.util.NumberRange;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.coverage.grid.GridEnvelope;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.metadata.spatial.PixelOrientation;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.InternationalString;
+import org.geotools.api.coverage.grid.GridEnvelope;
+import org.geotools.api.metadata.spatial.PixelOrientation;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.TransformException;
+import org.geotools.api.util.InternationalString;
 
 import javax.media.jai.RasterFactory;
 import javax.media.jai.RenderedImageAdapter;
@@ -418,9 +417,9 @@ public class RasterUtils {
         return raster.getGridGeometry().getGridToCRS2D(PixelOrientation.UPPER_LEFT).transform(gridCoordinates2D, null);
     }
     public static int[] getGridCoordinatesFromWorld(GridCoverage2D raster, double longitude, double latitude) throws TransformException {
-        DirectPosition2D directPosition2D = new DirectPosition2D(raster.getCoordinateReferenceSystem2D(), longitude, latitude);
-        DirectPosition worldCoord = raster.getGridGeometry().getCRSToGrid2D(PixelOrientation.UPPER_LEFT).transform((DirectPosition) directPosition2D, null);
-        double[] coords = worldCoord.getCoordinate();
+        Point2D directPosition2D = new Position2D(raster.getCoordinateReferenceSystem2D(), longitude, latitude);
+        Point2D worldCoord = raster.getGridGeometry().getCRSToGrid2D(PixelOrientation.UPPER_LEFT).transform(directPosition2D, null);
+        double[] coords = new double[] {worldCoord.getX(), worldCoord.getY()};
         int[] gridCoords = new int[] {(int) Math.floor(coords[0]), (int) Math.floor(coords[1])};
         return gridCoords;
     }
diff --git a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
index 701a24594..1512bb0b4 100644
--- a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java
@@ -27,8 +27,8 @@ import org.locationtech.jts.geom.*;
 import org.locationtech.jts.io.ParseException;
 import org.locationtech.jts.io.WKTReader;
 import org.locationtech.jts.io.WKTWriter;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.util.*;
 import java.util.stream.Collectors;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java
index b324e54eb..0e50749e5 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/FunctionEditorsTest.java
@@ -26,8 +26,8 @@ import org.geotools.coverage.grid.GridCoverage2D;
 import org.junit.Test;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.io.ParseException;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.IOException;
 import java.util.Arrays;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/FunctionsTest.java b/common/src/test/java/org/apache/sedona/common/raster/FunctionsTest.java
index 2bf3d491b..7327d614f 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/FunctionsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/FunctionsTest.java
@@ -26,8 +26,8 @@ import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.geom.Point;
 import org.locationtech.jts.io.ParseException;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.IOException;
 import java.util.ArrayList;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/GeometryFunctionsTest.java b/common/src/test/java/org/apache/sedona/common/raster/GeometryFunctionsTest.java
index a01fb5a88..703050c84 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/GeometryFunctionsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/GeometryFunctionsTest.java
@@ -24,8 +24,8 @@ import org.junit.Test;
 import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.Envelope;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.IOException;
 
diff --git a/common/src/test/java/org/apache/sedona/common/raster/MapAlgebraTest.java b/common/src/test/java/org/apache/sedona/common/raster/MapAlgebraTest.java
index 7bf17044c..79acf3af6 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/MapAlgebraTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/MapAlgebraTest.java
@@ -22,7 +22,7 @@ import org.apache.sedona.common.utils.RasterUtils;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.junit.Assert;
 import org.junit.Test;
-import org.opengis.referencing.FactoryException;
+import org.geotools.api.referencing.FactoryException;
 
 import java.awt.image.DataBuffer;
 import java.util.Random;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterAccessorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterAccessorsTest.java
index d8f52fca8..143d1d88a 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterAccessorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterAccessorsTest.java
@@ -26,8 +26,8 @@ import org.geotools.referencing.CRS;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.junit.Test;
 import org.locationtech.jts.geom.*;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.IOException;
 
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterBandAccessorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterBandAccessorsTest.java
index 306aed86f..5514ac890 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterBandAccessorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterBandAccessorsTest.java
@@ -24,8 +24,8 @@ import org.geotools.coverage.grid.GridCoverage2D;
 import org.junit.Test;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.io.ParseException;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.IOException;
 import java.util.Arrays;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterBandEditorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterBandEditorsTest.java
index 19b932ad7..0d8d147f3 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterBandEditorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterBandEditorsTest.java
@@ -24,8 +24,8 @@ import org.geotools.coverage.grid.GridCoverage2D;
 import org.junit.Test;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.io.ParseException;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.IOException;
 import java.text.DecimalFormat;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterConstructorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterConstructorsTest.java
index 56427f567..80afd7860 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterConstructorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterConstructorsTest.java
@@ -16,16 +16,16 @@ package org.apache.sedona.common.raster;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.sedona.common.Constructors;
 import org.apache.sedona.common.utils.RasterUtils;
+import org.geotools.api.geometry.Position;
 import org.geotools.coverage.grid.GridCoordinates2D;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.junit.Assert;
 import org.junit.Test;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.coverage.SampleDimensionType;
-import org.opengis.geometry.DirectPosition;
+import org.geotools.api.coverage.SampleDimensionType;
 import org.locationtech.jts.io.ParseException;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.awt.image.DataBuffer;
 import java.awt.image.Raster;
@@ -415,8 +415,8 @@ public class RasterConstructorsTest
                     // Check that the pixel at the point translates to the same world coordinate as the corresponding
                     // pixel in the grid coverage
                     try {
-                        DirectPosition actualWorldCoord = tileRaster.getGridGeometry().gridToWorld(tileGridCoord);
-                        DirectPosition expectedWorldCoord = gridCoverage2D.getGridGeometry().gridToWorld(gridCoord);
+                        Position actualWorldCoord = tileRaster.getGridGeometry().gridToWorld(tileGridCoord);
+                        Position expectedWorldCoord = gridCoverage2D.getGridGeometry().gridToWorld(gridCoord);
                         Assert.assertEquals(expectedWorldCoord, actualWorldCoord);
                     } catch (TransformException e) {
                         throw new RuntimeException(e);
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterEditorsTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterEditorsTest.java
index 0b811ba88..07af75b28 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterEditorsTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterEditorsTest.java
@@ -19,20 +19,20 @@
 package org.apache.sedona.common.raster;
 
 import org.apache.sedona.common.utils.RasterUtils;
+import org.geotools.api.geometry.Bounds;
+import org.geotools.api.geometry.Position;
 import org.geotools.coverage.grid.GridCoordinates2D;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridEnvelope2D;
-import org.geotools.geometry.DirectPosition2D;
+import org.geotools.geometry.Position2D;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.operation.transform.AffineTransform2D;
 import org.junit.Assert;
 import org.junit.Test;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.Envelope;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.MathTransform;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.awt.image.DataBuffer;
 import java.io.IOException;
@@ -698,8 +698,8 @@ public class RasterEditorsTest extends RasterTestBase {
     private void verifyReprojectMatchResult(GridCoverage2D source, GridCoverage2D target, GridCoverage2D transformed)
             throws TransformException, FactoryException {
         // Check the envelope and CRS
-        Envelope expectedEnvelope = target.getEnvelope();
-        Envelope actualEnvelope = transformed.getEnvelope();
+        Bounds expectedEnvelope = target.getEnvelope();
+        Bounds actualEnvelope = transformed.getEnvelope();
         assertSameEnvelope(expectedEnvelope, actualEnvelope, 1e-6);
         CoordinateReferenceSystem expectedCrs = target.getCoordinateReferenceSystem();
         CoordinateReferenceSystem actualCrs = transformed.getCoordinateReferenceSystem();
@@ -726,11 +726,11 @@ public class RasterEditorsTest extends RasterTestBase {
         for (double worldY = ipY; worldY > expectedEnvelope.getMinimum(1); worldY += scaleY) {
             for (double worldX = ipX; worldX < expectedEnvelope.getMaximum(0); worldX += scaleX) {
                 // Fetch the pixel values from the transformed raster
-                DirectPosition worldPos = new DirectPosition2D(worldX, worldY);
+                Position worldPos = new Position2D(worldX, worldY);
                 transformed.evaluate(worldPos, values);
 
                 // Find the corresponding grid coordinates on the source raster
-                DirectPosition srcWorldPos = crsTrans.transform(worldPos, null);
+                Position srcWorldPos = crsTrans.transform(worldPos, null);
                 GridCoordinates2D sourceGridPos = source.getGridGeometry().worldToGrid(srcWorldPos);
                 GridEnvelope2D sourceGridRange = source.getGridGeometry().getGridRange2D();
 
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterOutputTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterOutputTest.java
index dded35ca5..d75cd7576 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterOutputTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterOutputTest.java
@@ -21,7 +21,7 @@ package org.apache.sedona.common.raster;
 import org.apache.sedona.common.utils.RasterUtils;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.junit.Test;
-import org.opengis.referencing.FactoryException;
+import org.geotools.api.referencing.FactoryException;
 
 import javax.imageio.ImageIO;
 import java.io.File;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterPredicatesTest.java b/common/src/test/java/org/apache/sedona/common/raster/RasterPredicatesTest.java
index 05d9605b9..c9c535985 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterPredicatesTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterPredicatesTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.sedona.common.raster;
 
+import org.geotools.api.geometry.BoundingBox;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.geometry.jts.JTS;
 import org.geotools.referencing.CRS;
@@ -30,10 +31,9 @@ import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.geom.PrecisionModel;
 import org.locationtech.jts.io.ParseException;
-import org.opengis.geometry.BoundingBox;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.awt.image.DataBuffer;
 import java.io.IOException;
diff --git a/common/src/test/java/org/apache/sedona/common/raster/RasterTestBase.java b/common/src/test/java/org/apache/sedona/common/raster/RasterTestBase.java
index d531c77f6..b2b512f80 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/RasterTestBase.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/RasterTestBase.java
@@ -13,24 +13,25 @@
  */
 package org.apache.sedona.common.raster;
 
+ import org.geotools.api.geometry.Bounds;
+ import org.geotools.api.geometry.Position;
  import org.geotools.coverage.grid.GridCoordinates2D;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.coverage.grid.GridCoverageFactory;
 import org.geotools.gce.geotiff.GeoTiffReader;
 import org.geotools.gce.geotiff.GeoTiffWriter;
-import org.geotools.geometry.DirectPosition2D;
-import org.geotools.geometry.Envelope2D;
-import org.geotools.geometry.jts.ReferencedEnvelope;
+
+ import org.geotools.geometry.Position2D;
+ import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.crs.DefaultGeographicCRS;
 import org.junit.Assert;
 import org.junit.Before;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.Envelope;
-import org.opengis.parameter.GeneralParameterValue;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.TransformException;
+
+import org.geotools.api.parameter.GeneralParameterValue;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.operation.TransformException;
 
 import javax.media.jai.RasterFactory;
 import java.awt.*;
@@ -118,7 +119,7 @@ public class RasterTestBase {
                 image.setRGB(i, j, new Color(color, color, color).getRGB());
             }
         }
-        return factory.create("test", image, new Envelope2D(DefaultGeographicCRS.WGS84, 0, 0, 10, 10));
+        return factory.create("test", image, ReferencedEnvelope.rect(0, 0, 10, 10, DefaultGeographicCRS.WGS84));
     }
 
     protected void assertSameCoverage(GridCoverage2D expected, GridCoverage2D actual) {
@@ -127,8 +128,8 @@ public class RasterTestBase {
 
     protected void assertSameCoverage(GridCoverage2D expected, GridCoverage2D actual, int density) {
         Assert.assertEquals(expected.getNumSampleDimensions(), actual.getNumSampleDimensions());
-        Envelope expectedEnvelope = expected.getEnvelope();
-        Envelope actualEnvelope = actual.getEnvelope();
+        Bounds expectedEnvelope = expected.getEnvelope();
+        Bounds actualEnvelope = actual.getEnvelope();
         assertSameEnvelope(expectedEnvelope, actualEnvelope, 1e-6);
         CoordinateReferenceSystem expectedCrs = expected.getCoordinateReferenceSystem();
         CoordinateReferenceSystem actualCrs = actual.getCoordinateReferenceSystem();
@@ -136,7 +137,7 @@ public class RasterTestBase {
         assertSameValues(expected, actual, density);
     }
 
-    protected void assertSameEnvelope(Envelope expected, Envelope actual, double epsilon) {
+    protected void assertSameEnvelope(Bounds expected, Bounds actual, double epsilon) {
         Assert.assertEquals(expected.getMinimum(0), actual.getMinimum(0), epsilon);
         Assert.assertEquals(expected.getMinimum(1), actual.getMinimum(1), epsilon);
         Assert.assertEquals(expected.getMaximum(0), actual.getMaximum(0), epsilon);
@@ -144,7 +145,7 @@ public class RasterTestBase {
     }
 
     protected void assertSameValues(GridCoverage2D expected, GridCoverage2D actual, int density) {
-        Envelope expectedEnvelope = expected.getEnvelope();
+        Bounds expectedEnvelope = expected.getEnvelope();
         double x0 = expectedEnvelope.getMinimum(0);
         double y0 = expectedEnvelope.getMinimum(1);
         double xStep = (expectedEnvelope.getMaximum(0) - x0) / density;
@@ -156,7 +157,7 @@ public class RasterTestBase {
             for (int j = 0; j < density; j++) {
                 double x = x0 + j * xStep;
                 double y = y0 + i * yStep;
-                DirectPosition position = new DirectPosition2D(x, y);
+                Position position = new Position2D(x, y);
                 try {
                     GridCoordinates2D gridPosition = expected.getGridGeometry().worldToGrid(position);
                     if (Double.isNaN(gridPosition.getX()) || Double.isNaN(gridPosition.getY())) {
diff --git a/common/src/test/java/org/apache/sedona/common/raster/serde/CRSSerializerTest.java b/common/src/test/java/org/apache/sedona/common/raster/serde/CRSSerializerTest.java
index bb5399fd0..8603deea1 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/serde/CRSSerializerTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/serde/CRSSerializerTest.java
@@ -21,8 +21,8 @@ package org.apache.sedona.common.raster.serde;
 import org.geotools.referencing.CRS;
 import org.junit.Assert;
 import org.junit.Test;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
 
 public class CRSSerializerTest {
     @Test
diff --git a/common/src/test/java/org/apache/sedona/common/raster/serde/SerdeTest.java b/common/src/test/java/org/apache/sedona/common/raster/serde/SerdeTest.java
index 844c3d34f..3535775b7 100644
--- a/common/src/test/java/org/apache/sedona/common/raster/serde/SerdeTest.java
+++ b/common/src/test/java/org/apache/sedona/common/raster/serde/SerdeTest.java
@@ -23,7 +23,7 @@ import org.apache.sedona.common.raster.RasterTestBase;
 import org.geotools.coverage.grid.GridCoverage2D;
 import org.geotools.gce.geotiff.GeoTiffReader;
 import org.junit.Test;
-import org.opengis.referencing.FactoryException;
+import org.geotools.api.referencing.FactoryException;
 
 import java.io.File;
 import java.io.IOException;
diff --git a/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java b/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java
index 013fb7241..fe34c38ea 100644
--- a/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java
+++ b/flink/src/main/java/org/apache/sedona/flink/expressions/Functions.java
@@ -13,7 +13,6 @@
  */
 package org.apache.sedona.flink.expressions;
 
-import org.apache.calcite.runtime.Geometries;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.flink.table.annotation.DataTypeHint;
 import org.apache.flink.table.annotation.InputGroup;
@@ -21,8 +20,6 @@ import org.apache.flink.table.functions.ScalarFunction;
 import org.apache.sedona.common.FunctionsGeoTools;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.operation.buffer.BufferParameters;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
 
 import java.util.Arrays;
 
@@ -72,21 +69,21 @@ public class Functions {
     public static class ST_Buffer extends ScalarFunction {
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
-        Object o, @DataTypeHint("Double") Double radius) throws FactoryException, TransformException {
+        Object o, @DataTypeHint("Double") Double radius) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.buffer(geom, radius);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
-                             Object o, @DataTypeHint("Double") Double radius, @DataTypeHint("Boolean") Boolean useSpheroid) throws FactoryException, TransformException {
+                             Object o, @DataTypeHint("Double") Double radius, @DataTypeHint("Boolean") Boolean useSpheroid) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.buffer(geom, radius, useSpheroid);
         }
 
         @DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
         public Geometry eval(@DataTypeHint(value = "RAW", bridgedTo = org.locationtech.jts.geom.Geometry.class)
-                             Object o, @DataTypeHint("Double") Double radius, @DataTypeHint("Boolean") Boolean useSpheroid, @DataTypeHint("String") String params) throws FactoryException, TransformException {
+                             Object o, @DataTypeHint("Double") Double radius, @DataTypeHint("Boolean") Boolean useSpheroid, @DataTypeHint("String") String params) {
             Geometry geom = (Geometry) o;
             return org.apache.sedona.common.Functions.buffer(geom, radius, useSpheroid, params);
         }
diff --git a/flink/src/main/java/org/apache/sedona/flink/expressions/FunctionsGeoTools.java b/flink/src/main/java/org/apache/sedona/flink/expressions/FunctionsGeoTools.java
index 65054cf11..842ef42eb 100644
--- a/flink/src/main/java/org/apache/sedona/flink/expressions/FunctionsGeoTools.java
+++ b/flink/src/main/java/org/apache/sedona/flink/expressions/FunctionsGeoTools.java
@@ -15,8 +15,8 @@ package org.apache.sedona.flink.expressions;
 import org.apache.flink.table.annotation.DataTypeHint;
 import org.apache.flink.table.functions.ScalarFunction;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 
 public class FunctionsGeoTools {
diff --git a/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java b/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
index 0306e5b52..daef6d9b1 100644
--- a/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
+++ b/flink/src/test/java/org/apache/sedona/flink/FunctionTest.java
@@ -27,8 +27,8 @@ import org.junit.Test;
 import org.locationtech.jts.geom.*;
 import org.locationtech.jts.io.ParseException;
 import org.locationtech.jts.operation.buffer.BufferParameters;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
 import scala.collection.immutable.Stream;
 
 import java.util.Arrays;
diff --git a/pom.xml b/pom.xml
index d4f4265c0..6ecc8eefe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,7 +68,7 @@
         <maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
 
         <cdm.version>5.4.2</cdm.version>
-        <geotools.version>28.2</geotools.version>
+        <geotools.version>31.0</geotools.version>
         <hadoop.version>3.2.4</hadoop.version>
         <jackson.version>2.13.4</jackson.version>
         <jts.version>1.19.0</jts.version>
diff --git a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/GeoToolsWrapper.java b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/GeoToolsWrapper.java
index ef96ab05a..9f53fce7b 100644
--- a/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/GeoToolsWrapper.java
+++ b/snowflake/src/main/java/org/apache/sedona/snowflake/snowsql/GeoToolsWrapper.java
@@ -15,8 +15,8 @@ package org.apache.sedona.snowflake.snowsql;
 
 import org.apache.sedona.common.FunctionsGeoTools;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 public class GeoToolsWrapper {
     public static Geometry transform(Geometry geometry, String sourceCRS, String targetCRS, boolean lenient) {
diff --git a/spark/common/src/main/java/org/apache/sedona/core/spatialOperator/KNNQuery.java b/spark/common/src/main/java/org/apache/sedona/core/spatialOperator/KNNQuery.java
index 71bf27756..775c477b0 100644
--- a/spark/common/src/main/java/org/apache/sedona/core/spatialOperator/KNNQuery.java
+++ b/spark/common/src/main/java/org/apache/sedona/core/spatialOperator/KNNQuery.java
@@ -26,8 +26,8 @@ import org.apache.sedona.core.knnJudgement.KnnJudgementUsingIndex;
 import org.apache.sedona.core.spatialRDD.SpatialRDD;
 import org.apache.spark.api.java.JavaRDD;
 import org.locationtech.jts.geom.Geometry;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.operation.TransformException;
+import org.geotools.api.referencing.FactoryException;
+import org.geotools.api.referencing.operation.TransformException;
 
 import java.io.Serializable;
 import java.util.List;
diff --git a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinedGeometryRaster.scala b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinedGeometryRaster.scala
index a3fd7d3c4..03d6fd617 100644
--- a/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinedGeometryRaster.scala
+++ b/spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinedGeometryRaster.scala
@@ -20,14 +20,13 @@ package org.apache.spark.sql.sedona_sql.strategy.join
 
 import org.apache.sedona.common.FunctionsGeoTools
 import org.apache.sedona.common.utils.{CachedCRSTransformFinder, GeomUtils}
+import org.geotools.api.geometry.{BoundingBox, Bounds}
 import org.geotools.coverage.grid.GridCoverage2D
-import org.geotools.geometry.Envelope2D
-import org.geotools.geometry.jts.JTS
+import org.geotools.geometry.jts.{JTS, ReferencedEnvelope}
 import org.geotools.referencing.CRS
 import org.geotools.referencing.crs.{DefaultEngineeringCRS, DefaultGeographicCRS}
 import org.locationtech.jts.geom.{Envelope, Geometry}
-import org.opengis.geometry.BoundingBox
-import org.opengis.referencing.crs.{CoordinateReferenceSystem, GeographicCRS}
+import org.geotools.api.referencing.crs.{CoordinateReferenceSystem, GeographicCRS}
 
 object JoinedGeometryRaster {
   /**
@@ -58,13 +57,13 @@ object JoinedGeometryRaster {
       geom
     } else {
       val env = geom.getEnvelopeInternal
-      val envelope = new Envelope2D(null, env.getMinX, env.getMinY, env.getWidth, env.getHeight)
+      val envelope = ReferencedEnvelope.rect(env.getMinX, env.getMinY, env.getWidth, env.getHeight, null)
       val crs = FunctionsGeoTools.sridToCRS(srid)
       transformToWGS84Envelope(envelope, crs)
     }
   }
 
-  private def transformToWGS84Envelope(envelope: org.opengis.geometry.Envelope, crs: CoordinateReferenceSystem): Geometry = {
+  private def transformToWGS84Envelope(envelope: Bounds, crs: CoordinateReferenceSystem): Geometry = {
     // We use CRS.transform for envelopes to transform envelopes between different CRSs. This transformation function
     // could handle envelope crossing the anti-meridian and envelope near or covering poles correctly. We won't have
     // these cases properly handled if we transform the original geometries using JTS.transform.
diff --git a/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileRDDTest.java b/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileRDDTest.java
index 2c2d4b7ca..52a626707 100644
--- a/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileRDDTest.java
+++ b/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileRDDTest.java
@@ -29,9 +29,9 @@ import org.apache.sedona.core.spatialRDD.PointRDD;
 import org.apache.sedona.core.spatialRDD.PolygonRDD;
 import org.apache.spark.SparkConf;
 import org.apache.spark.api.java.JavaSparkContext;
-import org.geotools.data.DataStore;
-import org.geotools.data.DataStoreFinder;
-import org.geotools.data.FeatureSource;
+import org.geotools.api.data.DataStore;
+import org.geotools.api.data.DataStoreFinder;
+import org.geotools.api.data.FeatureSource;
 import org.geotools.data.shapefile.files.ShpFiles;
 import org.geotools.data.shapefile.shp.ShapefileReader;
 import org.geotools.feature.FeatureCollection;
@@ -44,9 +44,9 @@ import org.locationtech.jts.geom.Envelope;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.geom.MultiPolygon;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-import org.opengis.filter.Filter;
+import org.geotools.api.feature.simple.SimpleFeature;
+import org.geotools.api.feature.simple.SimpleFeatureType;
+import org.geotools.api.filter.Filter;
 
 import java.io.File;
 import java.io.IOException;
diff --git a/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileReaderTest.java b/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileReaderTest.java
index 65d145ed5..545545a03 100644
--- a/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileReaderTest.java
+++ b/spark/common/src/test/java/org/apache/sedona/core/formatMapper/shapefileParser/shapes/ShapefileReaderTest.java
@@ -37,9 +37,9 @@ import org.apache.sedona.core.spatialRDD.PointRDD;
 import org.apache.sedona.core.spatialRDD.PolygonRDD;
 import org.apache.sedona.core.spatialRDD.SpatialRDD;
 import org.apache.spark.SparkException;
-import org.geotools.data.DataStore;
-import org.geotools.data.DataStoreFinder;
-import org.geotools.data.FeatureSource;
+import org.geotools.api.data.DataStore;
+import org.geotools.api.data.DataStoreFinder;
+import org.geotools.api.data.FeatureSource;
 import org.geotools.data.shapefile.files.ShpFiles;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.FeatureIterator;
@@ -50,10 +50,10 @@ import org.locationtech.jts.geom.Envelope;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.geom.MultiPolygon;
-import org.opengis.feature.Property;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-import org.opengis.filter.Filter;
+import org.geotools.api.feature.Property;
+import org.geotools.api.feature.simple.SimpleFeature;
+import org.geotools.api.feature.simple.SimpleFeatureType;
+import org.geotools.api.filter.Filter;
 
 import java.io.File;
 import java.io.IOException;
diff --git a/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala b/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
index 3fee1e53c..f880b0700 100644
--- a/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
+++ b/spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala
@@ -32,7 +32,7 @@ import org.locationtech.jts.geom.{Coordinate, Geometry, GeometryFactory, Polygon
 import org.locationtech.jts.io.WKTWriter
 import org.locationtech.jts.linearref.LengthIndexedLine
 import org.locationtech.jts.operation.distance3d.Distance3DOp
-import org.opengis.referencing.FactoryException
+import org.geotools.api.referencing.FactoryException
 import org.scalatest.{GivenWhenThen, Matchers}
 import org.xml.sax.InputSource