geojson-diff 0.1.1__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. geojson_diff-0.2.0/CHANGELOG.md +88 -0
  2. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/CITATION.cff +5 -4
  3. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/MANIFEST.in +1 -0
  4. geojson_diff-0.2.0/PKG-INFO +229 -0
  5. geojson_diff-0.2.0/README.md +185 -0
  6. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/pyproject.toml +21 -15
  7. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/__init__.py +1 -1
  8. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/cli.py +53 -4
  9. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/core.py +6 -0
  10. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/render/html.py +61 -9
  11. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/render/markdown.py +1 -0
  12. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/tolerance.py +4 -3
  13. geojson_diff-0.2.0/src/geojson_diff.egg-info/PKG-INFO +229 -0
  14. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/test_cli_git.py +27 -0
  15. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/test_diff.py +17 -0
  16. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/test_render.py +57 -1
  17. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/test_tolerance_io.py +3 -1
  18. geojson_diff-0.1.1/CHANGELOG.md +0 -42
  19. geojson_diff-0.1.1/PKG-INFO +0 -478
  20. geojson_diff-0.1.1/README.md +0 -438
  21. geojson_diff-0.1.1/src/geojson_diff.egg-info/PKG-INFO +0 -478
  22. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/LICENSE +0 -0
  23. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/examples/github-actions/geojson-diff.yml +0 -0
  24. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/examples/parcels_v1.geojson +0 -0
  25. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/examples/parcels_v2.geojson +0 -0
  26. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/setup.cfg +0 -0
  27. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/__main__.py +0 -0
  28. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/_shapely.py +0 -0
  29. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/geometry.py +0 -0
  30. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/git.py +0 -0
  31. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/io.py +0 -0
  32. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/matching.py +0 -0
  33. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/properties.py +0 -0
  34. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/py.typed +0 -0
  35. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/render/__init__.py +0 -0
  36. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/render/layer.py +0 -0
  37. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/render/machine.py +0 -0
  38. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff/render/text.py +0 -0
  39. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/SOURCES.txt +0 -0
  40. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/dependency_links.txt +0 -0
  41. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/entry_points.txt +0 -0
  42. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/requires.txt +0 -0
  43. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/top_level.txt +0 -0
  44. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/conftest.py +0 -0
  45. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/test_geometry_properties.py +0 -0
  46. {geojson_diff-0.1.1 → geojson_diff-0.2.0}/tests/test_shapely_examples.py +0 -0
