3

I am using Map Composition, but I found in QGIS 2.14 (Essen) Text Editor that when I try to import MapComposerit returns that this module is not found.

This is the error :

File "C:/PROGRA~1/QGISES~1/apps/qgis/./python\qgis\utils.py", line 572, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named MapComposer

When I writhe in the console:

help(MapComposer)

The module is not found

2
  • 1
    Perhaps the QGIS API docs might help. If you're looking to add a composer map, you may need to use from qgis.core import QgsComposerMap.
    – Joseph
    Commented Apr 19, 2016 at 15:35
  • The fact is that I am following "QGIS Python Proramming Cookbook", thus, I try to follow all the steps... now, trying to create a Map Composition. I look at this modude but, I saw this class, then, can I use: qc = MapComposer.MapComposer(qmlr=reg, qmr=mr) ? Or shall I write QgsComposerMap instead of MapComposer?
    – user64823
    Commented Apr 19, 2016 at 15:45

1 Answer 1

1

Not sure about the examples in the "QGIS Python Programming Cookbook" but in the PyQGIS Developer Cookbook, we have the following example

mapRenderer = iface.mapCanvas().mapRenderer()
c = QgsComposition(mapRenderer)
c.setPlotStyle(QgsComposition.Print)

x, y = 0, 0
w, h = c.paperWidth(), c.paperHeight()
composerMap = QgsComposerMap(c, x ,y, w, h)
c.addItem(composerMap)
1
  • Thank you, I am checking this now, it works at the moment ;) Then, we use QgsComposerMap to set the dimensions of our paper project? And from here we can establish all the elements of the map, such as scalebar, north arrow, text boxes, and so on?
    – user64823
    Commented Apr 20, 2016 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.