TileStache / TileStache

A stylish alternative for caching your map tiles.
http://tilestache.org
BSD 3-Clause "New" or "Revised" License
758 stars 290 forks source link

tilestache-server.py with postgis config fails with import error for osgeo #299

Open radumas opened 7 years ago

radumas commented 7 years ago

I'm running Ubuntu 16.04 with PostgreSQL 9.5 and PostGIS 2.2 installed from package archives. I installed pip install -U pillow modestmaps simplejson werkzeug uuid into a virtualenv running Python 2.7.12. I set up a configuration for a PostGIS layer based on the documentation.

When I run ./scripts/tilestache-server.py -c myconf.cfg I get the following error:

Error loading Tilestache config:
Traceback (most recent call last):
  File "./scripts/tilestache-server.py", line 56, in <module>
    app = TileStache.WSGITileServer(config=options.file, autoreload=True)
  File "/home/username/git/tilestache_test/local/lib/python2.7/site-packages/TileStache-1.51.6-py2.7.egg/TileStache/__init__.py", line 374, in __init__
    self.config = parseConfig(config)
  File "/home/username/git/tilestache_test/local/lib/python2.7/site-packages/TileStache-1.51.6-py2.7.egg/TileStache/__init__.py", line 136, in parseConfig
    return Config.buildConfiguration(config_dict, dirpath)
  File "/home/username/git/tilestache_test/local/lib/python2.7/site-packages/TileStache-1.51.6-py2.7.egg/TileStache/Config.py", line 225, in buildConfiguration
    config.layers[name] = _parseConfigLayer(layer_dict, config, dirpath)
  File "/home/username/git/tilestache_test/local/lib/python2.7/site-packages/TileStache-1.51.6-py2.7.egg/TileStache/Config.py", line 455, in _parseConfigLayer
    _class = Providers.getProviderByName(provider_dict['name'])
  File "/home/username/git/tilestache_test/local/lib/python2.7/site-packages/TileStache-1.51.6-py2.7.egg/TileStache/Providers.py", line 130, in getProviderByName
    from . import Vector
  File "/home/username/git/tilestache_test/local/lib/python2.7/site-packages/TileStache-1.51.6-py2.7.egg/TileStache/Vector/__init__.py", line 168, in <module>
    from osgeo import ogr, osr
ImportError: No module named osgeo
jbants commented 7 years ago

You need gdal installed and probably have to change the code to do a try to see if gdal is available through osgeo otherwise load it directly.

You can try this provider for PostGIS as well http://tilestache.org/doc/TileStache.Goodies.VecTiles.html

gabefair commented 6 years ago

I'm having the same issue when I try to load my own layer via shapefile.

"layer_name":
    {
        "provider": {"name": "vector", "driver": "shapefile",
                          "parameters": {"file": "examples/layer_name.shp"}},
        "projection": "spherical mercator"
    },

gives me:

Error loading Tilestache config file: No module named osgeo

I have gdal installed via sudo apt-get build-dep python-gdal

radumas commented 6 years ago

Uh oh. I know I solved this but I don't remember how....

gabefair commented 6 years ago

This ticket can be closed now as #316 added new documentation that suggests installing GDAL to prevent these issues going forward.