rsgispy 0.0.1__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.
- rsgispy-0.0.1/LICENSE +201 -0
- rsgispy-0.0.1/PKG-INFO +54 -0
- rsgispy-0.0.1/README.md +2 -0
- rsgispy-0.0.1/pyproject.toml +85 -0
- rsgispy-0.0.1/rsgispy/__init__.py +254 -0
- rsgispy-0.0.1/rsgispy/elevation/__init__.py +1339 -0
- rsgispy-0.0.1/rsgispy/elevation/roughness.py +854 -0
- rsgispy-0.0.1/rsgispy/imagecalc/__init__.py +856 -0
- rsgispy-0.0.1/rsgispy/imagecalc/calc_pt_win_smpls.py +335 -0
- rsgispy-0.0.1/rsgispy/imagemorphology/__init__.py +946 -0
- rsgispy-0.0.1/rsgispy/imageprocess/__init__.py +650 -0
- rsgispy-0.0.1/rsgispy/imageutils/__init__.py +1918 -0
- rsgispy-0.0.1/rsgispy/imageutils/imagelut.py +326 -0
- rsgispy-0.0.1/rsgispy/tools/__init__.py +3 -0
- rsgispy-0.0.1/rsgispy/tools/filetools.py +1106 -0
- rsgispy-0.0.1/rsgispy/tools/geometrytools.py +588 -0
- rsgispy-0.0.1/rsgispy/tools/mapping.py +1209 -0
- rsgispy-0.0.1/rsgispy/tools/plotting.py +586 -0
- rsgispy-0.0.1/rsgispy/tools/stats.py +1087 -0
- rsgispy-0.0.1/rsgispy/tools/utils.py +1117 -0
- rsgispy-0.0.1/rsgispy/zonalstats/__init__.py +966 -0
- rsgispy-0.0.1/rsgispy.egg-info/PKG-INFO +54 -0
- rsgispy-0.0.1/rsgispy.egg-info/SOURCES.txt +38 -0
- rsgispy-0.0.1/rsgispy.egg-info/dependency_links.txt +1 -0
- rsgispy-0.0.1/rsgispy.egg-info/requires.txt +26 -0
- rsgispy-0.0.1/rsgispy.egg-info/top_level.txt +1 -0
- rsgispy-0.0.1/setup.cfg +4 -0
- rsgispy-0.0.1/tests/test_elevation.py +251 -0
- rsgispy-0.0.1/tests/test_elevation_roughness.py +291 -0
- rsgispy-0.0.1/tests/test_filetools.py +303 -0
- rsgispy-0.0.1/tests/test_geometrytools.py +122 -0
- rsgispy-0.0.1/tests/test_imagecalc.py +565 -0
- rsgispy-0.0.1/tests/test_imagelut.py +263 -0
- rsgispy-0.0.1/tests/test_imagemorphology.py +307 -0
- rsgispy-0.0.1/tests/test_imageprocess.py +341 -0
- rsgispy-0.0.1/tests/test_imageutils.py +633 -0
- rsgispy-0.0.1/tests/test_mapping.py +435 -0
- rsgispy-0.0.1/tests/test_stats.py +297 -0
- rsgispy-0.0.1/tests/test_utils.py +210 -0
- rsgispy-0.0.1/tests/test_zonalstats.py +291 -0
rsgispy-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
rsgispy-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rsgispy
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A pure Python replacement for RSGISLib which is easier to install and maintain
|
|
5
|
+
Author-email: Pete Bunting <petebunting@mac.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/remotesensinginfo/rsgispy
|
|
8
|
+
Project-URL: Repository, https://github.com/remotesensinginfo/rsgispy
|
|
9
|
+
Project-URL: Issues, https://github.com/remotesensinginfo/rsgispy/issues
|
|
10
|
+
Keywords: remote sensing,GIS,raster,geospatial,earth observation,rsgislib
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: geopandas>=1.0
|
|
30
|
+
Requires-Dist: matplotlib>=3.5
|
|
31
|
+
Requires-Dist: matplotlib-scalebar>=0.8
|
|
32
|
+
Requires-Dist: numpy>=1.20
|
|
33
|
+
Requires-Dist: pymu-eval>=0.0.1
|
|
34
|
+
Requires-Dist: pyproj>=3.4
|
|
35
|
+
Requires-Dist: rasterio>=1.3
|
|
36
|
+
Requires-Dist: shapely>=2.0
|
|
37
|
+
Requires-Dist: tqdm>=4.60
|
|
38
|
+
Provides-Extra: stats
|
|
39
|
+
Requires-Dist: scikit-learn>=1.2; extra == "stats"
|
|
40
|
+
Requires-Dist: scipy>=1.7; extra == "stats"
|
|
41
|
+
Provides-Extra: test
|
|
42
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
43
|
+
Requires-Dist: pytest-cov>=4.0; extra == "test"
|
|
44
|
+
Requires-Dist: pylint>=3.0; extra == "test"
|
|
45
|
+
Requires-Dist: rsgispy[stats]; extra == "test"
|
|
46
|
+
Provides-Extra: docs
|
|
47
|
+
Requires-Dist: sphinx>=7.0; extra == "docs"
|
|
48
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == "docs"
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: rsgispy[docs,stats,test]; extra == "dev"
|
|
51
|
+
Dynamic: license-file
|
|
52
|
+
|
|
53
|
+
# rsgispy
|
|
54
|
+
A pure python replacement for RSGISLib which is easier to install and maintain
|
rsgispy-0.0.1/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "rsgispy"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "A pure Python replacement for RSGISLib which is easier to install and maintain"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "Apache-2.0"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Pete Bunting", email = "petebunting@mac.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"remote sensing",
|
|
17
|
+
"GIS",
|
|
18
|
+
"raster",
|
|
19
|
+
"geospatial",
|
|
20
|
+
"earth observation",
|
|
21
|
+
"rsgislib",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"Intended Audience :: Science/Research",
|
|
27
|
+
"License :: OSI Approved :: Apache Software License",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
"Programming Language :: Python :: 3",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.9",
|
|
32
|
+
"Programming Language :: Python :: 3.10",
|
|
33
|
+
"Programming Language :: Python :: 3.11",
|
|
34
|
+
"Programming Language :: Python :: 3.12",
|
|
35
|
+
"Programming Language :: Python :: 3.13",
|
|
36
|
+
"Programming Language :: Python :: 3.14",
|
|
37
|
+
"Topic :: Scientific/Engineering :: GIS",
|
|
38
|
+
"Topic :: Scientific/Engineering :: Image Processing",
|
|
39
|
+
]
|
|
40
|
+
dependencies = [
|
|
41
|
+
"geopandas>=1.0",
|
|
42
|
+
"matplotlib>=3.5",
|
|
43
|
+
"matplotlib-scalebar>=0.8",
|
|
44
|
+
"numpy>=1.20",
|
|
45
|
+
"pymu-eval>=0.0.1",
|
|
46
|
+
"pyproj>=3.4",
|
|
47
|
+
"rasterio>=1.3",
|
|
48
|
+
"shapely>=2.0",
|
|
49
|
+
"tqdm>=4.60",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.optional-dependencies]
|
|
53
|
+
stats = [
|
|
54
|
+
"scikit-learn>=1.2",
|
|
55
|
+
"scipy>=1.7",
|
|
56
|
+
]
|
|
57
|
+
test = [
|
|
58
|
+
"pytest>=7.0",
|
|
59
|
+
"pytest-cov>=4.0",
|
|
60
|
+
"pylint>=3.0",
|
|
61
|
+
"rsgispy[stats]",
|
|
62
|
+
]
|
|
63
|
+
docs = [
|
|
64
|
+
"sphinx>=7.0",
|
|
65
|
+
"sphinx-rtd-theme>=2.0",
|
|
66
|
+
]
|
|
67
|
+
dev = [
|
|
68
|
+
"rsgispy[stats,test,docs]",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
[project.urls]
|
|
72
|
+
Homepage = "https://github.com/remotesensinginfo/rsgispy"
|
|
73
|
+
Repository = "https://github.com/remotesensinginfo/rsgispy"
|
|
74
|
+
Issues = "https://github.com/remotesensinginfo/rsgispy/issues"
|
|
75
|
+
|
|
76
|
+
[tool.setuptools.dynamic]
|
|
77
|
+
version = {attr = "rsgispy.__version__"}
|
|
78
|
+
|
|
79
|
+
[tool.setuptools.packages.find]
|
|
80
|
+
where = ["."]
|
|
81
|
+
include = ["rsgispy*"]
|
|
82
|
+
|
|
83
|
+
[tool.pytest.ini_options]
|
|
84
|
+
testpaths = ["tests"]
|
|
85
|
+
pythonpath = ["."]
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"""
|
|
2
|
+
rsgispy: Pure Python replacement for the RSGISLib library.
|
|
3
|
+
Provides remote sensing and GIS software tools and utilities.
|
|
4
|
+
|
|
5
|
+
Data Types for images:
|
|
6
|
+
|
|
7
|
+
* TYPE_UNDEFINED = 0
|
|
8
|
+
* TYPE_8INT = 1
|
|
9
|
+
* TYPE_16INT = 2
|
|
10
|
+
* TYPE_32INT = 3
|
|
11
|
+
* TYPE_64INT = 4
|
|
12
|
+
* TYPE_8UINT = 5
|
|
13
|
+
* TYPE_16UINT = 6
|
|
14
|
+
* TYPE_32UINT = 7
|
|
15
|
+
* TYPE_64UINT = 8
|
|
16
|
+
* TYPE_32FLOAT = 9
|
|
17
|
+
* TYPE_64FLOAT = 10
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from typing import Union
|
|
21
|
+
import numpy as np
|
|
22
|
+
from rasterio.enums import Resampling
|
|
23
|
+
|
|
24
|
+
__version__ = "0.0.1"
|
|
25
|
+
|
|
26
|
+
TYPE_UNDEFINED = 0
|
|
27
|
+
TYPE_8INT = 1
|
|
28
|
+
TYPE_16INT = 2
|
|
29
|
+
TYPE_32INT = 3
|
|
30
|
+
TYPE_64INT = 4
|
|
31
|
+
TYPE_8UINT = 5
|
|
32
|
+
TYPE_16UINT = 6
|
|
33
|
+
TYPE_32UINT = 7
|
|
34
|
+
TYPE_64UINT = 8
|
|
35
|
+
TYPE_32FLOAT = 9
|
|
36
|
+
TYPE_64FLOAT = 10
|
|
37
|
+
|
|
38
|
+
INTERP_NEAREST_NEIGHBOUR = 0
|
|
39
|
+
INTERP_BILINEAR = 1
|
|
40
|
+
INTERP_CUBIC = 2
|
|
41
|
+
INTERP_CUBICSPLINE = 3
|
|
42
|
+
INTERP_LANCZOS = 4
|
|
43
|
+
INTERP_AVERAGE = 5
|
|
44
|
+
INTERP_MODE = 6
|
|
45
|
+
INTERP_MIN = 7
|
|
46
|
+
INTERP_MAX = 8
|
|
47
|
+
INTERP_MEDIAN = 9
|
|
48
|
+
INTERP_Q1 = 10
|
|
49
|
+
INTERP_Q3 = 11
|
|
50
|
+
INTERP_SUM = 12
|
|
51
|
+
|
|
52
|
+
IMG_STRETCH_NONE = 0
|
|
53
|
+
IMG_STRETCH_USER = 1
|
|
54
|
+
IMG_STRETCH_LINEAR = 2
|
|
55
|
+
IMG_STRETCH_STDEV = 3
|
|
56
|
+
IMG_STRETCH_CUMULATIVE = 4
|
|
57
|
+
|
|
58
|
+
_RSGIS_TO_RASTERIO_INTERP = {
|
|
59
|
+
INTERP_NEAREST_NEIGHBOUR: Resampling.nearest,
|
|
60
|
+
INTERP_BILINEAR: Resampling.bilinear,
|
|
61
|
+
INTERP_CUBIC: Resampling.cubic,
|
|
62
|
+
INTERP_CUBICSPLINE: Resampling.cubic_spline,
|
|
63
|
+
INTERP_LANCZOS: Resampling.lanczos,
|
|
64
|
+
INTERP_AVERAGE: Resampling.average,
|
|
65
|
+
INTERP_MODE: Resampling.mode,
|
|
66
|
+
INTERP_MIN: Resampling.min,
|
|
67
|
+
INTERP_MAX: Resampling.max,
|
|
68
|
+
INTERP_MEDIAN: Resampling.med,
|
|
69
|
+
INTERP_Q1: Resampling.q1,
|
|
70
|
+
INTERP_Q3: Resampling.q3,
|
|
71
|
+
INTERP_SUM: Resampling.sum,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_RSGIS_TO_RASTERIO_DTYPE = {
|
|
75
|
+
TYPE_8INT: "int8",
|
|
76
|
+
TYPE_16INT: "int16",
|
|
77
|
+
TYPE_32INT: "int32",
|
|
78
|
+
TYPE_64INT: "int64",
|
|
79
|
+
TYPE_8UINT: "uint8",
|
|
80
|
+
TYPE_16UINT: "uint16",
|
|
81
|
+
TYPE_32UINT: "uint32",
|
|
82
|
+
TYPE_64UINT: "uint64",
|
|
83
|
+
TYPE_32FLOAT: "float32",
|
|
84
|
+
TYPE_64FLOAT: "float64",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_RSGIS_TO_NUMPY_DTYPE = {
|
|
88
|
+
TYPE_8INT: np.int8,
|
|
89
|
+
TYPE_16INT: np.int16,
|
|
90
|
+
TYPE_32INT: np.int32,
|
|
91
|
+
TYPE_64INT: np.int64,
|
|
92
|
+
TYPE_8UINT: np.uint8,
|
|
93
|
+
TYPE_16UINT: np.uint16,
|
|
94
|
+
TYPE_32UINT: np.uint32,
|
|
95
|
+
TYPE_64UINT: np.uint64,
|
|
96
|
+
TYPE_32FLOAT: np.float32,
|
|
97
|
+
TYPE_64FLOAT: np.float64,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_RSGIS_TO_STR_DTYPE = {
|
|
101
|
+
TYPE_8INT: "8 bit INTEGER",
|
|
102
|
+
TYPE_16INT: "16 bit INTEGER",
|
|
103
|
+
TYPE_32INT: "32 bit INTEGER",
|
|
104
|
+
TYPE_64INT: "64 bit INTEGER",
|
|
105
|
+
TYPE_8UINT: "8 bit UNSIGNED INTEGER (BYTE)",
|
|
106
|
+
TYPE_16UINT: "16 bit UNSIGNED INTEGER",
|
|
107
|
+
TYPE_32UINT: "32 bit UNSIGNED INTEGER",
|
|
108
|
+
TYPE_64UINT: "64 bit UNSIGNED INTEGER",
|
|
109
|
+
TYPE_32FLOAT: "32 bit FLOAT",
|
|
110
|
+
TYPE_64FLOAT: "64 bit FLOAT",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_STR_TO_RSGIS_DTYPE = {
|
|
114
|
+
"int8": TYPE_8INT,
|
|
115
|
+
"int16": TYPE_16INT,
|
|
116
|
+
"int32": TYPE_32INT,
|
|
117
|
+
"int64": TYPE_64INT,
|
|
118
|
+
"byte": TYPE_8UINT,
|
|
119
|
+
"uint8": TYPE_8UINT,
|
|
120
|
+
"uint16": TYPE_16UINT,
|
|
121
|
+
"uint32": TYPE_32UINT,
|
|
122
|
+
"uint64": TYPE_64UINT,
|
|
123
|
+
"float32": TYPE_32FLOAT,
|
|
124
|
+
"float64": TYPE_64FLOAT,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class RSGISPyException(Exception):
|
|
129
|
+
"""
|
|
130
|
+
A class representing an RSGISPy exception.
|
|
131
|
+
"""
|
|
132
|
+
|
|
133
|
+
def __init__(self, value: str):
|
|
134
|
+
"""
|
|
135
|
+
Init for the RSGISPyException class.
|
|
136
|
+
"""
|
|
137
|
+
super().__init__(value)
|
|
138
|
+
self.value = value
|
|
139
|
+
|
|
140
|
+
def __str__(self) -> str:
|
|
141
|
+
"""
|
|
142
|
+
Return a string representation of the exception.
|
|
143
|
+
"""
|
|
144
|
+
return repr(self.value)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def get_rsgis_datatype(gdal_type: str) -> int:
|
|
148
|
+
"""
|
|
149
|
+
Convert from a GDAL/rasterio data type string to an RSGIS data type int.
|
|
150
|
+
|
|
151
|
+
:param gdal_type: Data type name string (e.g., 'float32', 'uint8', 'byte').
|
|
152
|
+
:return: RSGIS data type constant (e.g., rsgispy.TYPE_32FLOAT).
|
|
153
|
+
"""
|
|
154
|
+
key = gdal_type.lower().strip()
|
|
155
|
+
if key not in _STR_TO_RSGIS_DTYPE:
|
|
156
|
+
raise RSGISPyException(
|
|
157
|
+
f"The data type '{gdal_type}' is unknown / not supported."
|
|
158
|
+
)
|
|
159
|
+
return _STR_TO_RSGIS_DTYPE[key]
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def get_rasterio_datatype(rsgislib_datatype: int) -> str:
|
|
163
|
+
"""
|
|
164
|
+
Convert from an RSGIS data type int to a rasterio/GDAL dtype string.
|
|
165
|
+
|
|
166
|
+
:param rsgislib_datatype: RSGIS data type constant (e.g., rsgispy.TYPE_32FLOAT).
|
|
167
|
+
:return: Rasterio dtype string (e.g., 'float32').
|
|
168
|
+
"""
|
|
169
|
+
if rsgislib_datatype not in _RSGIS_TO_RASTERIO_DTYPE:
|
|
170
|
+
raise RSGISPyException(
|
|
171
|
+
f"The data type '{rsgislib_datatype}' is unknown / not supported."
|
|
172
|
+
)
|
|
173
|
+
return _RSGIS_TO_RASTERIO_DTYPE[rsgislib_datatype]
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def get_numpy_datatype(rsgislib_datatype: int):
|
|
177
|
+
"""
|
|
178
|
+
Convert from an RSGIS data type int to a NumPy dtype.
|
|
179
|
+
|
|
180
|
+
:param rsgislib_datatype: RSGIS data type constant (e.g., rsgispy.TYPE_32FLOAT).
|
|
181
|
+
:return: NumPy dtype class (e.g., numpy.float32).
|
|
182
|
+
"""
|
|
183
|
+
if rsgislib_datatype not in _RSGIS_TO_NUMPY_DTYPE:
|
|
184
|
+
raise RSGISPyException("Data type was not recognised.")
|
|
185
|
+
return _RSGIS_TO_NUMPY_DTYPE[rsgislib_datatype]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def get_rsgis_datatype_str(rsgislib_datatype: int) -> str:
|
|
189
|
+
"""
|
|
190
|
+
Get a human-readable string representation of the RSGIS data type.
|
|
191
|
+
|
|
192
|
+
:param rsgislib_datatype: RSGIS data type constant.
|
|
193
|
+
:return: Human-readable string description.
|
|
194
|
+
"""
|
|
195
|
+
if rsgislib_datatype not in _RSGIS_TO_STR_DTYPE:
|
|
196
|
+
raise RSGISPyException(
|
|
197
|
+
f"The data type '{rsgislib_datatype}' is unknown / not supported."
|
|
198
|
+
)
|
|
199
|
+
return _RSGIS_TO_STR_DTYPE[rsgislib_datatype]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def get_rasterio_interp_type(
|
|
203
|
+
rsgis_interp_method: Union[int, Resampling],
|
|
204
|
+
) -> Resampling:
|
|
205
|
+
"""
|
|
206
|
+
Convert an ``rsgispy.INTERP_*`` (or ``rsgislib.INTERP_*``) constant to a
|
|
207
|
+
``rasterio.enums.Resampling`` enum member.
|
|
208
|
+
|
|
209
|
+
:param rsgis_interp_method: Interpolation constant or ``Resampling`` enum.
|
|
210
|
+
:return: Corresponding ``rasterio.enums.Resampling`` value.
|
|
211
|
+
"""
|
|
212
|
+
if isinstance(rsgis_interp_method, Resampling):
|
|
213
|
+
return rsgis_interp_method
|
|
214
|
+
if rsgis_interp_method not in _RSGIS_TO_RASTERIO_INTERP:
|
|
215
|
+
raise RSGISPyException(
|
|
216
|
+
"Interpolation method was not recognised or known."
|
|
217
|
+
)
|
|
218
|
+
return _RSGIS_TO_RASTERIO_INTERP[rsgis_interp_method]
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def is_notebook() -> bool:
|
|
222
|
+
"""
|
|
223
|
+
Determine whether code is executing inside a Jupyter notebook environment.
|
|
224
|
+
|
|
225
|
+
:return: True if running within a Jupyter notebook or qtconsole, False otherwise.
|
|
226
|
+
"""
|
|
227
|
+
try:
|
|
228
|
+
shell = get_ipython().__class__.__name__ # type: ignore[name-defined]
|
|
229
|
+
if shell == "ZMQInteractiveShell":
|
|
230
|
+
return True
|
|
231
|
+
return False
|
|
232
|
+
except NameError:
|
|
233
|
+
return False
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def get_tqdm():
|
|
237
|
+
"""
|
|
238
|
+
Return the appropriate tqdm progress bar callable for the current environment
|
|
239
|
+
(Jupyter notebook widget when inside a notebook and ipywidgets is available,
|
|
240
|
+
or standard terminal tqdm otherwise).
|
|
241
|
+
|
|
242
|
+
:return: tqdm class/callable.
|
|
243
|
+
"""
|
|
244
|
+
if is_notebook():
|
|
245
|
+
try:
|
|
246
|
+
import ipywidgets # noqa: F401 # pylint: disable=unused-import,import-outside-toplevel
|
|
247
|
+
import tqdm.notebook # pylint: disable=import-outside-toplevel
|
|
248
|
+
|
|
249
|
+
return tqdm.notebook.tqdm
|
|
250
|
+
except ImportError:
|
|
251
|
+
pass
|
|
252
|
+
import tqdm # pylint: disable=import-outside-toplevel
|
|
253
|
+
|
|
254
|
+
return tqdm.tqdm
|