Skip to content

About

Computes a geographic bounding box for a tabular dataset containing a latitude and longitude column, specifically deals with antimeridian crossings

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

Repository files navigation

Antimeridian-Crossing Bounding Box Calculator

DOI Open Notebook Python

This code computes a geographic bounding box for a tabular dataset containing a latitude and longitude column. Inputs are a CSV file, the column names for longitude and latitude, the field delimiter (comma, tab, semicolon, etc.), and a dataset id used to name output files. Coordinate values must be in decimal degrees, WGS84.

The code handles datasets in the -180/180 space, the 0/360 space, and datasets crossing the antimeridian (or both the antimeridian and prime meridian). The output is always a simple rectangular bounding box (or two rectangles joined as a MultiPolygon when it's split at the antimeridian), it does not support holes or more complex polygon shapes, just the smallest enclosing rectangle around the points.

The workflow loads a CSV file, extracts valid coordinate columns, calculates the smallest longitude interval containing the points, splits the bounding box if it crosses the antimeridian, and exports a GeoJSON file, a JPG preview map, and a WKT file. It also prints (but does not save) the OGC Bounding Box: [west, south, east, north].

Setup

Install dependencies with:

pip install -r requirements.txt

Make sure you run this in the same Python environment you'll use to open the notebook — e.g. conda activate <env_name> before installing, then select that same environment as the kernel in Jupyter or VS Code. Then open demo_bounding_box.ipynb in Jupyter or VS Code and run the cells.

Code

  • bounding_box.py: core library, loads and validates a CSV's coordinate columns, finds the tightest longitude interval (handling antimeridian wraparound), builds the rectangular bounding box geometry, splits it at the antimeridian if needed, and exports the result as GeoJSON, a JPG preview plot, and WKT.
  • dataset_configs.py: example dataset configurations (CSV URL, delimiter, longitude/latitude column names, dataset id) used to run the pipeline against specific datasets.
  • run_bounding_box.py: script entry point that runs the full pipeline end-to-end for a single dataset config, as an alternative to the notebook.
  • set_paths.py: resolves the project root and defines the code/, notebooks/, and output/ directory paths used by the other scripts.

Folder Structure

bounding_box/
├── code/
│   ├── bounding_box.py
│   ├── dataset_configs.py
│   ├── run_bounding_box.py
│   └── set_paths.py
├── notebooks/
│   └── demo_bounding_box.ipynb
├── outputs/
│   ├── output_dataset_<id>.geojson
│   └── output_dataset_<id>.jpg
|   |__ output_dataset_<id>.wkt
└── README.md

Standards Compliance

  • Geometry: Antimeridian-crossing geometries are split into a MultiPolygon, per RFC 7946 §3.1.9, which says such geometries "SHOULD be represented by cutting it in two such that neither part's representation crosses the antimeridian."
  • Bounding box: Crossing bboxes use the west > east convention from RFC 7946 §5.2 and OGC API - Features — west (min longitude) is numerically greater than east (max longitude).

About

Computes a geographic bounding box for a tabular dataset containing a latitude and longitude column, specifically deals with antimeridian crossings

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages