Commit 4f98dda2 authored by lixiao's avatar lixiao

add data size

parent 7422e179
...@@ -3,7 +3,7 @@ from pyproj import Transformer ...@@ -3,7 +3,7 @@ from pyproj import Transformer
import rasterio import rasterio
import numpy as np import numpy as np
import json import json
import re import re,os
def get_epsg_code_rasterio(filepath): def get_epsg_code_rasterio(filepath):
with rasterio.open(filepath) as dataset: with rasterio.open(filepath) as dataset:
...@@ -51,6 +51,12 @@ def get_cloud_coverage(json_path, satellite): ...@@ -51,6 +51,12 @@ def get_cloud_coverage(json_path, satellite):
return cloud_coverage,dataTime,grid return cloud_coverage,dataTime,grid
def get_tif_file_size(file_path):
# 获取文件大小(字节)
file_size = os.path.getsize(file_path)
# 转换为 MB
file_size_mb = file_size / (1024 * 1024)
return file_size_mb
def get_footprint(json_path, satellite): def get_footprint(json_path, satellite):
#哨兵2 tileInfo.json 中 tileDataGeometry #哨兵2 tileInfo.json 中 tileDataGeometry
......
...@@ -36,6 +36,12 @@ def get_file_timestamp_iso(tif_path): ...@@ -36,6 +36,12 @@ def get_file_timestamp_iso(tif_path):
timestamp_iso = timestamp_dt.isoformat(timespec='seconds') + "Z" timestamp_iso = timestamp_dt.isoformat(timespec='seconds') + "Z"
return timestamp_iso return timestamp_iso
def get_tif_file_size(file_path):
# 获取文件大小(字节)
file_size = os.path.getsize(file_path)
# 转换为 MB
file_size_mb = file_size / (1024 * 1024)
return file_size_mb
def fill_productInfoList(tif_path, input_config,json_path): def fill_productInfoList(tif_path, input_config,json_path):
outputProductInfo = { outputProductInfo = {
...@@ -48,7 +54,8 @@ def fill_productInfoList(tif_path, input_config,json_path): ...@@ -48,7 +54,8 @@ def fill_productInfoList(tif_path, input_config,json_path):
"outputProductInfo":outputProductInfo, "outputProductInfo":outputProductInfo,
"extent":get_extent.get_extent_wgs84(tif_path), "extent":get_extent.get_extent_wgs84(tif_path),
"productionTime":get_file_timestamp_iso(tif_path), "productionTime":get_file_timestamp_iso(tif_path),
"footprint":get_extent.get_footprint(json_path, input_config["satellite"]) "footprint":get_extent.get_footprint(json_path, input_config["satellite"]),
"dataSize":get_tif_file_size(tif_path)
} }
input_template['productInfoList'][0].update( input_template['productInfoList'][0].update(
productInfoList productInfoList
......
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