Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从GEOJSON文件中检索数据值,并将其输入到.py文件中的公式中_Python_Pycharm_Formula_Geojson_Equation - Fatal编程技术网

Python 从GEOJSON文件中检索数据值,并将其输入到.py文件中的公式中

Python 从GEOJSON文件中检索数据值,并将其输入到.py文件中的公式中,python,pycharm,formula,geojson,equation,Python,Pycharm,Formula,Geojson,Equation,我有一个GEOJSON文件,其中包含地震信息,例如特定地震的震级和深度: {"type": "FeatureCollection","name": "event_CATAC2020vvem","crs": { "type": "name", "properties": { "name": "urn:ogc:d

我有一个GEOJSON文件,其中包含地震信息,例如特定地震的震级和深度:

{"type": "FeatureCollection","name": "event_CATAC2020vvem","crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },"features": [{ "type": "Feature", "properties": { "id": "CATAC2020vvem", "date": "2020-11-06 10:22:48", "latitude": "6.887407303", "longitude": "-73.20696259", "magnitude": "4.315760204", "depth": "151.9202271" },"geometry": { "type": "Point", "coordinates": [ -73.20696259, 6.887407303 ] } }]}
我还有一个.py文件,其中包含一个公式,用于计算和打印强度值的距离d的结果

ml = float(input("Enter Magnitude Value: "))
h = float(input("Enter Depth Value: "))
#Iso = float(input("Enter Intensity MMI Value: "))
import math

Io = 1.5 * (ml - math.log(h) + 1.4)

for Iso in [i/10 for i in range(5,125,5)]:
    a = (Io - Iso) / (1.8)
    d = (10 / 8) * (a)
    d = d - 1
    if d <= 0:
        print("Distance is zero")
    else:
        d = math.sqrt(h * h + d * d)
        print("Radius (km) for " + str(Iso) + " MMI:", d)
ml=float(输入(“输入幅值:”)
h=浮动(输入(“输入深度值:”)
#Iso=浮动(输入(“输入强度MMI值:”)
输入数学
Io=1.5*(ml-math.log(h)+1.4)
对于Iso in[i/10表示范围内的i(5125,5)]:
a=(Io-Iso)/(1.8)
d=(10/8)*(a)
d=d-1

如果在包
json
中使用bult,则可以在Python中加载json对象

import math
import json

# Open JSON file 
f = open('data.geojson',) 

# returns JSON object as  a dictionary 
data = json.load(f) 

for feature in data['features']:
    ml = float(feature['properties']['magnitude'])
    h = float(feature['properties']['depth'])

    Io = 1.5 * (ml - math.log(h) + 1.4)

    for Iso in [i/10 for i in range(5,125,5)]:
        a = (Io - Iso) / (1.8)
        d = (10 / 8) * (a)
        d = d - 1
        if d <= 0:
            print("Distance is zero")
        else:
            d = math.sqrt(h * h + d * d)
            print("Radius (km) for " + str(Iso) + " MMI:", d)
导入数学
导入json
#打开JSON文件
f=open('data.geojson',)
#将JSON对象作为字典返回
data=json.load(f)
对于数据中的要素[“要素”]:
ml=浮点(特征['properties']['magnitude'])
h=浮动(特征['properties']['depth'])
Io=1.5*(ml-math.log(h)+1.4)
对于Iso in[i/10表示范围内的i(5125,5)]:
a=(Io-Iso)/(1.8)
d=(10/8)*(a)
d=d-1
如果d