Name | geojson-validator JSON |
Version |
0.6.0
JSON |
| download |
home_page | None |
Summary | Validates and fixes GeoJSON |
upload_time | 2024-11-30 00:06:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT |
keywords |
geojson
validation
gis
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# GeoJSON Validator
<img src="./repo-images/header_img.jpeg">
**Validate GeoJSON and automatically fix invalid geometries**. Like *geojsonhint*, but with geometry checks & fixes!
- 🔴 **Detects invalid geometries** & 🟢 **fixes them** : *Unclosed, wrong winding order etc.*
- 🟨 **Problematic** geometries (for many tools & APIs): *Self-intersection, crossing anti-meridian etc.*
- Checks 🧬 **structure** according to GeoJSON specification
- Use **Website** or **Python package**
<br>
<h3 align="center">
🎈 <a href="https://geojson-validator.streamlit.app/">geojson-validator.streamlit.app in the Browser 🎈 </a>
</h3>
<img src="./repo-images/gif.gif">
<br>
### Quickstart Python
```bash
# Installation
pip install geojson-validator
```
Data input can be any type of GeoJSON object, a filepath/url, and anything with a `__geo_interface__` (shapely, geopandas etc.).
```python
import geojson_validator
geojson_input = {'type': 'FeatureCollection',
'features': [{'type': 'Feature', 'geometry':
{'type': 'Point', 'coordinates': [-59.758285, 8.367035]}}]}
geojson_validator.validate_structure(geojson_input)
geojson_validator.validate_geometries(geojson_input)
geojson_validator.fix_geometries(geojson_input)
```
<br>
### 1. Validate GeoJSON structure 🧬
Checks the structure & formatting of the GeoJSON, e.g. required elements, data & geometry types, coordinate array depth etc.
```python
geojson_validator.validate_structure(geojson_input, check_crs=False)
```
Returns the reasons why the input does not conform to the GeoJSON specification.
Also gives the line location and feature index to more quickly localize the issues.
Example: `{"Missing 'type' member": {"line": [4], "feature": [0]}`.
### 2. Validate geometries 🟥
Checks the GeoJSON geometry objects for inconsistencies and geometric issues. See
[geojson-invalid-geometry](https://github.com/chrieke/geojson-invalid-geometry) for a detailed description of all
invalid and problematic criteria. You can choose to validate only specific criteria, by default all are selected.
```python
# Invalid according to the GeoJSON specification
criteria_invalid = ["unclosed", "less_three_unique_nodes", "exterior_not_ccw",
"interior_not_cw", "inner_and_exterior_ring_intersect"]
# Problematic with some tools & APIs
criteria_problematic = ["holes", "self_intersection", "duplicate_nodes",
"excessive_coordinate_precision", "excessive_vertices",
"3d_coordinates", "outside_lat_lon_boundaries", "crosses_antimeridian"]
geojson_validator.validate_geometries(geojson, criteria_invalid, criteria_problematic)
```
Returns the reasons (example below) and positional indices of the invalid geometries, e.g. features `[0, 3]`. Also indicates if a
sub-geometry of a MultiType geometry make it invalid e.g. `{2:[0, 5]}`.
```
{"invalid":
{"unclosed": [0, 3],
"exterior_not_ccw": [{2:[0, 5]}],
"problematic":
{"crosses_antimeridian": [1]},
"count_geometry_types":
{"Polygon": 3,
"MultiPolygon": 1}}
```
### 3. Fix GeoJSON geometries 🟩
Automatically repairs some of the most common categories of invalid geometries.
Always fixes *["unclosed", "exterior_not_ccw", "interior_not_cw"]*.
Select additional, non-essential fixes with the parameter `optional`.
More fixes and helper-functions (for issues that require user descisions) **coming soon**!
```python
geojson_validator.fix_geometries(geojson_input, optional=["duplicate_nodes"])
```
The result is a GeoJSON FeatureCollection with the fixed geometries.
### FAQ:
- Why not use geojson-pydantic for the schema validation?
pydantic error messages a bit convulted (if one coordinate is missing error 4 times), very schema like, not custom, not easy to understand for no nprogrammers.
often would need to be translated.
- Too many logging messages, can I disable them? You can disable or configure the logging behavior via `geojson_validator.configure_logger(enabled=True, level="DEBUG")` which also returns the logger instance.
Raw data
{
"_id": null,
"home_page": null,
"name": "geojson-validator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "geojson, validation, GIS",
"author": null,
"author_email": "Christoph Rieke <christoph.k.rieke@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b9/08/7439f2d6c4bbd5a5576fb1322bcd9e3beb5b75eb41961f9a489c19f95307/geojson_validator-0.6.0.tar.gz",
"platform": null,
"description": "# GeoJSON Validator\n\n<img src=\"./repo-images/header_img.jpeg\">\n\n**Validate GeoJSON and automatically fix invalid geometries**. Like *geojsonhint*, but with geometry checks & fixes!\n\n- \ud83d\udd34 **Detects invalid geometries** & \ud83d\udfe2 **fixes them** : *Unclosed, wrong winding order etc.* \n- \ud83d\udfe8 **Problematic** geometries (for many tools & APIs): *Self-intersection, crossing anti-meridian etc.*\n- Checks \ud83e\uddec **structure** according to GeoJSON specification\n- Use **Website** or **Python package**\n\n<br>\n\n<h3 align=\"center\">\n \ud83c\udf88 <a href=\"https://geojson-validator.streamlit.app/\">geojson-validator.streamlit.app in the Browser \ud83c\udf88 </a>\n</h3>\n\n<img src=\"./repo-images/gif.gif\">\n\n<br>\n\n### Quickstart Python\n\n```bash\n# Installation\npip install geojson-validator\n```\n\nData input can be any type of GeoJSON object, a filepath/url, and anything with a `__geo_interface__` (shapely, geopandas etc.).\n\n```python\nimport geojson_validator\n\ngeojson_input = {'type': 'FeatureCollection',\n 'features': [{'type': 'Feature', 'geometry':\n {'type': 'Point', 'coordinates': [-59.758285, 8.367035]}}]}\n\ngeojson_validator.validate_structure(geojson_input)\ngeojson_validator.validate_geometries(geojson_input)\ngeojson_validator.fix_geometries(geojson_input)\n```\n<br>\n\n### 1. Validate GeoJSON structure \ud83e\uddec\n\nChecks the structure & formatting of the GeoJSON, e.g. required elements, data & geometry types, coordinate array depth etc.\n\n```python\ngeojson_validator.validate_structure(geojson_input, check_crs=False)\n```\n\nReturns the reasons why the input does not conform to the GeoJSON specification.\nAlso gives the line location and feature index to more quickly localize the issues. \nExample: `{\"Missing 'type' member\": {\"line\": [4], \"feature\": [0]}`.\n\n\n### 2. Validate geometries \ud83d\udfe5\n\nChecks the GeoJSON geometry objects for inconsistencies and geometric issues. See \n[geojson-invalid-geometry](https://github.com/chrieke/geojson-invalid-geometry) for a detailed description of all \ninvalid and problematic criteria. You can choose to validate only specific criteria, by default all are selected.\n\n```python\n# Invalid according to the GeoJSON specification\ncriteria_invalid = [\"unclosed\", \"less_three_unique_nodes\", \"exterior_not_ccw\",\n \"interior_not_cw\", \"inner_and_exterior_ring_intersect\"]\n\n# Problematic with some tools & APIs\ncriteria_problematic = [\"holes\", \"self_intersection\", \"duplicate_nodes\", \n \"excessive_coordinate_precision\", \"excessive_vertices\", \n \"3d_coordinates\", \"outside_lat_lon_boundaries\", \"crosses_antimeridian\"]\n\ngeojson_validator.validate_geometries(geojson, criteria_invalid, criteria_problematic)\n```\nReturns the reasons (example below) and positional indices of the invalid geometries, e.g. features `[0, 3]`. Also indicates if a \nsub-geometry of a MultiType geometry make it invalid e.g. `{2:[0, 5]}`.\n\n```\n{\"invalid\": \n {\"unclosed\": [0, 3],\n \"exterior_not_ccw\": [{2:[0, 5]}], \n \"problematic\":\n {\"crosses_antimeridian\": [1]},\n \"count_geometry_types\": \n {\"Polygon\": 3,\n \"MultiPolygon\": 1}}\n```\n\n\n\n### 3. Fix GeoJSON geometries \ud83d\udfe9\n\nAutomatically repairs some of the most common categories of invalid geometries. \nAlways fixes *[\"unclosed\", \"exterior_not_ccw\", \"interior_not_cw\"]*.\nSelect additional, non-essential fixes with the parameter `optional`.\nMore fixes and helper-functions (for issues that require user descisions) **coming soon**!\n\n\n\n```python\ngeojson_validator.fix_geometries(geojson_input, optional=[\"duplicate_nodes\"])\n```\n\nThe result is a GeoJSON FeatureCollection with the fixed geometries.\n\n\n\n### FAQ:\n- Why not use geojson-pydantic for the schema validation?\npydantic error messages a bit convulted (if one coordinate is missing error 4 times), very schema like, not custom, not easy to understand for no nprogrammers.\noften would need to be translated.\n- Too many logging messages, can I disable them? You can disable or configure the logging behavior via `geojson_validator.configure_logger(enabled=True, level=\"DEBUG\")` which also returns the logger instance.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Validates and fixes GeoJSON",
"version": "0.6.0",
"project_urls": {
"Changelog": "https://github.com/chrieke/geojson-validator/changelog",
"Homepage": "https://github.com/chrieke/geojson-validator"
},
"split_keywords": [
"geojson",
" validation",
" gis"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cfc67151fabbbe7939300808e8d2360fd92f3472c2f00a88b1516da86dd56a70",
"md5": "7691698d9a4faef3b019c11c4d9e3248",
"sha256": "c6590ba006034c3f907a896381c3ec3dd7929cc31a5385b5c2d7c175b83a4e9f"
},
"downloads": -1,
"filename": "geojson_validator-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7691698d9a4faef3b019c11c4d9e3248",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 14883,
"upload_time": "2024-11-30T00:05:59",
"upload_time_iso_8601": "2024-11-30T00:05:59.104678Z",
"url": "https://files.pythonhosted.org/packages/cf/c6/7151fabbbe7939300808e8d2360fd92f3472c2f00a88b1516da86dd56a70/geojson_validator-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "b9087439f2d6c4bbd5a5576fb1322bcd9e3beb5b75eb41961f9a489c19f95307",
"md5": "c2ef716093bd32da33db2462f80b6a2b",
"sha256": "3b7ecc696db2c0b74d7b1dcc9af2d98ea1f1900985e7eff1ea143bc0f9d9c382"
},
"downloads": -1,
"filename": "geojson_validator-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "c2ef716093bd32da33db2462f80b6a2b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 19304,
"upload_time": "2024-11-30T00:06:08",
"upload_time_iso_8601": "2024-11-30T00:06:08.092058Z",
"url": "https://files.pythonhosted.org/packages/b9/08/7439f2d6c4bbd5a5576fb1322bcd9e3beb5b75eb41961f9a489c19f95307/geojson_validator-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-30 00:06:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "chrieke",
"github_project": "geojson-validator",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "geojson-validator"
}