Cannot render SVG images using python-mapnik.
vipul43 opened this issue · comments
- Below is the code of discussion. (Context: built and installed mapnikv3.1.0, python-mapnikv3.0.x for simple map generation)
img = mapnik.Image(width_pixels, height_pixels)
mapnik.render(m, img)
return img.tostring(image_format), image_format
- The code works fine when generating jpeg, png, tiff and webp images. But during the generation of SVG images below error pop up.
return img.tostring(image_format), image_format
RuntimeError: unknown file type: svg
- I think that there is some kind of plugin needed for svg formats but I have installed cairo for that purpose only, it doesnot solve the problem.
- Suggest a solution either involving any change in my code or installation of new plugins of mapnik.
It's not enough to install Cairo. You both mapnik and python-mapnik must be built with HAVE_CAIRO
.
You can try calling mapnik.has_cairo()
and mapnik.has_pycairo()
to see what they say.