获取geojson

时间:2018-08-13 15:24:01

标签: python-3.x sentinelsat

很抱歉,以前是否有人提出或回答过这个问题。我找不到它。

我对python还是比较陌生,我目前正在设置一个脚本,用于通过sentinelsat模块从ESA哨兵中心下载文件。

现在它可以工作了,但是我希望它有一种打印所涉及的文件总大小的方法。我已经打印了所有文件的名称及其各自的数据大小。我也列出了文件总数。现在,我只需要将单个数据大小总计为1个值即可。

这是我的代码段:

print("Listing file name and size:")
print("")
for n in range(0, np.size(bu_images_json["features"])):
    print("Image name: ",json.dumps(bu_images_json["features"][n]["properties"]["title"]))
    print("File size: ",json.dumps(bu_images_json["features"][n]["properties"]["size"]))
print("Found", n+1, "files availible for download")
print("Total amount to download")

看起来像这样

Image name:  "S2A_OPER_PRD_MSIL1C_PDMC_20161009T061329_R010_V20160727T140022_20160727T140246"
File size:  "5.02 GB"
Image name:  "S2A_OPER_PRD_MSIL1C_PDMC_20161009T060351_R139_V20160726T142942_20160726T143122"
File size:  "5.99 GB"
Image name:  "S2A_OPER_PRD_MSIL1C_PDMC_20160720T213054_R053_V20160720T141008_20160720T141008"
File size:  "5.65 GB"
Found 131 files availible for download
Total amount to download

如果任何人都知道任何github页面或类似内容,任何人都在其中玩过并扩展了sentinelsat模块-那么,我也想拥有一个链接。

谢谢您的时间。

1 个答案:

答案 0 :(得分:3)

from re import sub
print("Listing file name and size:")
total = 0
print("")
for n in range(0, np.size(bu_images_json["features"])):
    print("Image name: ",json.dumps(bu_images_json["features"][n]["properties"]["title"]))
    print("File size: ",json.dumps(bu_images_json["features"][n]["properties"]["size"]))
    total += float(sub('[^0-9.]','',json.dumps(bu_images_json["features"][n]["properties"]["size"])))
print("Found", n+1, "files availible for download")
print("Total amount to download: ",total)