geojson-diff 0.1.2__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 (45) hide show
  1. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/CHANGELOG.md +30 -1
  2. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/CITATION.cff +2 -2
  3. {geojson_diff-0.1.2 → 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.2 → geojson_diff-0.2.0}/pyproject.toml +5 -2
  7. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/__init__.py +1 -1
  8. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/cli.py +32 -1
  9. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/render/html.py +60 -9
  10. geojson_diff-0.2.0/src/geojson_diff.egg-info/PKG-INFO +229 -0
  11. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/test_cli_git.py +16 -0
  12. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/test_render.py +46 -1
  13. geojson_diff-0.1.2/PKG-INFO +0 -507
  14. geojson_diff-0.1.2/README.md +0 -464
  15. geojson_diff-0.1.2/src/geojson_diff.egg-info/PKG-INFO +0 -507
  16. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/LICENSE +0 -0
  17. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/examples/github-actions/geojson-diff.yml +0 -0
  18. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/examples/parcels_v1.geojson +0 -0
  19. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/examples/parcels_v2.geojson +0 -0
  20. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/setup.cfg +0 -0
  21. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/__main__.py +0 -0
  22. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/_shapely.py +0 -0
  23. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/core.py +0 -0
  24. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/geometry.py +0 -0
  25. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/git.py +0 -0
  26. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/io.py +0 -0
  27. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/matching.py +0 -0
  28. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/properties.py +0 -0
  29. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/py.typed +0 -0
  30. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/render/__init__.py +0 -0
  31. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/render/layer.py +0 -0
  32. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/render/machine.py +0 -0
  33. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/render/markdown.py +0 -0
  34. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/render/text.py +0 -0
  35. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff/tolerance.py +0 -0
  36. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/SOURCES.txt +0 -0
  37. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/dependency_links.txt +0 -0
  38. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/entry_points.txt +0 -0
  39. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/requires.txt +0 -0
  40. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/src/geojson_diff.egg-info/top_level.txt +0 -0
  41. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/conftest.py +0 -0
  42. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/test_diff.py +0 -0
  43. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/test_geometry_properties.py +0 -0
  44. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/test_shapely_examples.py +0 -0
  45. {geojson_diff-0.1.2 → geojson_diff-0.2.0}/tests/test_tolerance_io.py +0 -0
