Skip to content

Instantly share code, notes, and snippets.

@drnextgis
Created December 26, 2012 20:34
Show Gist options
  • Save drnextgis/4382927 to your computer and use it in GitHub Desktop.
Save drnextgis/4382927 to your computer and use it in GitHub Desktop.
mapnik.MemoryDatasource
import mapnik
# Массив векторных данных
geometries = [
(0, "POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))"),
(1, "POLYGON((1 5, 4 5, 4 6, 1 6, 1 5))")
]
# Создаём хранилище
ds = mapnik.MemoryDatasource()
# Объект контекста
ctx = mapnik.Context()
# Заполняем хранилище
for id, wkt in geometries:
f = mapnik.Feature(ctx, id)
f.add_geometries_from_wkt(wkt)
ds.add_feature(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment