我正在尝试使用Palantir函数shapefile_to_dataframe(),以便在以后的地理定位功能中使用shapefiles。
我在一个数据集中手动导入了shapefile (.shp、.shx和.dbf) (通过文件系统API没有访问问题)。
根据文档,我已经导入了地理空间工具和GEOSPARK概要文件+在transforms build.gradle中包含了依赖项。
下面是我的转换代码,它主要是从文档中提取的:
from transforms.api import transform, Input, Output, configure
from geospatial_tools import geospatial
from geospatial_tools.parsers import shapefile_to_dataframe
@geospatial()
@transform(
raw = Input("ri.foundry.main.dataset.0d984138-23da-4bcf-ad86-39686a14ef21"),
output = Output("/Indhu/InDhu/Vincent/geo_energy/datasets/extract_coord/raw_df")
)
def compute(raw, output):
return output.write_dataframe(shapefile_to_dataframe(raw))然后,代码帮助加载变得非常慢,然后我终于得到了以下错误:
AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)
Traceback (most recent call last):
File "/myproject/datasets/shp_to_df.py", line 3, in <module>
from geospatial_tools.parsers import shapefile_to_dataframe
File "/scratch/standalone/3a553998-623b-48f5-9c3f-03de7e64f328/code-assist/contents/transforms-python/build/conda/env/lib/python3.8/site-packages/geospatial_tools/parsers.py", line 11, in <module>
from fiona.drvsupport import supported_drivers
File "/scratch/standalone/3a553998-623b-48f5-9c3f-03de7e64f328/code-assist/contents/transforms-python/build/conda/env/lib/python3.8/site-packages/fiona/__init__.py", line 85, in <module>
with fiona._loading.add_gdal_dll_directories():
AttributeError: partially initialized module 'fiona' has no attribute '_loading' (most likely due to a circular import)非常感谢你的帮助,文森特
发布于 2022-09-29 10:40:09
我能够重现这个错误,而且它似乎只发生在预览-运行完整的构建似乎很好。绕过它的最简单的方法是在函数中移动导入:
from transforms.api import transform, Input, Output, configure
from geospatial_tools import geospatial
@geospatial()
@transform(
raw = Input("ri.foundry.main.dataset.0d984138-23da-4bcf-ad86-39686a14ef21"),
output = Output("/Indhu/InDhu/Vincent/geo_energy/datasets/extract_coord/raw_df")
)
def compute(raw, output):
from geospatial_tools.parsers import shapefile_to_dataframe
return output.write_dataframe(shapefile_to_dataframe(raw))然而,目前,函数shapefile_to_dataframe仍然无法在预览中工作,因为完整的transforms.api.FileSystem API没有实现--具体来说,函数ls没有实现参数glob,这是完全转换的API所做的。
https://stackoverflow.com/questions/73870305
复制相似问题