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

grid_boundary returns incorrect geometries for "NE", "NW", "SE", "SW" 100km BNG grid references #434

Open
tompeterken-os opened this issue Sep 19, 2023 · 0 comments

Comments

@tompeterken-os
Copy link
Contributor

tompeterken-os commented Sep 19, 2023

When using 100km-resolution BNG indices in grid_boundary, the tiles "NE", "NW", "SE", and "SW" are interpreted as being a "quadrant" resolution, so are erroneously being given geometries with half dimensions.

To Reproduce

import mosaic as mos
from pyspark.sql import functions as F

# Enable BNG indexing
spark.conf.set('spark.databricks.labs.mosaic.index.system', 'BNG')
mos.enable_mosaic(spark, dbutils)

# Create a dataframe with 4 100km grid references
df = (
  spark.createDataFrame([
    {'bng': g} for g in ['SE', 'SF', 'NX', 'NW']
  ])
  # Define boundary geometry
  .withColumn('grid_boundary', mos.grid_boundary('bng', F.lit('WKT')))
  # Measure area of each tile (should be the same for all)
  .withColumn('area', mos.st_area('grid_boundary'))
)

df.display()

All rows in the dataframe ought to have the same area of 10^10 m^2, but "SE" and "NW" do not:
image

Similar results for "NE" and "SW" too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant