kartograph / kartograph.py

UNMAINTAINED! Renders beautiful SVG maps in Python.
http://kartograph.org/docs/kartograph.py
1k stars 194 forks source link

Can't generate map with "special" layer #107

Open dikmax opened 10 years ago

dikmax commented 10 years ago

When I add to config some special layer (sea or graticule), map fails to generate with error:

Traceback (most recent call last):
  File "visited-countries/map/makeMap.py", line 22, in <module>
    K.generate(config, outfile='world.svg')
  File "/usr/local/lib/python2.7/dist-packages/kartograph/kartograph.py", line 46, in generate
    _map = Map(opts, self.layerCache, format=format)
  File "/usr/local/lib/python2.7/dist-packages/kartograph/map.py", line 48, in __init__
    me.proj = me._init_projection()
  File "/usr/local/lib/python2.7/dist-packages/kartograph/map.py", line 88, in _init_projection
    map_center = self.__get_map_center()
  File "/usr/local/lib/python2.7/dist-packages/kartograph/map.py", line 140, in __get_map_center
    features = self._get_bounding_geometry()
  File "/usr/local/lib/python2.7/dist-packages/kartograph/map.py", line 257, in _get_bounding_geometry
    charset=layer.options['charset']
TypeError: get_features() got an unexpected keyword argument 'filter'

I tried first with console util, then with python script. All the same.

from kartograph import Kartograph
K = Kartograph()

config = {
    "layers": {
        "background": {
            "special": "sea",
            "charset": "utf8"
        },
        "countries": {
           "src": "ne_50m_admin_0_countries_lakes.shp",
            "attributes": {
                "code": "su_a3"
            }
        }
    },
    "proj": {
        "id": "winkel3"
    }
}

K.generate(config, outfile='world.svg')

Any ideas how to fix it?

josemiotto commented 10 years ago

I had the same error, it is solved by adding a bounds parameter.

zimmicz commented 9 years ago

@josemiotto could you please send an example? I tried with

{
    "layers": {
        "background": {
            "special": "sea"
        },
        "countries": {
            "src": "ne_50m_admin_0_countries.shp"
        },
        "mygraticule": {
            "special": "graticule",
            "latitudes": 10,
            "longitudes": 10
        }
    },
    "bounds": {
        "mode": "bbox",
        "data": [-180, -90, 180, 90]
    }
}

but that does not seem to work.