osm文件,解析,内存错误甚至清除元素。

2024-05-15 11:00:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我想获取一个osm文件,清理它,然后将其保存为json文件。 xml文件大约有1GB大。你知道吗

def audit():
    osm_file = open('c:\Users\Stephan\Downloads\los-angeles_california.osm', "r")
    with open('lala.txt', 'w') as outfile:
        for event, elem in ET.iterparse(osm_file, events=("start",)):   
            if elem.tag == "node" or elem.tag == "way":
                json.dump(shape_element(elem),outfile)
                elem.clear()  
audit()

即使我使用榆树()我仍然有一个内存错误。有人知道为什么吗?你知道吗


Tags: 文件jsondownloadsdefosmtagstephanaudit