2

I am using pyqgis to create map automatically. However I encounter a problem when I want to set the grid annotation direction to 'Vertical Descending'. The command I use is the following:

composerMap.setGridAnnotationPosition(QgsComposerMap.OutsideMapFrame, \
                                                  QgsComposerMap.Top)

composerMap.setGridAnnotationDirection(QgsComposerMap.VerticalDescending, \
                                               QgsComposerMap.Top)

However, I get the following attribute error:

QgsComposerMap has no attributes VerticalDescending

After looking online, I found that this method is deprecated (https://qgis.org/api/deprecated.html) and that I should use grid() or grids() instead. When I look at qgscomposermapgrid.h source code (https://qgis.org/api/qgscomposermapgrid_8h_source.html#l00211) I see that there is an attribute 'VerticalDescending' (line 215) but I cannot find any example on how to use this method.

Any help?

0

Try out:

composerMap.setGridAnnotationPosition(QgsComposerMapGrid.OutsideMapFrame, \
                                      QgsComposerMapGrid.Top)

composerMap.setGridAnnotationDirection(QgsComposerMapGrid.VerticalDescending, \
                                       QgsComposerMapGrid.Top)

Now, these constants ('OutsideMapFrame', 'VerticalDescending', 'Top') are all in QgsComposerMapGrid class; not in QgsComposerMap class.

I corroborated that with my 'Get Pattern' plugin:

enter image description here

and at the Python Console:

>>>QgsComposerMapGrid.OutsideMapFrame
1
>>>QgsComposerMapGrid.Top
3
>>>QgsComposerMapGrid.VerticalDescending
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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