You need to enable JavaScript to run this app. Python处理174MB GeoJSON时json.loads卡顿遭Manjaro终止进程
优惠活动
大模型
产品
解决方案
定价
更多

Python处理174MB GeoJSON时json.loads卡顿遭Manjaro终止进程

大体积GeoJSON解析被系统强制终止的问题

基础数据说明

  • 待处理数据为FeatureCollection类型GeoJSON,访问地址为:https://opendata.arcgis.com/datasets/a779d051865f461eb2a1f50f10940ec4_161.geojson
  • 数据规模:文件累计包含66153条记录,总大小174MB

异常场景描述

运行环境为Manjaro系统,设备配备12GB运行内存;通过Python环境下的requests库获取对应数据的响应对象后,将对象传入自定义处理函数,在调用json.loads加载数据时,解析流程耗时极长,即便硬件内存满足基础要求,解析进程最终仍会被Manjaro系统强制终止。

现有处理代码

def getJson(document):
    a = json.loads(document.text)    # 解析流程在此处卡住,最终触发系统强制终止进程
    del document
    try:
        p = json.loads('[]')
        for i in a['features']:
            print('Detected GeoJson of type FeatureCollection')
            g = json.loads('{}')
            for key, value in i.items():
                if key == 'properties':
                    for k, v in value.items():
                        g.update({k:v})
                elif key != 'type':
                    try:
                        x = shape(value)
                        g.update({key:x.wkt})
                    except Exception as e:
                        g.update({key:value})
                
                p.append(g)
        return p

内容的提问来源于stack exchange,提问作者Potato

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.17 04:15:04