cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Mosaic's grid_boundary method returns inconsistent geometries

kll
New Contributor III

I am applying mosaic's `grid_boundary` method on a spark DataFrame containing a set of `h3_hex_ids`. The geometries returned are not consistent. i.e they could be either `lat, long` or `long, lat`.


Here's a sample data

```
import pyspark.sql.functions as F
import h3

# Create a Spark DataFrame with a h3_hex_id column
df = spark.createDataFrame([
("point1", 612232698081050623),
("point2", 611987238200279039),
("point3", 612252103481491455)),
], ["name", "h3_hex_id"])


# Get Polygon geometries
df1 = df.withColumn("geometry", grid_boundary(col("h3_hex_id"), format_name=F.lit("WKT")))
df1.show()

+--------------------+------+----------------+----------------+
| name | h3_hex_id | | geometry |
+--------------------+------+----------------+----------------+
| point1 | 612232698081050623 | POLYGON ((42.1261...
| point2 | 611987238200279039 | POLYGON ((-145.83...
| point3 | 612252103481491455 | POLYGON ((-138.08...
+--------------------+------+----------------+----------------+

```

This is causing a few issues with downstream tasks like spatial joins. Why are the geometries returned by `grid_boundary` method not consistent?

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group