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/03/21 20:52:17 UTC
(sedona) branch master updated: [DOCS] Update statements about Shapely 2 support (#1285)
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git
The following commit(s) were added to refs/heads/master by this push:
new b135750ef [DOCS] Update statements about Shapely 2 support (#1285)
b135750ef is described below
commit b135750ef1d84c76568af05e31342c72f29751a0
Author: Kristin Cowalcijk <bo...@wherobots.com>
AuthorDate: Fri Mar 22 04:52:12 2024 +0800
[DOCS] Update statements about Shapely 2 support (#1285)
---
docs/setup/emr.md | 6 ++--
docs/setup/release-notes.md | 4 ++-
docs/tutorial/geopandas-shapely.md | 57 ++++++++++++++++++++++++++++++++------
docs/tutorial/sql.md | 6 ++--
4 files changed, 57 insertions(+), 16 deletions(-)
diff --git a/docs/setup/emr.md b/docs/setup/emr.md
index e39c897f0..a3d9d8bca 100644
--- a/docs/setup/emr.md
+++ b/docs/setup/emr.md
@@ -25,9 +25,9 @@ sudo curl -o /jars/sedona-spark-shaded-3.0_2.12-{{ sedona.current_version }}.jar
sudo curl -o /jars/geotools-wrapper-{{ sedona.current_geotools }}.jar "https://repo1.maven.org/maven2/org/datasyslab/geotools-wrapper/{{ sedona.current_geotools }}/geotools-wrapper-{{ sedona.current_geotools }}.jar"
# Install necessary python libraries
-sudo python3 -m pip install pandas==1.3.5
-sudo python3 -m pip install shapely==1.8.5
-sudo python3 -m pip install geopandas==0.11.1
+sudo python3 -m pip install pandas
+sudo python3 -m pip install shapely
+sudo python3 -m pip install geopandas
sudo python3 -m pip install keplergl==0.3.2
sudo python3 -m pip install pydeck==0.8.0
sudo python3 -m pip install attrs matplotlib descartes apache-sedona=={{ sedona.current_version }}
diff --git a/docs/setup/release-notes.md b/docs/setup/release-notes.md
index 99bff233f..93d8a51e7 100644
--- a/docs/setup/release-notes.md
+++ b/docs/setup/release-notes.md
@@ -2,7 +2,9 @@
Support of Spark 2.X and Scala 2.11 was removed in Sedona 1.3.0+ although some parts of the source code might still be compatible. Sedona 1.3.0+ releases binary for both Scala 2.12 and 2.13.
!!! note
- Sedona Python currently only works with Shapely 1.x. If you use GeoPandas, please use <= GeoPandas `0.11.1`. GeoPandas > 0.11.1 will automatically install Shapely 2.0. If you use Shapely, please use <= `1.8.4`.
+ Sedona before 1.6.0 only works with Shapely 1.x. If you want to work with Shapely 2.x, please use Sedona no earlier than 1.6.0.
+
+ If you use Sedona < 1.6.0, please use GeoPandas <= `0.11.1` since GeoPandas > 0.11.1 will automatically install Shapely 2.0. If you use Shapely, please use <= `1.8.5`.
## Sedona 1.5.1
diff --git a/docs/tutorial/geopandas-shapely.md b/docs/tutorial/geopandas-shapely.md
index 1467d5842..bb41162aa 100644
--- a/docs/tutorial/geopandas-shapely.md
+++ b/docs/tutorial/geopandas-shapely.md
@@ -1,7 +1,7 @@
# Work with GeoPandas and Shapely
!!!danger
- Sedona Python currently only works with Shapely 1.x. If you use GeoPandas, please use <= GeoPandas `0.11.1`. GeoPandas > 0.11.1 will automatically install Shapely 2.0. If you use Shapely, please use <= `1.8.4`.
+ Sedona < 1.6.0 only works with Shapely 1.x and GeoPandas <= `0.11.1`. If you want to use the latest Shapely and GeoPandas, please use Sedona >= 1.6.0.
## Interoperate with GeoPandas
@@ -97,14 +97,15 @@ gdf.plot(
### Supported Shapely objects
-| shapely object | Available |
-|-----------------|--------------------|
-| Point | :heavy_check_mark: |
-| MultiPoint | :heavy_check_mark: |
-| LineString | :heavy_check_mark: |
-| MultiLinestring | :heavy_check_mark: |
-| Polygon | :heavy_check_mark: |
-| MultiPolygon | :heavy_check_mark: |
+| shapely object | Available |
+|--------------------|--------------------|
+| Point | :heavy_check_mark: |
+| MultiPoint | :heavy_check_mark: |
+| LineString | :heavy_check_mark: |
+| MultiLinestring | :heavy_check_mark: |
+| Polygon | :heavy_check_mark: |
+| MultiPolygon | :heavy_check_mark: |
+| GeometryCollection | :heavy_check_mark: |
To create Spark DataFrame based on mentioned Geometry types, please use <b> GeometryType </b> from <b> sedona.sql.types </b> module. Converting works for list or tuple with shapely objects.
@@ -336,3 +337,41 @@ gdf.show(1, False)
+---+----------------------------------------------------------------------------------------------------------+
```
+
+### GeomeryCollection example
+
+```python3
+
+from shapely.geometry import GeometryCollection, Point, LineString, Polygon
+
+exterior_p1 = [(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]
+interior_p1 = [(1, 1), (1, 1.5), (1.5, 1.5), (1.5, 1), (1, 1)]
+exterior_p2 = [(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]
+
+geoms = [
+ Polygon(exterior_p1, [interior_p1]),
+ Polygon(exterior_p2),
+ Point(1, 1),
+ LineString([(0, 0), (1, 1), (2, 2)])
+]
+
+data = [
+ [1, GeometryCollection(geoms)]
+]
+
+gdf = sedona.createDataFrame(
+ data,
+ schema
+)
+
+gdf.show(1, False)
+```
+
+```
++---+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|id |geom |
++---+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+|1 |GEOMETRYCOLLECTION (POLYGON ((0 0, 0 2, 2 2, 2 0, 0 0), (1 1, 1 1.5, 1.5 1.5, 1.5 1, 1 1)), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), POINT (1 1), LINESTRING (0 0, 1 1, 2 2))|
++---+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+
+```
diff --git a/docs/tutorial/sql.md b/docs/tutorial/sql.md
index 4e97d7f12..8c668de26 100644
--- a/docs/tutorial/sql.md
+++ b/docs/tutorial/sql.md
@@ -922,7 +922,7 @@ This UDF example takes a geometry type input and a primitive type input and retu
schemaUDF = StructType([
StructField("buffed", GeometryType()),
StructField("length", DoubleType())
- ])
+ ])
def bufferAndLength(geom: GeometryType(), distance: DoubleType()):
buffed = geom.buffer(distance)
@@ -931,8 +931,8 @@ This UDF example takes a geometry type input and a primitive type input and retu
sedona.udf.register("udf_bufferLength", bufferAndLength, schemaUDF)
- df.withColumn("bufferLength", expr("udf_bufferLength(geom, buffer)"))
- .select("geom", "buffer", "bufferLength.*")
+ df.withColumn("bufferLength", expr("udf_bufferLength(geom, buffer)")) \
+ .select("geom", "buffer", "bufferLength.*") \
.show()
```