pystac-monty 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 (58) hide show
  1. pystac_monty-0.2.0/LICENSE +13 -0
  2. pystac_monty-0.2.0/PKG-INFO +156 -0
  3. pystac_monty-0.2.0/README.md +120 -0
  4. pystac_monty-0.2.0/pyproject.toml +164 -0
  5. pystac_monty-0.2.0/pystac_monty/HazardProfiles.csv +303 -0
  6. pystac_monty-0.2.0/pystac_monty/__init__.py +0 -0
  7. pystac_monty-0.2.0/pystac_monty/cli.py +36 -0
  8. pystac_monty-0.2.0/pystac_monty/exporter.py +386 -0
  9. pystac_monty-0.2.0/pystac_monty/extension.py +916 -0
  10. pystac_monty-0.2.0/pystac_monty/geo_blocks.py +22 -0
  11. pystac_monty-0.2.0/pystac_monty/geocoding.py +821 -0
  12. pystac_monty-0.2.0/pystac_monty/hazard_profiles.py +371 -0
  13. pystac_monty-0.2.0/pystac_monty/impact.py +142 -0
  14. pystac_monty-0.2.0/pystac_monty/paring.py +65 -0
  15. pystac_monty-0.2.0/pystac_monty/response.py +148 -0
  16. pystac_monty-0.2.0/pystac_monty/sources/batch_export.py +206 -0
  17. pystac_monty-0.2.0/pystac_monty/sources/cems.py +1587 -0
  18. pystac_monty-0.2.0/pystac_monty/sources/charter.py +1218 -0
  19. pystac_monty-0.2.0/pystac_monty/sources/common.py +373 -0
  20. pystac_monty-0.2.0/pystac_monty/sources/desinventar.py +1175 -0
  21. pystac_monty-0.2.0/pystac_monty/sources/emdat.py +588 -0
  22. pystac_monty-0.2.0/pystac_monty/sources/gdacs.py +773 -0
  23. pystac_monty-0.2.0/pystac_monty/sources/gfd.py +220 -0
  24. pystac_monty-0.2.0/pystac_monty/sources/gidd.py +329 -0
  25. pystac_monty-0.2.0/pystac_monty/sources/glide.py +433 -0
  26. pystac_monty-0.2.0/pystac_monty/sources/ibtracs.py +623 -0
  27. pystac_monty-0.2.0/pystac_monty/sources/idu.py +285 -0
  28. pystac_monty-0.2.0/pystac_monty/sources/ifrc_events.py +424 -0
  29. pystac_monty-0.2.0/pystac_monty/sources/pdc.py +391 -0
  30. pystac_monty-0.2.0/pystac_monty/sources/usgs.py +797 -0
  31. pystac_monty-0.2.0/pystac_monty/sources/utils.py +110 -0
  32. pystac_monty-0.2.0/pystac_monty/validators/base.py +7 -0
  33. pystac_monty-0.2.0/pystac_monty/validators/cems.py +107 -0
  34. pystac_monty-0.2.0/pystac_monty/validators/charter.py +64 -0
  35. pystac_monty-0.2.0/pystac_monty/validators/desinventar.py +101 -0
  36. pystac_monty-0.2.0/pystac_monty/validators/em_dat.py +103 -0
  37. pystac_monty-0.2.0/pystac_monty/validators/gdacs_events.py +87 -0
  38. pystac_monty-0.2.0/pystac_monty/validators/gdacs_geometry.py +85 -0
  39. pystac_monty-0.2.0/pystac_monty/validators/gdacs_impacts.py +86 -0
  40. pystac_monty-0.2.0/pystac_monty/validators/gfd.py +75 -0
  41. pystac_monty-0.2.0/pystac_monty/validators/gidd.py +72 -0
  42. pystac_monty-0.2.0/pystac_monty/validators/glide.py +69 -0
  43. pystac_monty-0.2.0/pystac_monty/validators/ibtracs.py +48 -0
  44. pystac_monty-0.2.0/pystac_monty/validators/idu.py +101 -0
  45. pystac_monty-0.2.0/pystac_monty/validators/ifrc.py +121 -0
  46. pystac_monty-0.2.0/pystac_monty/validators/pdc.py +91 -0
  47. pystac_monty-0.2.0/pystac_monty/validators/response.py +48 -0
  48. pystac_monty-0.2.0/pystac_monty/validators/usgs.py +113 -0
  49. pystac_monty-0.2.0/pystac_monty.egg-info/PKG-INFO +156 -0
  50. pystac_monty-0.2.0/pystac_monty.egg-info/SOURCES.txt +56 -0
  51. pystac_monty-0.2.0/pystac_monty.egg-info/dependency_links.txt +1 -0
  52. pystac_monty-0.2.0/pystac_monty.egg-info/entry_points.txt +2 -0
  53. pystac_monty-0.2.0/pystac_monty.egg-info/requires.txt +11 -0
  54. pystac_monty-0.2.0/pystac_monty.egg-info/top_level.txt +1 -0
  55. pystac_monty-0.2.0/setup.cfg +4 -0
  56. pystac_monty-0.2.0/tests/test_batch_export.py +42 -0
  57. pystac_monty-0.2.0/tests/test_exporter.py +303 -0
  58. pystac_monty-0.2.0/tests/test_geocoding_performance.py +133 -0
