1

我已经在我的服务器中成功安装了 TileStache。现在我有一个 geojson 文件,想通过 TileStache 提供它。我是 TileStache 的新手,我找不到关于如何在 TileStache 中设置 Geojson 的清晰解释。我能找到的最佳解释在这里,但它使用 shp 文件作为数据源。

我想知道如何使用 Geojson 作为数据源来设置它。

编辑


我尝试在配置文件中添加一个tes层,所以我的配置文件如下所示:

{
  "cache":
  {
    "name": "Test",
    "path": "/tmp/stache",
    "umask": "0000"
  },
  "layers":
  {
    "osm":
    {
        "provider": {"name": "proxy", "provider": "OPENSTREETMAP"},
        "png options": {"palette": "http://tilestache.org/example-palette-openstreetmap-mapnik.act"}
    },
    "example":
    {
        "provider": {"name": "mapnik", "mapfile": "examples/style.xml"},
        "projection": "spherical mercator"
    },
        "tes":{
                "provider": {
                        "name": "vector", "driver": "GeoJSON",
                        "parameters": {"file": "tes.geojson"},
                        "properties": []
                }
        }
  }
}

当我尝试运行 usingtilestache-server.py -c /etc/TileStache/tilestache.cfg时,它给了我这样的错误:

Error loading Tilestache config:
Traceback (most recent call last):
  File "/usr/local/bin/tilestache-server.py", line 5, in <module>
    pkg_resources.run_script('TileStache==1.50.1', 'tilestache-server.py')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1235, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/EGG-INFO/scripts/tilestache-server.py", line 55, in <module>
    app = TileStache.WSGITileServer(config=options.file, autoreload=True)
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/__init__.py", line 342, in __init__
    self.config = parseConfigfile(config)
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/__init__.py", line 107, in parseConfigfile
    return Config.buildConfiguration(config_dict, dirpath)
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Config.py", line 218, in buildConfiguration
    config.layers[name] = _parseConfigfileLayer(layer_dict, config, dirpath)
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Config.py", line 448, in _parseConfigfileLayer
    _class = Providers.getProviderByName(provider_dict['name'])
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Providers.py", line 122, in getProviderByName
    from . import Vector
  File "/usr/local/lib/python2.7/dist-packages/TileStache-1.50.1-py2.7.egg/TileStache/Vector/__init__.py", line 164, in <module>
    from osgeo import ogr, osr
ImportError: No module named osgeo

我不知道出了什么问题。

4

1 回答 1

1

ImportError:没有名为 osgeo 的模块

您缺少GDAL 库。安装可能非常棘手,我通过使用 PPA 在 Ubuntu 14.04 上运行它,在 GIS Stackexchangeppa:ubuntugis/ubuntugis-unstable阅读这篇文章中的说明。

于 2015-09-18T22:19:57.597 回答