@@ -0,0 +1,88 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
5
+ project uses [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] - 2026-12-02
10
+ ### Added
11
+ - `--tiles NAME|URL` and `--attribution HTML` for the HTML report. `render(result, "html",
12
+ tiles=...)` takes the basemap names `esri` and `osm` or a URL template;
13
+ `geojson_diff.render.html` exports `BASEMAPS`, `ESRI_TILES`, `ESRI_ATTRIBUTION`, `OSM_TILES`
14
+ and `basemap()`.
15
+ - Usage guide `docs/guide.md`: matching, tolerances, reports, git and CI recipes, and the
16
+ geometry behind the comparison (haversine, Hausdorff, spherical area, spatial matching
17
+ score, geometry hash) as KaTeX formulas. Figures in `docs/assets/`, regenerated by
18
+ `docs/assets/make_assets.py`.
19
+
20
+ ### Changed
21
+ - Releases are signed with PEP 740 attestations from the GitLab pipeline (Trusted Publishing identity), so PyPI shows verified provenance for every file.
22
+ - The PyPI "Documentation" link opens the package page on geophilo.com.
23
+ - A custom tile URL without `attribution` gets no credit line instead of the OpenStreetMap
24
+ one; named basemaps bring their own.
25
+ - README rebuilt around a hero figure, a quickstart with real output and verified related
26
+ packages; the long reference sections moved to the guide. PyPI metadata: `spatial-diff`
27
+ and `merge-request` keywords and the `Natural Language :: English` classifier.
28
+ `MANIFEST.in` keeps `docs/` out of the sdist.
29
+
30
+ ### Fixed
31
+ - The HTML report's map uses Esri's World Light Gray Canvas by default, credited to Esri and
32
+ its data providers. The default was OpenStreetMap's tile server, whose usage policy asks web
33
+ pages for a valid HTTP Referer; a report opened from disk (`file://`), such as a downloaded
34
+ CI artifact, cannot send one, so its tiles could be refused. OpenStreetMap stays available
35
+ with `--tiles osm`. The light grey tiles stop at zoom 16, so the map scales them beyond that.
36
+
37
+ ## [0.1.2] - 2026-11-15
38
+ ### Fixed
39
+ - `precision` outside 0-15 is rejected (`DiffOptions`, `--precision`): a negative value
40
+ rounded geometry hashes to tens of degrees and matched unrelated features.
41
+ - `min_score` outside [0, 1] (or NaN) is rejected instead of silently dropping every
42
+ spatial match.
43
+ - A negative `max_rows` / `--max-rows` no longer slices rows from the end of the
44
+ Markdown and HTML tables and prints a wrong "more changes" count.
45
+ - Tolerances written with a trailing decimal point (`"1.m"`) are accepted; infinite
46
+ tolerances are rejected.
47
+ ### Changed
48
+ - Project links, citation metadata and CI moved to GitLab (https://gitlab.com/geophilo1/geojson_diff_sdk);
49
+ GitHub workflows removed, GitLab CI pipeline added (Python 3.9, 3.11, 3.13; tagged releases to PyPI).
50
+ - README: GitLab pipeline and downloads badges, absolute links that work on PyPI, related packages.
51
+ - PyPI metadata: refined description and keywords, Education audience classifier,
52
+ SDK dashboard / DOI links.
53
+
54
+ ## [0.1.1] - 2026-11-09
55
+ ### Changed
56
+ - Release archived on Zenodo, which mints the citable DOI; no code changes.
57
+
58
+ ## [0.1.0] - 2026-11-08
59
+ ### Added
60
+ - **Diff engine** (`geojson_diff.diff`): compares two GeoJSON FeatureCollections,
61
+ GeoJSONSeq (RFC 8142) or newline-delimited GeoJSON files feature by feature and
62
+ classifies every feature as `added`, `removed`, `modified` (properties only),
63
+ `moved` (geometry changed beyond the tolerance) or `unchanged`.
64
+ - **Matching strategies**, chainable in order: feature `id`, property `key`(s)
65
+ (composite and dotted nested keys), normalised geometry `hash` and `spatial`
66
+ (centroid proximity plus attribute similarity with a deterministic greedy
67
+ assignment). `auto` uses `key` when keys are given, else `id` then `hash`.
68
+ - **Property diff**: nested objects and arrays with RFC 6901 paths, JSON type
69
+ tracking (`integer -> number`), `--strict-types`, ignored properties.
70
+ - **Geometry diff**: tolerance in metres (haversine) or degrees, Hausdorff
71
+ distance (pure Python, early-break), vertex added/removed/moved counts,
72
+ centroid shift, area and length deltas (spherical), bounding box of changes;
73
+ ring rotation, orientation and collinear extra vertices do not count as changes.
74
+ - **Outputs**: coloured terminal text, JSON-Patch-like machine output, Markdown
75
+ for pull-request comments (optional `geojson` map block), a GeoJSON diff layer
76
+ styled with simplestyle-spec properties and a self-contained HTML report with a
77
+ Leaflet before/after map. All data values are escaped.
78
+ - **Git integration**: `geojson-diff --textconv` and `geojson-diff --git`
79
+ (external diff driver) plus the `git-geojson-diff REV1 [REV2] PATH` helper.
80
+ - **CI**: exit codes 0 / 1 / 2, `--fail-on removed,moved:5`, `--exit-zero` and a
81
+ GitHub Actions example that posts the Markdown summary on pull requests.
82
+ - **Streaming reader**: features are decoded one at a time; with an indexable first
83
+ strategy the new file is streamed against an index of the old one.
84
+ - Optional `shapely` extra for topological equality and symmetric-difference area.
85
+
86
+ [Unreleased]: https://gitlab.com/geophilo1/geojson_diff_sdk"/-/compare/v0.2.0...HEAD
87
+ [0.2.0]: https://gitlab.com/geophilo1/geojson_diff_sdk"/-/compare/v0.1.2...v0.2.0
88
+ [0.1.0]: https://gitlab.com/geophilo1/geojson_diff_sdk/-/tags/v0.1.0
@@ -3,13 +3,14 @@ message: "If you use this software, please cite it as below."
3
3
  authors:
4
4
  - family-names: "Eminoğlu"
5
5
  given-names: "Yusuf"
6
- email: "yusufeminoglu@gmail.com"
6
+ email: "geospacephilo@gmail.com"
7
7
  orcid: "https://orcid.org/0009-0005-6000-2934"
8
8
  title: "geojson-diff"
9
- version: "0.1.1"
10
- date-released: "2026-11-09"
9
+ version: "0.2.0"
10
+ date-released: "2026-12-02"
11
+ doi: "10.5281/zenodo.24063377"
11
12
  license: "MIT"
12
- repository-code: "https://github.com/YusufEminoglu/geojson_diff_sdk"
13
+ repository-code: "https://gitlab.com/geophilo1/geojson_diff_sdk"
13
14
  url: "https://pypi.org/project/geojson-diff/"
14
15
  abstract: "Feature-level diffs of GeoJSON datasets for code review, pull requests and data pipelines, with tolerance-aware geometry comparison, typed property diffs, text/JSON/Markdown/GeoJSON/HTML reports, a git diff driver and CI exit codes."
15
16
  keywords:
@@ -7,3 +7,4 @@ include src/geojson_diff/py.typed
7
7
  recursive-include src/geojson_diff *.py
8
8
  recursive-include tests *.py
9
9
  recursive-include examples *.geojson *.yml
10
+ prune docs
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: geojson-diff
3
+ Version: 0.2.0
4
+ Summary: Compare two GeoJSON files feature by feature: added, removed, modified and moved features with tolerances in metres, text/JSON/Markdown/HTML map reports, a git diff driver and CI exit codes.
5
+ Author-email: Yusuf Eminoğlu <geospacephilo@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://gitlab.com/geophilo1/geojson_diff_sdk
8
+ Project-URL: Repository, https://gitlab.com/geophilo1/geojson_diff_sdk
9
+ Project-URL: Documentation, https://geophilo.com/sdks/geojson-diff/
10
+ Project-URL: Issues, https://gitlab.com/geophilo1/geojson_diff_sdk/-/work_items
11
+ Project-URL: Changelog, https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CHANGELOG.md
12
+ Project-URL: SDK dashboard, https://geophilo.com/sdk-dashboard/
13
+ Project-URL: DOI, https://doi.org/10.5281/zenodo.24063377
14
+ Keywords: geojson,geojson-diff,diff,compare-geojson,change-detection,git-diff,code-review,pull-request,data-pipeline,data-quality,hausdorff,geojsonseq,leaflet,spatial-diff,merge-request,gis
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Natural Language :: English
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Environment :: Console
25
+ Classifier: Topic :: Scientific/Engineering :: GIS
26
+ Classifier: Topic :: Software Development :: Quality Assurance
27
+ Classifier: Topic :: Software Development :: Version Control :: Git
28
+ Classifier: Topic :: Utilities
29
+ Classifier: Intended Audience :: Science/Research
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: Intended Audience :: Education
32
+ Classifier: Typing :: Typed
33
+ Requires-Python: >=3.9
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Provides-Extra: shapely
37
+ Requires-Dist: shapely>=2.0.0; extra == "shapely"
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
40
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
41
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ <p align="center">
46
+ <a href="https://geophilo.com/sdks/geojson-diff/"><img src="https://geophilo.com/assets/sdk_icons/geojson_diff_sdk.svg" width="120" height="120" alt="geojson-diff icon"></a>
47
+ </p>
48
+
49
+ # geojson-diff
50
+
51
+ [![PyPI version](https://img.shields.io/pypi/v/geojson-diff.svg)](https://pypi.org/project/geojson-diff/)
52
+ [![Python versions](https://img.shields.io/pypi/pyversions/geojson-diff.svg)](https://pypi.org/project/geojson-diff/)
53
+ [![pipeline status](https://gitlab.com/geophilo1/geojson_diff_sdk/badges/main/pipeline.svg)](https://gitlab.com/geophilo1/geojson_diff_sdk/-/pipelines)
54
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/LICENSE)
55
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24063377.svg)](https://doi.org/10.5281/zenodo.24063377)
56
+ [![Downloads](https://static.pepy.tech/badge/geojson-diff/month)](https://pepy.tech/project/geojson-diff)
57
+
58
+ **Feature-level diffs of GeoJSON for code review and data pipelines: which features were
59
+ added, removed, modified or moved, with tolerances in metres, as terminal text, a pull request
60
+ comment, a map report or a CI exit code, in pure Python with no required dependencies.**
61
+
62
+ <p align="center"><img src="https://gitlab.com/geophilo1/geojson_diff_sdk/-/raw/main/docs/assets/hero.svg" width="820" alt="The diff of two versions of a small parcel dataset at a 0.5 m tolerance: a map with the added cafe in green, the removed shed in red, the modified parcel in orange, the moved road in blue over its dashed old line and two unchanged features in grey, with a 50 m scale bar; beside it the counts (1 added, 1 removed, 1 modified, 1 moved, 2 unchanged) and the change details, such as height 12 to 14.5 and a Hausdorff distance of 21.0 m for the road."></p>
63
+
64
+ ## Why geojson-diff?
65
+
66
+ - **Features, not lines.** A line diff says that some line of a large file changed;
67
+ geojson-diff says which parcel got a new height, which bus stop moved how far and which
68
+ buildings were removed.
69
+ - **Tolerant where it should be.** Geometries are compared within a tolerance in metres
70
+ (haversine on lon/lat data) or CRS units; a rotated ring start, a flipped orientation or an
71
+ extra collinear vertex is not a change.
72
+ - **Matches features four ways.** By `id`, by property keys (composite and nested), by a
73
+ normalised geometry hash, or spatially by proximity and attribute similarity, in a chain,
74
+ with a deterministic assignment.
75
+ - **Fits review workflows.** Coloured text, patch-like JSON, Markdown for merge request and
76
+ pull request comments, a styled GeoJSON diff layer, a single-file HTML map report, a git
77
+ diff driver and CI exit codes with `--fail-on` thresholds.
78
+ - **Streams big files.** One feature at a time; two 50.7 MB FeatureCollections of 100 000
79
+ polygons diff in about 15 s on a laptop.
80
+ - **Tested.** 122 tests, 96 % line and branch coverage (measured 2026-11-26), mypy-clean, ships
81
+ `py.typed`.
82
+
83
+ ## Installation
84
+
85
+ ```bash
86
+ pip install geojson-diff
87
+ ```
88
+
89
+ | Extra | Adds | Install |
90
+ | --- | --- | --- |
91
+ | `shapely` | exact topological equality and symmetric-difference areas (`--shapely`) | `pip install "geojson-diff[shapely]"` |
92
+
93
+ Python 3.9 to 3.13 on Windows, macOS and Linux.
94
+
95
+ ## Quickstart
96
+
97
+ ```python
98
+ from geojson_diff import diff, render
99
+
100
+
101
+ def points(*rows):
102
+ return {"type": "FeatureCollection", "features": [
103
+ {"type": "Feature", "id": fid, "properties": props,
104
+ "geometry": {"type": "Point", "coordinates": xy}} for fid, xy, props in rows]}
105
+
106
+
107
+ old = points((1, [29.0, 41.0], {"name": "Library", "floors": 2}),
108
+ (2, [29.001, 41.001], {"name": "Bus stop"}),
109
+ (3, [29.002, 41.0], {"name": "Kiosk"}))
110
+ new = points((1, [29.0, 41.0], {"name": "Library", "floors": 3}),
111
+ (2, [29.00125, 41.001], {"name": "Bus stop"}),
112
+ (4, [29.003, 41.0], {"name": "Cafe"}))
113
+ result = diff(old, new, tolerance="0.5m")
114
+ print(render(result, "text"))
115
+ print(result.counts, result.has_changes)
116
+ ```
117
+
118
+ ```text
119
+ geojson-diff <object> -> <object>
120
+ 3 -> 3 features: 1 added, 1 removed, 1 modified, 1 moved, 0 unchanged
121
+ matched by id, hash; tolerance 0.5 m
122
+
123
+ + added 4 Point
124
+ name: "Cafe"
125
+ - removed 3 Point
126
+ name: "Kiosk"
127
+ ~ modified 1 Point
128
+ floors: 2 -> 3
129
+ > moved 2 Point
130
+ geometry: Hausdorff 21.0 m, centroid shift 21.0 m, vertices 1 moved (1 -> 1)
131
+
132
+ bbox of changes: [29.000000, 41.000000, 29.003000, 41.001000]
133
+ area delta 0.0 m2, length delta 0 m
134
+
135
+ {'added': 1, 'removed': 1, 'modified': 1, 'moved': 1, 'unchanged': 0} True
136
+ ```
137
+
138
+ `diff()` also takes file paths, open files, GeoJSONSeq and plain iterables of features.
139
+
140
+ ## Command line
141
+
142
+ ```text
143
+ $ geojson-diff --help
144
+ usage: geojson-diff [-h] [-V] [--textconv | --git] [-k PROP] [-m STRATEGIES] [--max-distance DIST]
145
+ [--attribute-weight W] [--min-score S] [--precision N] [-t TOL]
146
+ [--crs {auto,geographic,projected}] [-i PROP] [--strict-types] [--shapely]
147
+ [-f {text,json,md,geojson,html}] [-o FILE] [--color {auto,always,never}]
148
+ [--show-unchanged] [--max-rows N] [--title TITLE] [--tiles NAME|URL]
149
+ [--attribution HTML] [--md-map] [-q] [--fail-on LIST] [--exit-zero]
150
+ [PATH ...]
151
+
152
+ Diff two GeoJSON FeatureCollections (or GeoJSONSeq files) feature by feature. Exit status: 0 no
153
+ changes, 1 changes, 2 error.
154
+ ```
155
+
156
+ ```bash
157
+ geojson-diff old.geojson new.geojson --tolerance 0.5m --key parcel_id
158
+ geojson-diff old.geojson new.geojson -t 0.5m -f md --fail-on removed:10,moved:0
159
+ geojson-diff old.geojson new.geojson -t 0.5m -o review.html # map report
160
+ git-geojson-diff HEAD~1 HEAD data/parcels.geojson # two revisions of a file
161
+ ```
162
+
163
+ The HTML report uses Esri's light grey basemap, which also loads when the file is opened from
164
+ disk; `--tiles osm` switches to OpenStreetMap for reports served over HTTP(S), and any tile
165
+ URL template works with `--attribution`.
166
+
167
+ ## Features
168
+
169
+ | Status | Meaning |
170
+ | --- | --- |
171
+ | `added` | only in the new file |
172
+ | `removed` | only in the old file |
173
+ | `modified` | matched, properties (or the feature `id`) changed, geometry within tolerance |
174
+ | `moved` | matched, geometry changed beyond the tolerance (property changes are listed too) |
175
+ | `unchanged` | matched, nothing changed |
176
+
177
+ | Area | What you get |
178
+ | --- | --- |
179
+ | Matching | `--match id,key,hash,spatial` chains; `--key` for composite and dotted keys; `--max-distance`, `--attribute-weight`, `--min-score` for spatial matching |
180
+ | Geometry | tolerances such as `0.5m`, `10cm`, `2ft` or `1e-6deg`; Hausdorff distance, vertex changes, centroid shift, area and length deltas, bbox of changes |
181
+ | Properties | typed, nested diffs with RFC 6901 JSON Pointer paths; `--ignore-property`, `--strict-types` |
182
+ | Outputs | `text`, `json`, `md`, `geojson` (simplestyle diff layer), `html` (Leaflet map report) |
183
+ | Git and CI | `--textconv`, `--git` external diff driver, `git-geojson-diff`, exit codes, `--fail-on` thresholds |
184
+ | Python | `diff`, `render`, `diff_layer`, `compare_geometry`, `diff_properties`, `hausdorff_distance`, `haversine`, `geometry_hash` |
185
+
186
+ ## Documentation
187
+
188
+ - Usage guide (matching, tolerances, reports, git and CI recipes, and the geometry behind the
189
+ comparisons): https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/docs/guide.md
190
+ - Package page: https://geophilo.com/sdks/geojson-diff/
191
+ - Changelog: https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CHANGELOG.md
192
+
193
+ | API | What it does |
194
+ | --- | --- |
195
+ | `diff(old, new, options=None, **overrides)` | a `DiffResult` with `changes`, `counts`, `bbox`, `area_delta`, `length_delta` |
196
+ | `render(result, fmt, **kwargs)` | text, JSON, Markdown, GeoJSON layer or HTML report |
197
+ | `diff_layer(result)` | the styled diff layer as a dict |
198
+ | `DiffOptions` | matching, tolerance, precision and property settings |
199
+ | `hausdorff_distance`, `haversine`, `geometry_hash` | the geometry helpers behind the comparison |
200
+
201
+ ## Related packages
202
+
203
+ - [geofix](https://pypi.org/project/geofix/): validate and repair GeoJSON; geojson-diff on the
204
+ input and output of `geofix fix` shows the repair feature by feature.
205
+ - [geocsv](https://pypi.org/project/geocsv/): converts CSV exports of places to GeoJSON, so two
206
+ CSV snapshots can be diffed with `--key name`.
207
+ - [gpkglite](https://pypi.org/project/gpkglite/): `gpkglite dump` turns GeoPackage layers into
208
+ GeoJSON that geojson-diff compares, without GDAL.
209
+
210
+ ## Citation
211
+
212
+ If geojson-diff helps your work, please cite the archived release,
213
+ [10.5281/zenodo.24063377](https://doi.org/10.5281/zenodo.24063377) (metadata in
214
+ [CITATION.cff](https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CITATION.cff)):
215
+
216
+ ```bibtex
217
+ @software{eminoglu_geojson_diff,
218
+ author = {Eminoğlu, Yusuf},
219
+ title = {geojson-diff},
220
+ year = {2026},
221
+ version = {0.2.0},
222
+ doi = {10.5281/zenodo.24063377},
223
+ url = {https://doi.org/10.5281/zenodo.24063377}
224
+ }
225
+ ```
226
+
227
+ ## License
228
+
229
+ MIT © 2026 Yusuf Eminoğlu. See [LICENSE](https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/LICENSE).
@@ -0,0 +1,185 @@
1
+ <p align="center">
2
+ <a href="https://geophilo.com/sdks/geojson-diff/"><img src="https://geophilo.com/assets/sdk_icons/geojson_diff_sdk.svg" width="120" height="120" alt="geojson-diff icon"></a>
3
+ </p>
4
+
5
+ # geojson-diff
6
+
7
+ [![PyPI version](https://img.shields.io/pypi/v/geojson-diff.svg)](https://pypi.org/project/geojson-diff/)
8
+ [![Python versions](https://img.shields.io/pypi/pyversions/geojson-diff.svg)](https://pypi.org/project/geojson-diff/)
9
+ [![pipeline status](https://gitlab.com/geophilo1/geojson_diff_sdk/badges/main/pipeline.svg)](https://gitlab.com/geophilo1/geojson_diff_sdk/-/pipelines)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/LICENSE)
11
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24063377.svg)](https://doi.org/10.5281/zenodo.24063377)
12
+ [![Downloads](https://static.pepy.tech/badge/geojson-diff/month)](https://pepy.tech/project/geojson-diff)
13
+
14
+ **Feature-level diffs of GeoJSON for code review and data pipelines: which features were
15
+ added, removed, modified or moved, with tolerances in metres, as terminal text, a pull request
16
+ comment, a map report or a CI exit code, in pure Python with no required dependencies.**
17
+
18
+ <p align="center"><img src="https://gitlab.com/geophilo1/geojson_diff_sdk/-/raw/main/docs/assets/hero.svg" width="820" alt="The diff of two versions of a small parcel dataset at a 0.5 m tolerance: a map with the added cafe in green, the removed shed in red, the modified parcel in orange, the moved road in blue over its dashed old line and two unchanged features in grey, with a 50 m scale bar; beside it the counts (1 added, 1 removed, 1 modified, 1 moved, 2 unchanged) and the change details, such as height 12 to 14.5 and a Hausdorff distance of 21.0 m for the road."></p>
19
+
20
+ ## Why geojson-diff?
21
+
22
+ - **Features, not lines.** A line diff says that some line of a large file changed;
23
+ geojson-diff says which parcel got a new height, which bus stop moved how far and which
24
+ buildings were removed.
25
+ - **Tolerant where it should be.** Geometries are compared within a tolerance in metres
26
+ (haversine on lon/lat data) or CRS units; a rotated ring start, a flipped orientation or an
27
+ extra collinear vertex is not a change.
28
+ - **Matches features four ways.** By `id`, by property keys (composite and nested), by a
29
+ normalised geometry hash, or spatially by proximity and attribute similarity, in a chain,
30
+ with a deterministic assignment.
31
+ - **Fits review workflows.** Coloured text, patch-like JSON, Markdown for merge request and
32
+ pull request comments, a styled GeoJSON diff layer, a single-file HTML map report, a git
33
+ diff driver and CI exit codes with `--fail-on` thresholds.
34
+ - **Streams big files.** One feature at a time; two 50.7 MB FeatureCollections of 100 000
35
+ polygons diff in about 15 s on a laptop.
36
+ - **Tested.** 122 tests, 96 % line and branch coverage (measured 2026-11-26), mypy-clean, ships
37
+ `py.typed`.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install geojson-diff
43
+ ```
44
+
45
+ | Extra | Adds | Install |
46
+ | --- | --- | --- |
47
+ | `shapely` | exact topological equality and symmetric-difference areas (`--shapely`) | `pip install "geojson-diff[shapely]"` |
48
+
49
+ Python 3.9 to 3.13 on Windows, macOS and Linux.
50
+
51
+ ## Quickstart
52
+
53
+ ```python
54
+ from geojson_diff import diff, render
55
+
56
+
57
+ def points(*rows):
58
+ return {"type": "FeatureCollection", "features": [
59
+ {"type": "Feature", "id": fid, "properties": props,
60
+ "geometry": {"type": "Point", "coordinates": xy}} for fid, xy, props in rows]}
61
+
62
+
63
+ old = points((1, [29.0, 41.0], {"name": "Library", "floors": 2}),
64
+ (2, [29.001, 41.001], {"name": "Bus stop"}),
65
+ (3, [29.002, 41.0], {"name": "Kiosk"}))
66
+ new = points((1, [29.0, 41.0], {"name": "Library", "floors": 3}),
67
+ (2, [29.00125, 41.001], {"name": "Bus stop"}),
68
+ (4, [29.003, 41.0], {"name": "Cafe"}))
69
+ result = diff(old, new, tolerance="0.5m")
70
+ print(render(result, "text"))
71
+ print(result.counts, result.has_changes)
72
+ ```
73
+
74
+ ```text
75
+ geojson-diff <object> -> <object>
76
+ 3 -> 3 features: 1 added, 1 removed, 1 modified, 1 moved, 0 unchanged
77
+ matched by id, hash; tolerance 0.5 m
78
+
79
+ + added 4 Point
80
+ name: "Cafe"
81
+ - removed 3 Point
82
+ name: "Kiosk"
83
+ ~ modified 1 Point
84
+ floors: 2 -> 3
85
+ > moved 2 Point
86
+ geometry: Hausdorff 21.0 m, centroid shift 21.0 m, vertices 1 moved (1 -> 1)
87
+
88
+ bbox of changes: [29.000000, 41.000000, 29.003000, 41.001000]
89
+ area delta 0.0 m2, length delta 0 m
90
+
91
+ {'added': 1, 'removed': 1, 'modified': 1, 'moved': 1, 'unchanged': 0} True
92
+ ```
93
+
94
+ `diff()` also takes file paths, open files, GeoJSONSeq and plain iterables of features.
95
+
96
+ ## Command line
97
+
98
+ ```text
99
+ $ geojson-diff --help
100
+ usage: geojson-diff [-h] [-V] [--textconv | --git] [-k PROP] [-m STRATEGIES] [--max-distance DIST]
101
+ [--attribute-weight W] [--min-score S] [--precision N] [-t TOL]
102
+ [--crs {auto,geographic,projected}] [-i PROP] [--strict-types] [--shapely]
103
+ [-f {text,json,md,geojson,html}] [-o FILE] [--color {auto,always,never}]
104
+ [--show-unchanged] [--max-rows N] [--title TITLE] [--tiles NAME|URL]
105
+ [--attribution HTML] [--md-map] [-q] [--fail-on LIST] [--exit-zero]
106
+ [PATH ...]
107
+
108
+ Diff two GeoJSON FeatureCollections (or GeoJSONSeq files) feature by feature. Exit status: 0 no
109
+ changes, 1 changes, 2 error.
110
+ ```
111
+
112
+ ```bash
113
+ geojson-diff old.geojson new.geojson --tolerance 0.5m --key parcel_id
114
+ geojson-diff old.geojson new.geojson -t 0.5m -f md --fail-on removed:10,moved:0
115
+ geojson-diff old.geojson new.geojson -t 0.5m -o review.html # map report
116
+ git-geojson-diff HEAD~1 HEAD data/parcels.geojson # two revisions of a file
117
+ ```
118
+
119
+ The HTML report uses Esri's light grey basemap, which also loads when the file is opened from
120
+ disk; `--tiles osm` switches to OpenStreetMap for reports served over HTTP(S), and any tile
121
+ URL template works with `--attribution`.
122
+
123
+ ## Features
124
+
125
+ | Status | Meaning |
126
+ | --- | --- |
127
+ | `added` | only in the new file |
128
+ | `removed` | only in the old file |
129
+ | `modified` | matched, properties (or the feature `id`) changed, geometry within tolerance |
130
+ | `moved` | matched, geometry changed beyond the tolerance (property changes are listed too) |
131
+ | `unchanged` | matched, nothing changed |
132
+
133
+ | Area | What you get |
134
+ | --- | --- |
135
+ | Matching | `--match id,key,hash,spatial` chains; `--key` for composite and dotted keys; `--max-distance`, `--attribute-weight`, `--min-score` for spatial matching |
136
+ | Geometry | tolerances such as `0.5m`, `10cm`, `2ft` or `1e-6deg`; Hausdorff distance, vertex changes, centroid shift, area and length deltas, bbox of changes |
137
+ | Properties | typed, nested diffs with RFC 6901 JSON Pointer paths; `--ignore-property`, `--strict-types` |
138
+ | Outputs | `text`, `json`, `md`, `geojson` (simplestyle diff layer), `html` (Leaflet map report) |
139
+ | Git and CI | `--textconv`, `--git` external diff driver, `git-geojson-diff`, exit codes, `--fail-on` thresholds |
140
+ | Python | `diff`, `render`, `diff_layer`, `compare_geometry`, `diff_properties`, `hausdorff_distance`, `haversine`, `geometry_hash` |
141
+
142
+ ## Documentation
143
+
144
+ - Usage guide (matching, tolerances, reports, git and CI recipes, and the geometry behind the
145
+ comparisons): https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/docs/guide.md
146
+ - Package page: https://geophilo.com/sdks/geojson-diff/
147
+ - Changelog: https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CHANGELOG.md
148
+
149
+ | API | What it does |
150
+ | --- | --- |
151
+ | `diff(old, new, options=None, **overrides)` | a `DiffResult` with `changes`, `counts`, `bbox`, `area_delta`, `length_delta` |
152
+ | `render(result, fmt, **kwargs)` | text, JSON, Markdown, GeoJSON layer or HTML report |
153
+ | `diff_layer(result)` | the styled diff layer as a dict |
154
+ | `DiffOptions` | matching, tolerance, precision and property settings |
155
+ | `hausdorff_distance`, `haversine`, `geometry_hash` | the geometry helpers behind the comparison |
156
+
157
+ ## Related packages
158
+
159
+ - [geofix](https://pypi.org/project/geofix/): validate and repair GeoJSON; geojson-diff on the
160
+ input and output of `geofix fix` shows the repair feature by feature.
161
+ - [geocsv](https://pypi.org/project/geocsv/): converts CSV exports of places to GeoJSON, so two
162
+ CSV snapshots can be diffed with `--key name`.
163
+ - [gpkglite](https://pypi.org/project/gpkglite/): `gpkglite dump` turns GeoPackage layers into
164
+ GeoJSON that geojson-diff compares, without GDAL.
165
+
166
+ ## Citation
167
+
168
+ If geojson-diff helps your work, please cite the archived release,
169
+ [10.5281/zenodo.24063377](https://doi.org/10.5281/zenodo.24063377) (metadata in
170
+ [CITATION.cff](https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CITATION.cff)):
171
+
172
+ ```bibtex
173
+ @software{eminoglu_geojson_diff,
174
+ author = {Eminoğlu, Yusuf},
175
+ title = {geojson-diff},
176
+ year = {2026},
177
+ version = {0.2.0},
178
+ doi = {10.5281/zenodo.24063377},
179
+ url = {https://doi.org/10.5281/zenodo.24063377}
180
+ }
181
+ ```
182
+
183
+ ## License
184
+
185
+ MIT © 2026 Yusuf Eminoğlu. See [LICENSE](https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/LICENSE).
@@ -4,26 +4,28 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "geojson-diff"
7
- version = "0.1.1"
7
+ version = "0.2.0"
8
8
  authors = [
9
- { name = "Yusuf Eminoğlu", email = "yusufeminoglu@gmail.com" }
9
+ { name = "Yusuf Eminoğlu", email = "geospacephilo@gmail.com" }
10
10
  ]
11
- description = "Feature-level diffs of GeoJSON datasets for code review, pull requests and data pipelines: text, JSON, Markdown, GeoJSON and HTML map reports, git diff driver and CI exit codes."
11
+ description = "Compare two GeoJSON files feature by feature: added, removed, modified and moved features with tolerances in metres, text/JSON/Markdown/HTML map reports, a git diff driver and CI exit codes."
12
12
  keywords = [
13
13
  "geojson",
14
+ "geojson-diff",
14
15
  "diff",
15
- "gis",
16
- "geospatial",
17
- "git",
16
+ "compare-geojson",
17
+ "change-detection",
18
+ "git-diff",
18
19
  "code-review",
19
20
  "pull-request",
20
21
  "data-pipeline",
21
- "ci",
22
- "geojsonseq",
22
+ "data-quality",
23
23
  "hausdorff",
24
+ "geojsonseq",
24
25
  "leaflet",
25
- "change-detection",
26
- "data-quality",
26
+ "spatial-diff",
27
+ "merge-request",
28
+ "gis",
27
29
  ]
28
30
  readme = "README.md"
29
31
  license = "MIT"
@@ -37,6 +39,7 @@ classifiers = [
37
39
  "Programming Language :: Python :: 3.11",
38
40
  "Programming Language :: Python :: 3.12",
39
41
  "Programming Language :: Python :: 3.13",
42
+ "Natural Language :: English",
40
43
  "Operating System :: OS Independent",
41
44
  "Environment :: Console",
42
45
  "Topic :: Scientific/Engineering :: GIS",
@@ -45,6 +48,7 @@ classifiers = [
45
48
  "Topic :: Utilities",
46
49
  "Intended Audience :: Science/Research",
47
50
  "Intended Audience :: Developers",
51
+ "Intended Audience :: Education",
48
52
  "Typing :: Typed",
49
53
  ]
50
54
  dependencies = []
@@ -65,11 +69,13 @@ geojson-diff = "geojson_diff.cli:main"
65
69
  git-geojson-diff = "geojson_diff.cli:git_main"
66
70
 
67
71
  [project.urls]
68
- Homepage = "https://github.com/YusufEminoglu/geojson_diff_sdk"
69
- Repository = "https://github.com/YusufEminoglu/geojson_diff_sdk"
70
- Issues = "https://github.com/YusufEminoglu/geojson_diff_sdk/issues"
71
- Documentation = "https://github.com/YusufEminoglu/geojson_diff_sdk#readme"
72
- Changelog = "https://github.com/YusufEminoglu/geojson_diff_sdk/blob/main/CHANGELOG.md"
72
+ Homepage = "https://gitlab.com/geophilo1/geojson_diff_sdk"
73
+ Repository = "https://gitlab.com/geophilo1/geojson_diff_sdk"
74
+ Documentation = "https://geophilo.com/sdks/geojson-diff/"
75
+ Issues = "https://gitlab.com/geophilo1/geojson_diff_sdk/-/work_items"
76
+ Changelog = "https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CHANGELOG.md"
77
+ "SDK dashboard" = "https://geophilo.com/sdk-dashboard/"
78
+ DOI = "https://doi.org/10.5281/zenodo.24063377"
73
79
 
74
80
  [tool.setuptools]
75
81
  package-dir = {"" = "src"}
@@ -8,7 +8,7 @@
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
- __version__ = "0.1.1"
11
+ __version__ = "0.2.0"
12
12
 
13
13
  from .core import (
14
14
  STATUSES,