【问题标题】:Mapnik Shapefile datasource runtime errorMapnik Shapefile 数据源运行时错误
【发布时间】:2013-12-19 10:07:14
【问题描述】:

我是 manpnik 的新手,面临类似的问题。每次我尝试从 python 地理空间开发手册编译示例代码时,mapnik 都会抛出运行时错误消息。 这就是问题的根源。

datasource = mapnik.Shapefile(file="world_borders.shp")
polygonLayer = mapnik.Layer("Polygons")
polygonLayer.datasource = datasource
polygonLayer.styles.append("polygonStyle")

error message
Traceback (most recent call last):
  File "createExampleMap.py", line 45, in <module>
    datasource = mapnik.Shapefile(file="world_borders.shp")
  File "C:\Python27\lib\site-packages\mapnik\__init__.py", line 341, in Shapefile
    return CreateDatasource(keywords)
RuntimeError: Could not create datasource for type: 'shape'


I'd appreciate help from anyone thanks

【问题讨论】:

    标签: runtime-error datasource shapefile mapnik


    【解决方案1】:

    我也收到此错误消息。对我来说,这是由于我将 /site-packages/mapnik 目录移出 Mapnik 树所致。

    假设您使用的是 Windows,您可能需要检查您的路径是否正常:

    1. 在您的 demo/python 文件夹中启动命令提示符并键入 PATH
      检查您的 lib 文件夹是否在路径中

    2. 从同一个目录启动 python 并说

      from mapnik import paths
      paths.mapniklibpath
      

      这应该输出你的 lib 文件夹,例如'c:\\mapnik-v2.2.0\\lib'

    我将 Mapnik 的 site-packages 放在我的 Python 的 Lib 目录中,这搞砸了 mapnik.paths

    【讨论】:

    • 在 windows 上遇到同样的问题,检查和更改 mapniklibpath 为我解决了它。
    猜你喜欢
    • 2018-01-04
    • 2018-11-29
    • 2015-02-13
    • 2014-09-09
    • 2011-05-05
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    • 2011-11-10
    相关资源
    最近更新 更多