How to Setup Geojson as Datasource in TileStache

484 views Asked by At

I have successfully installed TileStache in my server. Now I have a geojson file and want to serve it through TileStache. I am new to TileStache and I can't find a clear explanation of how to setup a Geojson in TileStache. Best explanation I can found is here, but it uses a shp file as the datasource.

I want to know how to set it using a Geojson as the datasource.

Edit


I tried adding a tes layer to the config file, so my config file looks like this:

{
  "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": []
                }
        }
  }
}

When I tried to run using tilestache-server.py -c /etc/TileStache/tilestache.cfg, it gives me error like this:

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

I can't figure out what is wrong.

1

There are 1 answers

0
chrki On

ImportError: No module named osgeo

You are missing the GDAL library. It can be quite tricky to install, I got it working on Ubuntu 14.04 by using the PPA ppa:ubuntugis/ubuntugis-unstable, read the instructions in this post over at the GIS Stackexchange.