@@ -6,6 +6,34 @@ project uses [Semantic Versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
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
+
9
37
  ## [0.1.2] - 2026-11-15
10
38
  ### Fixed
11
39
  - `precision` outside 0-15 is rejected (`DiffOptions`, `--precision`): a negative value
@@ -55,5 +83,6 @@ project uses [Semantic Versioning](https://semver.org/).
55
83
  strategy the new file is streamed against an index of the old one.
56
84
  - Optional `shapely` extra for topological equality and symmetric-difference area.
57
85
 
58
- [Unreleased]: https://gitlab.com/geophilo1/geojson_diff_sdk/-/compare/v0.1.0...HEAD
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
59
88
  [0.1.0]: https://gitlab.com/geophilo1/geojson_diff_sdk/-/tags/v0.1.0
@@ -6,8 +6,8 @@ authors:
6
6
  email: "geospacephilo@gmail.com"
7
7
  orcid: "https://orcid.org/0009-0005-6000-2934"
8
8
  title: "geojson-diff"
9
- version: "0.1.2"
10
- date-released: "2026-11-15"
9
+ version: "0.2.0"
10
+ date-released: "2026-12-02"
11
11
  doi: "10.5281/zenodo.24063377"
12
12
  license: "MIT"
13
13
  repository-code: "https://gitlab.com/geophilo1/geojson_diff_sdk"
@@ -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,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "geojson-diff"
7
- version = "0.1.2"
7
+ version = "0.2.0"
8
8
  authors = [
9
9
  { name = "Yusuf Eminoğlu", email = "geospacephilo@gmail.com" }
10
10
  ]
@@ -23,6 +23,8 @@ keywords = [
23
23
  "hausdorff",
24
24
  "geojsonseq",
25
25
  "leaflet",
26
+ "spatial-diff",
27
+ "merge-request",
26
28
  "gis",
27
29
  ]
28
30
  readme = "README.md"
@@ -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",
@@ -68,7 +71,7 @@ git-geojson-diff = "geojson_diff.cli:git_main"
68
71
  [project.urls]
69
72
  Homepage = "https://gitlab.com/geophilo1/geojson_diff_sdk"
70
73
  Repository = "https://gitlab.com/geophilo1/geojson_diff_sdk"
71
- Documentation = "https://gitlab.com/geophilo1/geojson_diff_sdk#readme"
74
+ Documentation = "https://geophilo.com/sdks/geojson-diff/"
72
75
  Issues = "https://gitlab.com/geophilo1/geojson_diff_sdk/-/work_items"
73
76
  Changelog = "https://gitlab.com/geophilo1/geojson_diff_sdk/-/blob/main/CHANGELOG.md"
74
77
  "SDK dashboard" = "https://geophilo.com/sdk-dashboard/"
@@ -8,7 +8,7 @@
8
8
 
9
9
  from __future__ import annotations
10
10
 
11
- __version__ = "0.1.2"
11
+ __version__ = "0.2.0"
12
12
 
13
13
  from .core import (
14
14
  STATUSES,
@@ -47,6 +47,22 @@ def _int_in_range(low: int, high: int | None = None) -> Callable[[str], int]:
47
47
  return convert
48
48
 
49
49
 
50
+ def _tiles(value: str) -> str:
51
+ """argparse type: a basemap name (``esri``, ``osm``) or a tile URL template."""
52
+ from .render.html import BASEMAPS
53
+
54
+ if value.lower() in BASEMAPS:
55
+ return value.lower()
56
+ if value.startswith(("https://", "http://")) and all(
57
+ part in value for part in ("{z}", "{x}", "{y}")
58
+ ):
59
+ return value
60
+ raise argparse.ArgumentTypeError(
61
+ f"use {', '.join(BASEMAPS)} or an http(s) URL template with {{z}}, {{x}} and {{y}}; "
62
+ f"got {value!r}"
63
+ )
64
+
65
+
50
66
  def parse_fail_on(spec: str | None) -> dict[str, int]:
51
67
  """Parse ``removed,modified`` or ``removed:10,moved:0`` into allowed counts.
52
68
 
@@ -180,6 +196,19 @@ def _add_diff_options(parser: argparse.ArgumentParser) -> None:
180
196
  "--max-rows", type=_int_in_range(0), default=100, metavar="N", help="rows in md tables"
181
197
  )
182
198
  o.add_argument("--title", default="", help="title for md/html reports")
199
+ o.add_argument(
200
+ "--tiles",
201
+ type=_tiles,
202
+ default="esri",
203
+ metavar="NAME|URL",
204
+ help="html basemap: esri (default; works for reports opened from disk), osm "
205
+ "(OpenStreetMap; needs a served page) or a tile URL template",
206
+ )
207
+ o.add_argument(
208
+ "--attribution",
209
+ metavar="HTML",
210
+ help="html basemap attribution (default: the named basemap's own)",
211
+ )
183
212
  o.add_argument(
184
213
  "--md-map",
185
214
  action="store_true",
@@ -282,7 +311,9 @@ def _report(result: DiffResult, args: argparse.Namespace, force_text: bool = Fal
282
311
  include_map=args.md_map,
283
312
  )
284
313
  elif fmt == "html":
285
- text = render(result, "html", title=args.title)
314
+ text = render(
315
+ result, "html", title=args.title, tiles=args.tiles, attribution=args.attribution
316
+ )
286
317
  elif fmt == "geojson":
287
318
  text = render(result, "geojson", include_unchanged=args.show_unchanged)
288
319
  else: