从geojson

时间:2018-02-12 10:50:45

标签: python python-3.x mapnik

我从postgis生成一个tile。我试图从geojson添加数据。但是当叠加数据时,会发生错误:

Mapnik LOG> 2018-02-12 14:33:14: feature_style_processor: Style=way_style required for layer=way_layer does not exist.

创建了平铺,但没有来自geoj​​son的数据。这是我从GeoJson文件中获取数据的代码:

def _get_graph_way(self):
    s = mapnik.Style()
    r = mapnik.Rule()
    way_line = mapnik.LineSymbolizer()
    way_line.stroke = mapnik.Color('#ffffff')
    way_line.stroke_width = 4
    r.symbols.append(way_line)
    s.rules.append(r)
    self.my_map.append_style('way', s)
    way_layer = mapnik.Layer('way_layer')
    way_layer.styles.append('way_style')
    ds = mapnik.GeoJSON(file="geo.json")
    way_layer.datasource = ds
    self.my_map.layers.append(way_layer)

这是GeoJson文件中的数据示例:

{
    "type": "FeatureCollection",
    "features": [
        {"id": 1,
            "type": "Feature",
            "geometry": {"type": "LineString", "coordinates": [[50.192642, 53.224538], [50.193331, 53.224360]]}, "properties": {"is_exit": true, "is_entry": true, "relations": [2, 3]}}
    ]
}

0 个答案:

没有答案