@@ -0,0 +1,13 @@
1
+ Copyright 2019-2024 the authors
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: pystac_monty
3
+ Version: 0.2.0
4
+ Summary: Python library for working with the SpatioTemporal Asset Catalog (STAC) extension for Montandon
5
+ Author-email: Emmanuel Mathot <emmanuel.mathot@gmail.com>
6
+ License: Apache-2.0
7
+ Project-URL: Documentation, https://ifrcgo.org/monty-stac-extension/
8
+ Project-URL: Repository, https://github.com/IFRCGo/pystac-monty
9
+ Project-URL: Issues, https://github.com/IFRCGo/pystac-monty/issues
10
+ Project-URL: Changelog, https://github.com/IFRCGo/pystac-monty/blob/main/CHANGELOG.md
11
+ Project-URL: Discussions, https://github.com/radiantearth/stac-spec/discussions/categories/stac-software
12
+ Keywords: pystac,disaster,hazard,catalog,STAC,Montandon,Monty
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Natural Language :: English
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: python-dateutil>=2.7.0
25
+ Requires-Dist: pystac>=1.11.0
26
+ Requires-Dist: geojson>=2.5.0
27
+ Requires-Dist: markdownify>=0.14.1
28
+ Requires-Dist: pytz>=2021.1
29
+ Requires-Dist: pandas>=2.2.0
30
+ Requires-Dist: lxml>=5.3.0
31
+ Requires-Dist: pydantic>=2.10.6
32
+ Requires-Dist: ijson>=3.4.0
33
+ Requires-Dist: pyarrow>=22.0.0
34
+ Requires-Dist: shapely>=2.0.0
35
+ Dynamic: license-file
36
+
37
+ # Montandon Extension for PySTAC
38
+
39
+ This project provides a Python library for working with the SpatioTemporal Asset Catalog (STAC) extension for Montandon. It extends the capabilities of PySTAC to handle disaster and hazard-related data using the Montandon schema.
40
+
41
+ ## Features
42
+
43
+ - Extend STAC Collections and Items with Montandon-specific properties.
44
+ - Support for hazard detail objects.
45
+ - Integration with GDACS data sources.
46
+ - Utilities for pairing and correlation ID generation.
47
+
48
+ ## Installation
49
+
50
+ To install the library, use pip:
51
+
52
+ ```sh
53
+ pip install pystac_monty
54
+ ```
55
+
56
+ To install the tool `jq`, use the following:
57
+
58
+ Debian/Ubuntu/Mint environment
59
+ ```sh
60
+ sudo apt-get update
61
+ sudo apt-get install jq
62
+ ```
63
+
64
+ MacOS environment
65
+ ```sh
66
+ brew install jq
67
+ ```
68
+
69
+ To check if it is install correctly
70
+
71
+ ```sh
72
+ jq --version
73
+ ```
74
+
75
+ ## Usage
76
+
77
+ ### Batch export (CLI)
78
+
79
+ To export upstream source files to on-disk Monty STAC, first initialise the submodule:
80
+
81
+ ```sh
82
+ git submodule update --init --recursive
83
+ ```
84
+
85
+ Then run the CLI. `SOURCE` is one of `glide`, `gfd`, `gdacs`; `--input` accepts a source-specific file (see the `convert_*` docstrings in `pystac_monty/sources/batch_export.py`):
86
+
87
+ ```sh
88
+ pystac-monty SOURCE --input path/to/input --output path/to/output/
89
+ ```
90
+
91
+ The output directory will contain role collections (`{slug}-events/`, `{slug}-hazards/`, etc.), each with a collection JSON and flat item files. Raw source payloads live in `monty-stac-extension/docs/model/sources/` — the `examples/` folders are published STAC output, not inputs.
92
+
93
+ To add more sources or use the exporter programmatically, see `pystac_monty/exporter.py`.
94
+
95
+ ### Extending a STAC Item
96
+
97
+ The library provides classes and functions to work with Montandon STAC objects. Here is an example of how to create a Montandon Item:
98
+
99
+ ```python
100
+ import pystac
101
+ from pystac_monty.extension import MontyExtension
102
+
103
+ item = pystac.Item(...) # Create or load a STAC Item
104
+ monty_ext = MontyExtension.ext(item)
105
+ monty_ext.episode_number = 1
106
+ print(monty_ext.episode_number)
107
+ ```
108
+
109
+ ### Working with GDACS data
110
+
111
+ To transform GDACS event data into STAC Items:
112
+
113
+ ```python
114
+ from pystac_monty.sources.gdacs import GDACSTransformer, GDACSDataSource
115
+
116
+ data_source = GDACSDataSource(source_url="...", data="...", type=GDACSDataSourceType.EVENT)
117
+ transformer = GDACSTransformer(data=[data_source])
118
+ items = transformer.make_items()
119
+ ```
120
+
121
+ ## Development
122
+
123
+ To set up the development environment:
124
+
125
+ ```sh
126
+ pip install uv
127
+ uv sync
128
+ ```
129
+
130
+ To run the tests:
131
+
132
+ 1. Make the test with actual calls to http and write them in the cassette files:
133
+
134
+ ```sh
135
+ uv run pytest -v -s --record-mode rewrite
136
+ ```
137
+
138
+ 2. Run the tests with the recorded calls:
139
+
140
+ ```sh
141
+ uv run pytest -v -s
142
+ ```
143
+
144
+ ## Contributing
145
+
146
+ Contributions are welcome! Please open an issue or submit a pull request.
147
+
148
+ ## License
149
+
150
+ This project is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.
151
+
152
+ ### Links
153
+
154
+ - [Documentation](https://pystac.readthedocs.io)
155
+ - [Repository](https://github.com/IFRCGo/monty-stac-extension)
156
+ - [Issues](https://github.com/IFRCGo/monty-stac-extension/issues)
@@ -0,0 +1,120 @@
1
+ # Montandon Extension for PySTAC
2
+
3
+ This project provides a Python library for working with the SpatioTemporal Asset Catalog (STAC) extension for Montandon. It extends the capabilities of PySTAC to handle disaster and hazard-related data using the Montandon schema.
4
+
5
+ ## Features
6
+
7
+ - Extend STAC Collections and Items with Montandon-specific properties.
8
+ - Support for hazard detail objects.
9
+ - Integration with GDACS data sources.
10
+ - Utilities for pairing and correlation ID generation.
11
+
12
+ ## Installation
13
+
14
+ To install the library, use pip:
15
+
16
+ ```sh
17
+ pip install pystac_monty
18
+ ```
19
+
20
+ To install the tool `jq`, use the following:
21
+
22
+ Debian/Ubuntu/Mint environment
23
+ ```sh
24
+ sudo apt-get update
25
+ sudo apt-get install jq
26
+ ```
27
+
28
+ MacOS environment
29
+ ```sh
30
+ brew install jq
31
+ ```
32
+
33
+ To check if it is install correctly
34
+
35
+ ```sh
36
+ jq --version
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### Batch export (CLI)
42
+
43
+ To export upstream source files to on-disk Monty STAC, first initialise the submodule:
44
+
45
+ ```sh
46
+ git submodule update --init --recursive
47
+ ```
48
+
49
+ Then run the CLI. `SOURCE` is one of `glide`, `gfd`, `gdacs`; `--input` accepts a source-specific file (see the `convert_*` docstrings in `pystac_monty/sources/batch_export.py`):
50
+
51
+ ```sh
52
+ pystac-monty SOURCE --input path/to/input --output path/to/output/
53
+ ```
54
+
55
+ The output directory will contain role collections (`{slug}-events/`, `{slug}-hazards/`, etc.), each with a collection JSON and flat item files. Raw source payloads live in `monty-stac-extension/docs/model/sources/` — the `examples/` folders are published STAC output, not inputs.
56
+
57
+ To add more sources or use the exporter programmatically, see `pystac_monty/exporter.py`.
58
+
59
+ ### Extending a STAC Item
60
+
61
+ The library provides classes and functions to work with Montandon STAC objects. Here is an example of how to create a Montandon Item:
62
+
63
+ ```python
64
+ import pystac
65
+ from pystac_monty.extension import MontyExtension
66
+
67
+ item = pystac.Item(...) # Create or load a STAC Item
68
+ monty_ext = MontyExtension.ext(item)
69
+ monty_ext.episode_number = 1
70
+ print(monty_ext.episode_number)
71
+ ```
72
+
73
+ ### Working with GDACS data
74
+
75
+ To transform GDACS event data into STAC Items:
76
+
77
+ ```python
78
+ from pystac_monty.sources.gdacs import GDACSTransformer, GDACSDataSource
79
+
80
+ data_source = GDACSDataSource(source_url="...", data="...", type=GDACSDataSourceType.EVENT)
81
+ transformer = GDACSTransformer(data=[data_source])
82
+ items = transformer.make_items()
83
+ ```
84
+
85
+ ## Development
86
+
87
+ To set up the development environment:
88
+
89
+ ```sh
90
+ pip install uv
91
+ uv sync
92
+ ```
93
+
94
+ To run the tests:
95
+
96
+ 1. Make the test with actual calls to http and write them in the cassette files:
97
+
98
+ ```sh
99
+ uv run pytest -v -s --record-mode rewrite
100
+ ```
101
+
102
+ 2. Run the tests with the recorded calls:
103
+
104
+ ```sh
105
+ uv run pytest -v -s
106
+ ```
107
+
108
+ ## Contributing
109
+
110
+ Contributions are welcome! Please open an issue or submit a pull request.
111
+
112
+ ## License
113
+
114
+ This project is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.
115
+
116
+ ### Links
117
+
118
+ - [Documentation](https://pystac.readthedocs.io)
119
+ - [Repository](https://github.com/IFRCGo/monty-stac-extension)
120
+ - [Issues](https://github.com/IFRCGo/monty-stac-extension/issues)
@@ -0,0 +1,164 @@
1
+ [project]
2
+ name = "pystac_monty"
3
+ description = "Python library for working with the SpatioTemporal Asset Catalog (STAC) extension for Montandon"
4
+ readme = "README.md"
5
+ authors = [{ name = "Emmanuel Mathot", email = "emmanuel.mathot@gmail.com" }]
6
+ keywords = [
7
+ "pystac",
8
+ "disaster",
9
+ "hazard",
10
+ "catalog",
11
+ "STAC",
12
+ "Montandon",
13
+ "Monty",
14
+ ]
15
+ license = { text = "Apache-2.0" }
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: Apache Software License",
20
+ "Natural Language :: English",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ ]
26
+ requires-python = ">=3.11"
27
+ dependencies = [
28
+ "python-dateutil>=2.7.0",
29
+ "pystac>=1.11.0",
30
+ "geojson>=2.5.0",
31
+ "markdownify>=0.14.1",
32
+ "pytz>=2021.1",
33
+ "pandas>=2.2.0",
34
+ "lxml>=5.3.0",
35
+ "pydantic>=2.10.6",
36
+ "ijson>=3.4.0",
37
+ "pyarrow>=22.0.0",
38
+ "shapely>=2.0.0",
39
+ ]
40
+ dynamic = ["version"]
41
+
42
+ [project.urls]
43
+ Documentation = "https://ifrcgo.org/monty-stac-extension/"
44
+ Repository = "https://github.com/IFRCGo/pystac-monty"
45
+ Issues = "https://github.com/IFRCGo/pystac-monty/issues"
46
+ Changelog = "https://github.com/IFRCGo/pystac-monty/blob/main/CHANGELOG.md"
47
+ Discussions = "https://github.com/radiantearth/stac-spec/discussions/categories/stac-software"
48
+
49
+ [project.scripts]
50
+ pystac-monty = "pystac_monty.cli:main"
51
+
52
+ [tool.coverage.run]
53
+ branch = true
54
+ source = ["pystac_monty"]
55
+ # omit = ["pystac/extensions/label.py"]
56
+
57
+ [tool.coverage.report]
58
+ fail_under = 90
59
+ exclude_lines = ["if TYPE_CHECKING:"]
60
+
61
+ [tool.doc8]
62
+ ignore-path = ["docs/_build", "docs/tutorials"]
63
+ max-line-length = 88
64
+
65
+ [tool.mypy]
66
+ show_error_codes = true
67
+ strict = true
68
+
69
+ [[tool.mypy.overrides]]
70
+ module = ["jinja2"]
71
+ ignore_missing_imports = true
72
+
73
+ [tool.pyright]
74
+ exclude = [
75
+ "**/__pycache__",
76
+ "**/snap_test_*.py",
77
+ ".venv/",
78
+ "**/migrations/*.py",
79
+ "tests/**",
80
+ "notebooks/**",
81
+ ]
82
+ reportMissingImports = true
83
+ reportMissingTypeStubs = false
84
+ typeCheckingMode = "basic"
85
+ reportAttributeAccessIssue = "warning"
86
+ reportArgumentType = "warning"
87
+ reportCallIssue = "warning"
88
+ reportReturnType = "warning"
89
+ reportAssignmentType = "warning"
90
+ reportGeneralTypeIssues = "warning"
91
+ reportOptionalMemberAccess = "warning"
92
+ reportOptionalSubscript = "warning"
93
+ reportInvalidTypeForm = "warning"
94
+ venvPath = "."
95
+ venv = ".venv"
96
+
97
+ [tool.ruff]
98
+ line-length = 130
99
+ extend-exclude = [
100
+ ".git",
101
+ ".pytest_cache",
102
+ ".venv",
103
+ "venv",
104
+ "**/migrations/*",
105
+ "__pycache__",
106
+ ]
107
+ lint.extend-select = ["I", "E", "F", "W"]
108
+ lint.ignore = ["C901", "E701", "E203"]
109
+
110
+ [tool.ruff.lint.per-file-ignores]
111
+ "__init__.py" = ["E402"]
112
+
113
+ [tool.pytest.ini_options]
114
+ filterwarnings = ["error"]
115
+
116
+ [tool.setuptools.packages.find]
117
+ include = ["pystac_monty*"]
118
+ exclude = ["tests*"]
119
+
120
+ [tool.setuptools.package-data]
121
+ pystac_monty = ["HazardProfiles.csv"]
122
+
123
+ [tool.setuptools.dynamic]
124
+ version = { attr = "pystac_monty.extension.__version__" }
125
+
126
+ [dependency-groups]
127
+ dev = [
128
+ "codespell<2.3",
129
+ "coverage>=7.6.2",
130
+ "doc8>=1.1.2",
131
+ "fiona>=1.10.0",
132
+ "geopandas>=1.0.1",
133
+ "geopy>=2.4.0",
134
+ "html5lib>=1.1",
135
+ "jinja2>=3.1.4",
136
+ "jsonschema>=4.23.0",
137
+ "mypy>=1.11.2",
138
+ "openpyxl>=3.1.0",
139
+ "orjson>=3.10.7",
140
+ "packaging>=24.1",
141
+ "parameterized",
142
+ "pre-commit>=4.0.1",
143
+ "pytest>=8.3.3",
144
+ "pytest-cov>=5.0.0",
145
+ "pytest-mock>=3.14.0",
146
+ "pytest-recording>=0.13.2",
147
+ "requests>=2.32.3",
148
+ "ruff>=0.6.9",
149
+ "shapely>=2.0.0",
150
+ "types-html5lib>=1.1.11.20240806",
151
+ "types-jsonschema>=4.23.0.20240813",
152
+ "types-lxml>=2024.12.13",
153
+ "types-orjson>=3.6.2",
154
+ "types-python-dateutil>=2.9.0.20241003",
155
+ "types-urllib3>=1.26.25.14",
156
+ "virtualenv>=20.26.6",
157
+ ]
158
+
159
+ [tool.uv.workspace]
160
+ members = ["docs"]
161
+
162
+ [build-system]
163
+ requires = ["setuptools>=61.0"]
164
+ build-backend = "setuptools.build_meta"