1

I am trying to create a grid and annotate it in degrees, minutes ans seconds but it is not giving the results correctly. Kindly help me in solving this. The out put of map is attached below.

mapSettings = canvas.mapSettings()
c = QgsComposition(mapSettings)
c.setPlotStyle(QgsComposition.Print)
x, y = 10, 10
w, h = c.paperWidth() - 20, c.paperHeight() - 20
mapSettings.setOutputSize(QSize(w, h))
composerMap = QgsComposerMap(c, x, y, w, h)
composerMap.moveContent(0, 0)
composerMap.setPreviewMode(1)
composerMap.grid().setStyle(3)
composerMap.grid().setFrameStyle(3)
composerMap.grid().setAnnotationFormat(7)
composerMap.grid().setIntervalX(100)
composerMap.grid().setIntervalY(100)
composerMap.setShowGridAnnotation(True)
composerMap.grid().setAnnotationPrecision(0)
composerMap.grid().setAnnotationDirection(1, 0)
composerMap.grid().setAnnotationDirection(1, 1)
composerMap.grid().setEnabled(True)
composerMap.setFrameEnabled(True)
c.addItem(composerMap)

Reference image

  • what projection is your image in? – Ian Turton Jun 12 '17 at 9:48
  • WGS 1984 UTM Zone 43N – Krishna Jun 12 '17 at 10:23
  • That projection uses meters, not degrees. Try setting your project to WGS84 (EPSG 4326) with on-the-fly transformation turned on. – csk Jun 21 '17 at 17:57

Your Answer

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

Browse other questions tagged or ask your own question.