You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for scene in scenes:
print(scene['acquisition_date'].strftime('%Y-%m-%d'))
# Write scene footprints to disk
fname = f"{scene['landsat_product_id']}.geojson"
with open(fname, "w") as f:
json.dump(scene['spatial_coverage'].geo_interface, f)
print(f)
import json
from landsatxplore.api import API
from landsatxplore.earthexplorer import EarthExplorer
Initialize a new API instance and get an access key
usgs_username = ""
usgs_password = ""
api = API(usgs_username, usgs_password)
Search for Landsat TM scenes
scenes = api.search(
dataset='landsat_ot_c2_l1',
latitude=30.9,
longitude=75.85,
#bbox= (70, 28, 80, 32), #(xmin, ymin, xmax, ymax),
start_date='2017-01-01',
end_date='2017-04-01',
max_cloud_cover=10
)
print(f"{len(scenes)} scenes found.")
Process the result
for scene in scenes:
print(scene['acquisition_date'].strftime('%Y-%m-%d'))
# Write scene footprints to disk
fname = f"{scene['landsat_product_id']}.geojson"
with open(fname, "w") as f:
json.dump(scene['spatial_coverage'].geo_interface, f)
print(f)
api.logout()
output
3 scenes found.
2017-03-19
<_io.TextIOWrapper name='LC08_L1TP_148038_20170319_20200904_02_T1.geojson' mode='w' encoding='cp1252'>
2017-03-19
<_io.TextIOWrapper name='LC08_L1TP_148039_20170319_20200904_02_T1.geojson' mode='w' encoding='cp1252'>
2017-02-15
<_io.TextIOWrapper name='LC08_L1TP_148039_20170215_20200905_02_T1.geojson' mode='w' encoding='cp1252'>
Downloading Scenes
ee = EarthExplorer(usgs_username, usgs_password)
ee.download('LC08_L1TP_148038_20170319_20200904_02_T1', output_dir=r'D:\RF_Paper\JAM\MODIS')
ee.logout()
error
EarthExplorerError Traceback (most recent call last)
in
2 ee = EarthExplorer(usgs_username, usgs_password)
3
----> 4 ee.download('LC08_L1TP_148038_20170319_20200904_02_T1', output_dir=r'D:\RF_Paper\JAM\MODIS')
5
6 ee.logout()
~\Anaconda3\lib\site-packages\landsatxplore\earthexplorer.py in download(self, identifier, output_dir, dataset, timeout, skip)
148 data_product_id=DATA_PRODUCTS[dataset], entity_id=entity_id
149 )
--> 150 filename = self._download(url, output_dir, timeout=timeout, skip=skip)
151 return filename
~\Anaconda3\lib\site-packages\landsatxplore\earthexplorer.py in _download(self, url, output_dir, timeout, chunk_size, skip)
90 error_msg = r.json().get("errorMessage")
91 if error_msg:
---> 92 raise EarthExplorerError(error_msg)
93 download_url = r.json().get("url")
94
EarthExplorerError: Download is not available
The text was updated successfully, but these errors were encountered: