Commit 7422e179 authored by lixiao's avatar lixiao

fix landssat

parent 36f979e8
Pipeline #9831 failed with stages
...@@ -79,7 +79,8 @@ def get_s2_tif_name(input_config): ...@@ -79,7 +79,8 @@ def get_s2_tif_name(input_config):
return output_path return output_path
def get_landsat_tif_name(input_config): def get_landsat_tif_name(input_config):
parts = input_config['input_path'].split('_') parts = os.path.basename(input_config['input_path']).split('_')
print(parts)
# 获取当前时间并格式化 # 获取当前时间并格式化
if input_config['index'] == 'NDWI': if input_config['index'] == 'NDWI':
index_name = 'WaterExtraction' index_name = 'WaterExtraction'
...@@ -89,6 +90,7 @@ def get_landsat_tif_name(input_config): ...@@ -89,6 +90,7 @@ def get_landsat_tif_name(input_config):
output_name = "_".join([parts[0], parts[1], parts[3], parts[2], index_name, current_time]) + '.tif' output_name = "_".join([parts[0], parts[1], parts[3], parts[2], index_name, current_time]) + '.tif'
os.makedirs(input_config["output_path"], exist_ok=True) os.makedirs(input_config["output_path"], exist_ok=True)
output_path = os.path.join(input_config['output_path'],output_name) output_path = os.path.join(input_config['output_path'],output_name)
print(output_path)
return output_path return output_path
def visible_go(input_config): def visible_go(input_config):
...@@ -135,7 +137,7 @@ def visible_go(input_config): ...@@ -135,7 +137,7 @@ def visible_go(input_config):
if input_config['satellite'] == 'sentinel2': if input_config['satellite'] == 'sentinel2':
json_path = input_config['input_path'].replace('metadata.xml','tileInfo.json') json_path = input_config['input_path'].replace('metadata.xml','tileInfo.json')
if input_config['satellite'] == 'landsat': if input_config['satellite'] == 'landsat':
json_path = input_config['input_path'].replace('MTL.xml','stac.json') json_path = input_config['input_path'].replace('MTL.xml','SR_stac.json')
outjson_path = out_json(input_config, json_path, output_path) outjson_path = out_json(input_config, json_path, output_path)
...@@ -172,20 +174,20 @@ def visible_go(input_config): ...@@ -172,20 +174,20 @@ def visible_go(input_config):
if __name__ == "__main__": if __name__ == "__main__":
input_config = {
"index": "NDWI",
"satellite": "sentinel2",
"input_path": r"D:\hunan\50RKQ_l2a\metadata.xml",
"output_path": r"D:\hunan\50RKQ_l2a\test2"
}
# input_config = { # input_config = {
# "index": "NDVI", # "index": "NDWI",
# "satellite": "landsat", # "satellite": "sentinel2",
# "input_path": r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\LC08_L2SP_122043_20231227_20240104_02_T1_MTL.xml", # "input_path": r"D:\hunan\50RKQ_l2a\metadata.xml",
# "output_path": r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\test\test_ndvi7.tif" # "output_path": r"D:\hunan\50RKQ_l2a\test2"
# } # }
input_config = {
"index": "NDVI",
"satellite": "landsat",
"input_path": r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\LC08_L2SP_122043_20231227_20240104_02_T1_MTL.xml",
"output_path": r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\test1"
}
# input_config = { # input_config = {
# "index": "NDWI", # "index": "NDWI",
# "satellite": "sentinel1", # "satellite": "sentinel1",
......
...@@ -71,7 +71,7 @@ def get_footprint(json_path, satellite): ...@@ -71,7 +71,7 @@ def get_footprint(json_path, satellite):
elif satellite == 'landsat': elif satellite == 'landsat':
coordinates_wgs84 = data['geometry']['coordinates'] coordinates_wgs84 = data['geometry']['coordinates'][0]
footprint.update({ footprint.update({
"coordinates": [[coordinates_wgs84]] "coordinates": [[coordinates_wgs84]]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment