usgsxplore 0.0.2__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Amaury Dehecq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,172 @@
1
+ Metadata-Version: 2.1
2
+ Name: usgsxplore
3
+ Version: 0.0.2
4
+ Summary: Search and download data or scenes from USGS API
5
+ Home-page: https://github.com/adehecq/usgs_explorer
6
+ License: MIT
7
+ Keywords: earth observation,remote sesing,GIS,satellite imagery,USGS,M2M
8
+ Author: Godin Luc
9
+ Author-email: godin.luc2002@gmail.com
10
+ Maintainer: Amaury Dehecq
11
+ Maintainer-email: this-is-not-an-email@a.com
12
+ Requires-Python: >=3.10,<4.0
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Dist: click (>=8.1.7,<9.0.0)
19
+ Requires-Dist: geopandas (>=1.0.1,<2.0.0)
20
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
21
+ Requires-Dist: shapely (>=2.0.5,<3.0.0)
22
+ Requires-Dist: tqdm (>=4.66.4,<5.0.0)
23
+ Project-URL: Documentation, https://github.com/adehecq/usgs_explorer
24
+ Project-URL: Repository, https://github.com/adehecq/usgs_explorer
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Description
28
+
29
+ The **usgsxplore** Python package provides an interface to the [M2M API](https://m2m.cr.usgs.gov/) to search and donwloads scenes.
30
+
31
+ This package is highly inspired of [landsatxplore](https://github.com/yannforget/landsatxplore) but it support more dataset and add functionalities.
32
+
33
+ # Quick start
34
+
35
+ Searching for Landsat scenes that contains the location (5.7074, 45.1611) acquired between 2010-2020.
36
+
37
+ ```bash
38
+ usgsxplore search landsat_tm_c2_l1 --location 5.7074 45.1611 --interval-date 2010-01-01 2020-01-01
39
+ ```
40
+
41
+ Search for Hexagon KH-9 scenes. Save the result into a geopackage
42
+
43
+ ```bash
44
+ usgsxplore search declassii --filter "camera=H" --output results.gpkg
45
+ ```
46
+
47
+ Downloading the 10 first images from landsat_tm_c2_l1
48
+ ```bash
49
+ usgsxplore search landsat_tm_c2_l1 --limit 10 --output results.txt
50
+ usgsxplore download results.txt
51
+ ```
52
+
53
+ # Installation
54
+
55
+ The package can be installed using pip.
56
+
57
+ ```bash
58
+ pip install usgsxplore
59
+ ```
60
+
61
+ # Usage
62
+
63
+ **usgsxplore** can be used both through its command-line interface and as a python module.
64
+
65
+ ## Command-line interface
66
+
67
+ ```bash
68
+ usgsxplore --help
69
+ ```
70
+
71
+ ```
72
+ Usage: usgsxplore [OPTIONS] COMMAND [ARGS]...
73
+
74
+ Command line interface of the usgsxplore. Documentation :
75
+ https://github.com/adehecq/usgs_explorer
76
+
77
+ Options:
78
+ --help Show this message and exit.
79
+
80
+ Commands:
81
+ download Download scenes with their entity ids provided in the textfile.
82
+ search Search scenes in a dataset with filters.
83
+ ```
84
+
85
+ ### Credentials
86
+
87
+ Credentials for the Earth Explorer portal can be obtained [here](https://ers.cr.usgs.gov/register/).
88
+
89
+ `--username` and `--token` or `--password` can be provided as command-line options or as environment variables:
90
+
91
+ ``` shell
92
+ export USGSXPLORE_USERNAME=<your_username>
93
+ export USGSXPLORE_TOKEN=<your_token>
94
+ export USGSXPLORE_PASSWORD=<your_password>
95
+ ```
96
+
97
+ ### Searching
98
+
99
+ ```bash
100
+ usgsxplore search --help
101
+ ```
102
+
103
+ ```
104
+ Usage: usgsxplore search [OPTIONS] DATASET
105
+
106
+ Search scenes in a dataset with filters.
107
+
108
+ Options:
109
+ -u, --username TEXT EarthExplorer username. [required]
110
+ -p, --password TEXT EarthExplorer password.
111
+ -t, --token TEXT EarthExplorer token.
112
+ -o, --output PATH Output file : (txt, json, gpkg, shp, geojson)
113
+ -l, --location FLOAT... Point of interest (longitude, latitude).
114
+ -b, --bbox FLOAT... Bounding box (xmin, ymin, xmax, ymax).
115
+ -c, --clouds INTEGER Max. cloud cover (1-100).
116
+ -i, --interval-date TEXT... Date interval (start, end), (YYYY-MM-DD, YYYY-
117
+ MM-DD).
118
+ -f, --filter TEXT String representation of metadata filter
119
+ -m, --limit INTEGER Max. results returned. Return all by default
120
+ --pbar Display a progress bar
121
+ --help Show this message and exit.
122
+ ```
123
+
124
+ If the `--output` is not provided, the command will print entity ids of scenes found. Else if the `--output` is provided it will save results in the file. There is 5 availables format for the results:
125
+ - **text file (.txt)** : Each line is an entity id and the first line contain the dataset ex: `#dataset=landsat_tm_c2_l1`. This file is often use to download the scenes.
126
+ - **json file (.json)** : json file containing the results of the search.
127
+ - **vector data (.gpkg, .shp, .geojson)** : save the results in a vector data file, usefull to visualise the results.
128
+
129
+ The search command work with multiple scene-search so there is no limit of results, but you can fixe one with `--limit`.
130
+
131
+ If you provide a wrong dataset, a list of 50 datasets with high string similarity will be print.
132
+
133
+ The `--filter` work like this "`field1=value1 & field2=value2 | field3=value3`". For the field you can put either the filter id, the filter label, or the sql filter. For the value you can put either value or value label. Exemples:
134
+ ```bash
135
+ # select scenes of satelites Hexagon KH-9
136
+ # all of those 4 command will give the same results
137
+ usgsxplore search declassii --filter "camera=L"
138
+ usgsxplore search declassii --filter "Camera Type=L"
139
+ usgsxplore search declassii --filter "5e839ff8cfa94807=L"
140
+ usgsxplore search declassii --filter "camera=KH-9 Lower Resolution Mapping Camera"
141
+
142
+ # select scenes of satelites Hexagon KH-9 if their are downloadable
143
+ usgsxplore search declassii --filter "camera=L & DOWNLOAD_AVAILABLE=Y"
144
+ ```
145
+
146
+ ### Downloading
147
+
148
+ ```bash
149
+ usgsxplore download --help
150
+ ```
151
+ ```
152
+ Usage: usgsxplore download [OPTIONS] TEXTFILE
153
+
154
+ Download scenes with their entity ids provided in the textfile. The dataset
155
+ can also be provide in the first line of the textfile : #dataset=declassii
156
+
157
+ Options:
158
+ -u, --username TEXT EarthExplorer username.
159
+ -p, --password TEXT EarthExplorer password.
160
+ -t, --token TEXT EarthExplorer token.
161
+ -d, --dataset TEXT Dataset
162
+ -o, --output-dir PATH Output directory
163
+ -b, --pbar INTEGER RANGE Type of progression displaying (0,1,2) [0<=x<=2]
164
+ -m, --max-thread INTEGER Max thread number (default: 5)
165
+ --overwrite Overwrite existing files
166
+ --help Show this message and exit.
167
+ ```
168
+ This command download scenes from their entity ids in the `TEXTFILE` and save the results in `--output-dir`. It can display different type of progression depends on `--pbar` value:
169
+ - **0** : display nothing.
170
+ - **1** : display one progress bar for all scenes downloading.
171
+ - **2** : display a progress bar for each scenes downloading, with state information.
172
+
@@ -0,0 +1,145 @@
1
+ # Description
2
+
3
+ The **usgsxplore** Python package provides an interface to the [M2M API](https://m2m.cr.usgs.gov/) to search and donwloads scenes.
4
+
5
+ This package is highly inspired of [landsatxplore](https://github.com/yannforget/landsatxplore) but it support more dataset and add functionalities.
6
+
7
+ # Quick start
8
+
9
+ Searching for Landsat scenes that contains the location (5.7074, 45.1611) acquired between 2010-2020.
10
+
11
+ ```bash
12
+ usgsxplore search landsat_tm_c2_l1 --location 5.7074 45.1611 --interval-date 2010-01-01 2020-01-01
13
+ ```
14
+
15
+ Search for Hexagon KH-9 scenes. Save the result into a geopackage
16
+
17
+ ```bash
18
+ usgsxplore search declassii --filter "camera=H" --output results.gpkg
19
+ ```
20
+
21
+ Downloading the 10 first images from landsat_tm_c2_l1
22
+ ```bash
23
+ usgsxplore search landsat_tm_c2_l1 --limit 10 --output results.txt
24
+ usgsxplore download results.txt
25
+ ```
26
+
27
+ # Installation
28
+
29
+ The package can be installed using pip.
30
+
31
+ ```bash
32
+ pip install usgsxplore
33
+ ```
34
+
35
+ # Usage
36
+
37
+ **usgsxplore** can be used both through its command-line interface and as a python module.
38
+
39
+ ## Command-line interface
40
+
41
+ ```bash
42
+ usgsxplore --help
43
+ ```
44
+
45
+ ```
46
+ Usage: usgsxplore [OPTIONS] COMMAND [ARGS]...
47
+
48
+ Command line interface of the usgsxplore. Documentation :
49
+ https://github.com/adehecq/usgs_explorer
50
+
51
+ Options:
52
+ --help Show this message and exit.
53
+
54
+ Commands:
55
+ download Download scenes with their entity ids provided in the textfile.
56
+ search Search scenes in a dataset with filters.
57
+ ```
58
+
59
+ ### Credentials
60
+
61
+ Credentials for the Earth Explorer portal can be obtained [here](https://ers.cr.usgs.gov/register/).
62
+
63
+ `--username` and `--token` or `--password` can be provided as command-line options or as environment variables:
64
+
65
+ ``` shell
66
+ export USGSXPLORE_USERNAME=<your_username>
67
+ export USGSXPLORE_TOKEN=<your_token>
68
+ export USGSXPLORE_PASSWORD=<your_password>
69
+ ```
70
+
71
+ ### Searching
72
+
73
+ ```bash
74
+ usgsxplore search --help
75
+ ```
76
+
77
+ ```
78
+ Usage: usgsxplore search [OPTIONS] DATASET
79
+
80
+ Search scenes in a dataset with filters.
81
+
82
+ Options:
83
+ -u, --username TEXT EarthExplorer username. [required]
84
+ -p, --password TEXT EarthExplorer password.
85
+ -t, --token TEXT EarthExplorer token.
86
+ -o, --output PATH Output file : (txt, json, gpkg, shp, geojson)
87
+ -l, --location FLOAT... Point of interest (longitude, latitude).
88
+ -b, --bbox FLOAT... Bounding box (xmin, ymin, xmax, ymax).
89
+ -c, --clouds INTEGER Max. cloud cover (1-100).
90
+ -i, --interval-date TEXT... Date interval (start, end), (YYYY-MM-DD, YYYY-
91
+ MM-DD).
92
+ -f, --filter TEXT String representation of metadata filter
93
+ -m, --limit INTEGER Max. results returned. Return all by default
94
+ --pbar Display a progress bar
95
+ --help Show this message and exit.
96
+ ```
97
+
98
+ If the `--output` is not provided, the command will print entity ids of scenes found. Else if the `--output` is provided it will save results in the file. There is 5 availables format for the results:
99
+ - **text file (.txt)** : Each line is an entity id and the first line contain the dataset ex: `#dataset=landsat_tm_c2_l1`. This file is often use to download the scenes.
100
+ - **json file (.json)** : json file containing the results of the search.
101
+ - **vector data (.gpkg, .shp, .geojson)** : save the results in a vector data file, usefull to visualise the results.
102
+
103
+ The search command work with multiple scene-search so there is no limit of results, but you can fixe one with `--limit`.
104
+
105
+ If you provide a wrong dataset, a list of 50 datasets with high string similarity will be print.
106
+
107
+ The `--filter` work like this "`field1=value1 & field2=value2 | field3=value3`". For the field you can put either the filter id, the filter label, or the sql filter. For the value you can put either value or value label. Exemples:
108
+ ```bash
109
+ # select scenes of satelites Hexagon KH-9
110
+ # all of those 4 command will give the same results
111
+ usgsxplore search declassii --filter "camera=L"
112
+ usgsxplore search declassii --filter "Camera Type=L"
113
+ usgsxplore search declassii --filter "5e839ff8cfa94807=L"
114
+ usgsxplore search declassii --filter "camera=KH-9 Lower Resolution Mapping Camera"
115
+
116
+ # select scenes of satelites Hexagon KH-9 if their are downloadable
117
+ usgsxplore search declassii --filter "camera=L & DOWNLOAD_AVAILABLE=Y"
118
+ ```
119
+
120
+ ### Downloading
121
+
122
+ ```bash
123
+ usgsxplore download --help
124
+ ```
125
+ ```
126
+ Usage: usgsxplore download [OPTIONS] TEXTFILE
127
+
128
+ Download scenes with their entity ids provided in the textfile. The dataset
129
+ can also be provide in the first line of the textfile : #dataset=declassii
130
+
131
+ Options:
132
+ -u, --username TEXT EarthExplorer username.
133
+ -p, --password TEXT EarthExplorer password.
134
+ -t, --token TEXT EarthExplorer token.
135
+ -d, --dataset TEXT Dataset
136
+ -o, --output-dir PATH Output directory
137
+ -b, --pbar INTEGER RANGE Type of progression displaying (0,1,2) [0<=x<=2]
138
+ -m, --max-thread INTEGER Max thread number (default: 5)
139
+ --overwrite Overwrite existing files
140
+ --help Show this message and exit.
141
+ ```
142
+ This command download scenes from their entity ids in the `TEXTFILE` and save the results in `--output-dir`. It can display different type of progression depends on `--pbar` value:
143
+ - **0** : display nothing.
144
+ - **1** : display one progress bar for all scenes downloading.
145
+ - **2** : display a progress bar for each scenes downloading, with state information.
@@ -0,0 +1,35 @@
1
+ [tool.poetry]
2
+ name = "usgsxplore"
3
+ version = "0.0.2"
4
+ description = "Search and download data or scenes from USGS API"
5
+ authors = ["Godin Luc <godin.luc2002@gmail.com>"]
6
+ maintainers = ["Amaury Dehecq <this-is-not-an-email@a.com>"]
7
+ license = "MIT"
8
+ readme = "README.md"
9
+ homepage = "https://github.com/adehecq/usgs_explorer"
10
+ repository = "https://github.com/adehecq/usgs_explorer"
11
+ documentation = "https://github.com/adehecq/usgs_explorer"
12
+ keywords = ["earth observation","remote sesing", "GIS","satellite imagery", "USGS", "M2M"]
13
+
14
+
15
+ [tool.poetry.dependencies]
16
+ python = "^3.10"
17
+ requests = "^2.32.3"
18
+ geopandas = "^1.0.1"
19
+ tqdm = "^4.66.4"
20
+ shapely = "^2.0.5"
21
+ click = "^8.1.7"
22
+
23
+
24
+ [tool.poetry.group.dev.dependencies]
25
+ pytest = "^8.2.2"
26
+ pytest-cov = "^5.0.0"
27
+ flake8 = "^7.1.0"
28
+ pre-commit = "^3.7.1"
29
+
30
+ [tool.poetry.scripts]
31
+ usgsxplore = "usgsxplore.cli:cli"
32
+
33
+ [build-system]
34
+ requires = ["poetry-core"]
35
+ build-backend = "poetry.core.masonry.api"
File without changes