【问题标题】:Read Shapefile from Google Cloud Storage using Dataflow + Beam + Python使用 Dataflow + Beam + Python 从 Google Cloud Storage 读取 Shapefile
【发布时间】:2018-11-26 10:05:42
【问题描述】:

如何使用 Dataflow + Beam + Python 从 Google Cloud Storage 读取 Shapefile。
我只找到了beam.io.ReadFromText,但 python shapefile 阅读器需要类似文件的对象:shp.Reader(shp=shp_file, dbf=dbf_file) 或 shapefile。
我正在使用 Python 2.7。

【问题讨论】:

    标签: python google-cloud-storage google-cloud-dataflow apache-beam shapefile


    【解决方案1】:

    这是这样做的方法:

    prj_file =  beam.io.gcp.gcsio.GcsIO().open(
        filenamePRJ, 
        mode='r',
        read_buffer_size=1677721600, 
        mime_type='application/octet-stream'
    )
    
    shp_file = beam.io.gcp.gcsio.GcsIO().open(
        filenameSHP, 
        mode='r',
        read_buffer_size=1677721600,
        mime_type='application/octet-stream'
    )
    
    dbf_file =  beam.io.gcp.gcsio.GcsIO().open(
        filenameDBF,
        mode='r',
        read_buffer_size=1677721600,
        mime_type='application/octet-stream'
    )
    
    sf = shp.Reader(shp=shp_file, dbf=dbf_file)      
    euref  = osr.SpatialReference()
    euref.ImportFromWkt(str(prj_file.read()))
    wgs84 = osr.SpatialReference()
    wgs84.ImportFromEPSG(4326)
    transformation = osr.CoordinateTransformation(euref,wgs84)
    

    【讨论】:

      【解决方案2】:

      这里是包含用于读取 Shapefile 的自定义 Beam I/O 连接器的 python 包:https://github.com/GoogleCloudPlatform/dataflow-geobeam

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-09
        • 2020-03-07
        • 1970-01-01
        • 2019-05-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多