我使用python编写的Azure函数来读取来自Blob的shapefile。配置是
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "inputShp",
"type": "blobTrigger",
"direction": "in",
"path": "uploads/shapefile/{name}.shp",
"connection": "StorageConnectionString"
}
]
}
以及__init__.py
脚本
但这是一个错误
Exception: ShapefileException: Shapefile Reader requires a shapefile or file-like object.
我尝试使用reader = shapefile.Reader(io.BytesIO(inputShp.read()))
来代替,这会导致错误
error: unpack requires a buffer of 4 bytes
从一个流读取SeaFipe文件似乎是菲奥娜的内存文件(或者MeMyRyZip文件)让你做的。在
未经测试,但值得一试。在
https://fiona.readthedocs.io/en/latest/fiona.html#fiona.io.MemoryFile
您还可以使用关键字参数从任何类似Python文件的对象加载shapefile来指定这三个文件中的任何一个。这个特性非常强大,允许您从url、zip文件、序列化对象或某些情况下的数据库加载shapefile。在
下面是相同的样品
使用“打开”而不是读。或者试试下面的例子
^{pr2}$这也应该行得通。希望有帮助。在
相关问题 更多 >
编程相关推荐