Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Update statements about Shapely 2 support #1285

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/setup/emr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion docs/setup/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
57 changes: 48 additions & 9 deletions docs/tutorial/geopandas-shapely.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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))|
+---+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

```
6 changes: 3 additions & 3 deletions docs/tutorial/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
```

Expand Down
Loading