簡體   English   中英

使用 Dataflow + Beam + Python 從 Google Cloud Storage 讀取 Shapefile

[英]Read Shapefile from Google Cloud Storage using Dataflow + Beam + Python

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

這是這樣做的方法:

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)

這是包含用於讀取 Shapefile 的自定義 Beam I/O 連接器的 Python 包: https : //github.com/GoogleCloudPlatform/dataflow-geobeam

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM