You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2025/01/10 21:37:27 UTC
Re: [I] Preserve Spatial Partitioning From RDD to Dataframe [sedona]
paleolimbot commented on issue #1268:
URL: https://github.com/apache/sedona/issues/1268#issuecomment-2584326953
Just working on this now! For myself as I work on this, a self-contained example:
Get a geoparquet:
```shell
curl -L https://github.com/MrPowers/sedona-examples/raw/refs/heads/main/data/ne_cities.parquet \
-o cities.parquet
```
Set up the session:
```python
from sedona.spark import SedonaContext
config = SedonaContext.builder().getOrCreate()
sedona = SedonaContext.create(config)
```
Partition an RDD and try to write it:
```python
from sedona.spark import Adapter, GridType
df = sedona.read.format("geoparquet").load("cities.parquet")
rdd = Adapter.toSpatialRdd(df, "geometry")
rdd.analyze()
rdd.spatialPartitioning(GridType.KDBTREE, num_partitions=6)
df2 = Adapter.toDf(rdd, sedona)
df2.write.format("geoparquet").save("cities_maybe_partitioned")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org