creating png images using qgis3 pygisInterpolation plugin from PyGIS?“unexpected indent” in the...

name character vectors with same name of list

How do you funnel food off a cutting board?

What is the wife of a henpecked husband called?

Is it safe to try charging my laptop with a USB-C PD charger that has less wattage than recommended?

Eww, those bytes are gross

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

page split between longtable caption and table

Could flying insects re-enter the Earth's atmosphere from space without burning up?

Getting a UK passport renewed when you have dual nationality and a different name in your second country?

How can I deal with a significant flaw I found in my previous supervisor’s paper?

How can I improve my fireworks photography?

Can you earn endless XP using a Flameskull and its self-revival feature?

Closed form for these polynomials?

Strange Sign on Lab Door

What is a good way to foreshadow that magic is actually very advanced technology?

How should I handle players who ignore the session zero agreement?

How to generate a matrix with certain conditions

Why did the villain in the first Men in Black movie care about Earth's Cockroaches?

Number of FLOP (Floating Point Operations) for exponentiation

Every character has a name - does this lead to too many named characters?

Does my logo design convey the right feelings for a University Student's Council?

Program that converts a number to a letter of the alphabet

What to do if authors don't respond to my serious concerns about their paper?

Can a person refuse a presidential pardon?



creating png images using qgis3 pygis


Interpolation plugin from PyGIS?“unexpected indent” in the scriptqgis python + layout/template + exporting in .png + filtering layersIs QgsMapLayerRegistry removed in QGIS3?No module named 'processing.core.AlgorithmProvider' in QGIS3Add layer to map in qgis3 via a python scriptRunning Processing Script crashes QGIS3QgsProcessingException in Processing script QGIS3QGIS3 Python Export PNG after layout resizeQGIS3 in custom application via PyQGIS (Linux)













0















some days ago i upgraded from qgis 2.18 to 3.6.0 - not knowing that many python scripts won't run without modifications :(



i could convert all of them but not this one:



from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtGui
import processing, sys, time, psycopg2
import pprint

...
creatin layers skipped (got this running)
...

################### Create Graph #####################

mapRenderer = iface.mapCanvas().mapRenderer()

layers = [missingLayer.id(),clipLayer.id()]
mapRenderer.setLayerSet(layers)

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

c.setPaperSize(148,90)
c.setPrintResolution(300)

# add map
x, y = 0, 0
w, h = c.paperWidth(), c.paperHeight()
composerMap = QgsComposerMap(c, x,y,w,h)
c.addItem(composerMap)

#output to image
dpi = c.printResolution()
dpmm = dpi / 25.4
width = int(dpmm * c.paperWidth())
height = int(dpmm * c.paperHeight())

BackgroundColor = QColor(0,0,255)

# create output image and initialize it
image = QImage(QSize(width, height), QImage.Format_ARGB32)
image.setDotsPerMeterX(dpmm * 1000)
image.setDotsPerMeterY(dpmm * 1000)
image.fill(BackgroundColor)

header = QgsComposerLabel(c)
header.setItemPosition(40,1)
header.setBackgroundEnabled(0)
newFont = QFont("Comic Sans MS", 18)
header.setFont(newFont)
header.setText("Missing Countries Map")
header.adjustSizeToText()
c.addItem(header)

header2 = QgsComposerLabel(c)
header2.setItemPosition(50,11)
header2.setBackgroundEnabled(0)
newFont2 = QFont("Comic Sans MS", 10)
header2.setFont(newFont2)
header2.setText("TS="+ts)
header2.adjustSizeToText()
c.addItem(header2)

footer = QgsComposerLabel(c)
footer.setItemPosition(124,87.5)
footer.setBackgroundEnabled(0)
newFont3 = QFont("Times Roman", 4)
footer.setFont(newFont3)
footer.setText(time.ctime())
footer.adjustSizeToText()
c.addItem(footer)

legend = QgsComposerLegend(c)
legend.model().setLayerSet(mapRenderer.layerSet())
legend.setItemPosition(5,65)
legend.setFrameEnabled(1)
newFont = QFont("Comic Sans MS", 6)
legend.setStyleFont(QgsComposerLegendStyle.Title, newFont)
legend.setStyleFont(QgsComposerLegendStyle.Subgroup, newFont)
legend.setStyleFont(QgsComposerLegendStyle.SymbolLabel, newFont)
legend.setStyleMargin(QgsComposerLegendStyle.Title,2)
legend.setTitle("Legend")
legend.setSymbolHeight(2)
legend.adjustBoxSize()
c.addItem(legend)

# render the composition
imagePainter = QPainter(image)
imagePainter.setRenderHint(QPainter.Antialiasing)
sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight())
targetArea = QRectF(0, 0, width, height)
c.render(imagePainter, targetArea, sourceArea)
imagePainter.end()
imageFile = "missing_boundaries"+ts+".png"
print "saving to "+imageFile
image.save(imageFile)



yes, i do know the QqsComposer has gone but i can't find any documentation or example for QGIS3 plotting. Exept the API description of course.
:(



any hints how to start will help. don't need the whole script converted by you, only the first few lines should be enought.










share|improve this question



























    0















    some days ago i upgraded from qgis 2.18 to 3.6.0 - not knowing that many python scripts won't run without modifications :(



    i could convert all of them but not this one:



    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from PyQt4 import QtGui
    import processing, sys, time, psycopg2
    import pprint

    ...
    creatin layers skipped (got this running)
    ...

    ################### Create Graph #####################

    mapRenderer = iface.mapCanvas().mapRenderer()

    layers = [missingLayer.id(),clipLayer.id()]
    mapRenderer.setLayerSet(layers)

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

    c.setPaperSize(148,90)
    c.setPrintResolution(300)

    # add map
    x, y = 0, 0
    w, h = c.paperWidth(), c.paperHeight()
    composerMap = QgsComposerMap(c, x,y,w,h)
    c.addItem(composerMap)

    #output to image
    dpi = c.printResolution()
    dpmm = dpi / 25.4
    width = int(dpmm * c.paperWidth())
    height = int(dpmm * c.paperHeight())

    BackgroundColor = QColor(0,0,255)

    # create output image and initialize it
    image = QImage(QSize(width, height), QImage.Format_ARGB32)
    image.setDotsPerMeterX(dpmm * 1000)
    image.setDotsPerMeterY(dpmm * 1000)
    image.fill(BackgroundColor)

    header = QgsComposerLabel(c)
    header.setItemPosition(40,1)
    header.setBackgroundEnabled(0)
    newFont = QFont("Comic Sans MS", 18)
    header.setFont(newFont)
    header.setText("Missing Countries Map")
    header.adjustSizeToText()
    c.addItem(header)

    header2 = QgsComposerLabel(c)
    header2.setItemPosition(50,11)
    header2.setBackgroundEnabled(0)
    newFont2 = QFont("Comic Sans MS", 10)
    header2.setFont(newFont2)
    header2.setText("TS="+ts)
    header2.adjustSizeToText()
    c.addItem(header2)

    footer = QgsComposerLabel(c)
    footer.setItemPosition(124,87.5)
    footer.setBackgroundEnabled(0)
    newFont3 = QFont("Times Roman", 4)
    footer.setFont(newFont3)
    footer.setText(time.ctime())
    footer.adjustSizeToText()
    c.addItem(footer)

    legend = QgsComposerLegend(c)
    legend.model().setLayerSet(mapRenderer.layerSet())
    legend.setItemPosition(5,65)
    legend.setFrameEnabled(1)
    newFont = QFont("Comic Sans MS", 6)
    legend.setStyleFont(QgsComposerLegendStyle.Title, newFont)
    legend.setStyleFont(QgsComposerLegendStyle.Subgroup, newFont)
    legend.setStyleFont(QgsComposerLegendStyle.SymbolLabel, newFont)
    legend.setStyleMargin(QgsComposerLegendStyle.Title,2)
    legend.setTitle("Legend")
    legend.setSymbolHeight(2)
    legend.adjustBoxSize()
    c.addItem(legend)

    # render the composition
    imagePainter = QPainter(image)
    imagePainter.setRenderHint(QPainter.Antialiasing)
    sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight())
    targetArea = QRectF(0, 0, width, height)
    c.render(imagePainter, targetArea, sourceArea)
    imagePainter.end()
    imageFile = "missing_boundaries"+ts+".png"
    print "saving to "+imageFile
    image.save(imageFile)



    yes, i do know the QqsComposer has gone but i can't find any documentation or example for QGIS3 plotting. Exept the API description of course.
    :(



    any hints how to start will help. don't need the whole script converted by you, only the first few lines should be enought.










    share|improve this question

























      0












      0








      0








      some days ago i upgraded from qgis 2.18 to 3.6.0 - not knowing that many python scripts won't run without modifications :(



      i could convert all of them but not this one:



      from PyQt4.QtCore import *
      from PyQt4.QtGui import *
      from PyQt4 import QtGui
      import processing, sys, time, psycopg2
      import pprint

      ...
      creatin layers skipped (got this running)
      ...

      ################### Create Graph #####################

      mapRenderer = iface.mapCanvas().mapRenderer()

      layers = [missingLayer.id(),clipLayer.id()]
      mapRenderer.setLayerSet(layers)

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

      c.setPaperSize(148,90)
      c.setPrintResolution(300)

      # add map
      x, y = 0, 0
      w, h = c.paperWidth(), c.paperHeight()
      composerMap = QgsComposerMap(c, x,y,w,h)
      c.addItem(composerMap)

      #output to image
      dpi = c.printResolution()
      dpmm = dpi / 25.4
      width = int(dpmm * c.paperWidth())
      height = int(dpmm * c.paperHeight())

      BackgroundColor = QColor(0,0,255)

      # create output image and initialize it
      image = QImage(QSize(width, height), QImage.Format_ARGB32)
      image.setDotsPerMeterX(dpmm * 1000)
      image.setDotsPerMeterY(dpmm * 1000)
      image.fill(BackgroundColor)

      header = QgsComposerLabel(c)
      header.setItemPosition(40,1)
      header.setBackgroundEnabled(0)
      newFont = QFont("Comic Sans MS", 18)
      header.setFont(newFont)
      header.setText("Missing Countries Map")
      header.adjustSizeToText()
      c.addItem(header)

      header2 = QgsComposerLabel(c)
      header2.setItemPosition(50,11)
      header2.setBackgroundEnabled(0)
      newFont2 = QFont("Comic Sans MS", 10)
      header2.setFont(newFont2)
      header2.setText("TS="+ts)
      header2.adjustSizeToText()
      c.addItem(header2)

      footer = QgsComposerLabel(c)
      footer.setItemPosition(124,87.5)
      footer.setBackgroundEnabled(0)
      newFont3 = QFont("Times Roman", 4)
      footer.setFont(newFont3)
      footer.setText(time.ctime())
      footer.adjustSizeToText()
      c.addItem(footer)

      legend = QgsComposerLegend(c)
      legend.model().setLayerSet(mapRenderer.layerSet())
      legend.setItemPosition(5,65)
      legend.setFrameEnabled(1)
      newFont = QFont("Comic Sans MS", 6)
      legend.setStyleFont(QgsComposerLegendStyle.Title, newFont)
      legend.setStyleFont(QgsComposerLegendStyle.Subgroup, newFont)
      legend.setStyleFont(QgsComposerLegendStyle.SymbolLabel, newFont)
      legend.setStyleMargin(QgsComposerLegendStyle.Title,2)
      legend.setTitle("Legend")
      legend.setSymbolHeight(2)
      legend.adjustBoxSize()
      c.addItem(legend)

      # render the composition
      imagePainter = QPainter(image)
      imagePainter.setRenderHint(QPainter.Antialiasing)
      sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight())
      targetArea = QRectF(0, 0, width, height)
      c.render(imagePainter, targetArea, sourceArea)
      imagePainter.end()
      imageFile = "missing_boundaries"+ts+".png"
      print "saving to "+imageFile
      image.save(imageFile)



      yes, i do know the QqsComposer has gone but i can't find any documentation or example for QGIS3 plotting. Exept the API description of course.
      :(



      any hints how to start will help. don't need the whole script converted by you, only the first few lines should be enought.










      share|improve this question














      some days ago i upgraded from qgis 2.18 to 3.6.0 - not knowing that many python scripts won't run without modifications :(



      i could convert all of them but not this one:



      from PyQt4.QtCore import *
      from PyQt4.QtGui import *
      from PyQt4 import QtGui
      import processing, sys, time, psycopg2
      import pprint

      ...
      creatin layers skipped (got this running)
      ...

      ################### Create Graph #####################

      mapRenderer = iface.mapCanvas().mapRenderer()

      layers = [missingLayer.id(),clipLayer.id()]
      mapRenderer.setLayerSet(layers)

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

      c.setPaperSize(148,90)
      c.setPrintResolution(300)

      # add map
      x, y = 0, 0
      w, h = c.paperWidth(), c.paperHeight()
      composerMap = QgsComposerMap(c, x,y,w,h)
      c.addItem(composerMap)

      #output to image
      dpi = c.printResolution()
      dpmm = dpi / 25.4
      width = int(dpmm * c.paperWidth())
      height = int(dpmm * c.paperHeight())

      BackgroundColor = QColor(0,0,255)

      # create output image and initialize it
      image = QImage(QSize(width, height), QImage.Format_ARGB32)
      image.setDotsPerMeterX(dpmm * 1000)
      image.setDotsPerMeterY(dpmm * 1000)
      image.fill(BackgroundColor)

      header = QgsComposerLabel(c)
      header.setItemPosition(40,1)
      header.setBackgroundEnabled(0)
      newFont = QFont("Comic Sans MS", 18)
      header.setFont(newFont)
      header.setText("Missing Countries Map")
      header.adjustSizeToText()
      c.addItem(header)

      header2 = QgsComposerLabel(c)
      header2.setItemPosition(50,11)
      header2.setBackgroundEnabled(0)
      newFont2 = QFont("Comic Sans MS", 10)
      header2.setFont(newFont2)
      header2.setText("TS="+ts)
      header2.adjustSizeToText()
      c.addItem(header2)

      footer = QgsComposerLabel(c)
      footer.setItemPosition(124,87.5)
      footer.setBackgroundEnabled(0)
      newFont3 = QFont("Times Roman", 4)
      footer.setFont(newFont3)
      footer.setText(time.ctime())
      footer.adjustSizeToText()
      c.addItem(footer)

      legend = QgsComposerLegend(c)
      legend.model().setLayerSet(mapRenderer.layerSet())
      legend.setItemPosition(5,65)
      legend.setFrameEnabled(1)
      newFont = QFont("Comic Sans MS", 6)
      legend.setStyleFont(QgsComposerLegendStyle.Title, newFont)
      legend.setStyleFont(QgsComposerLegendStyle.Subgroup, newFont)
      legend.setStyleFont(QgsComposerLegendStyle.SymbolLabel, newFont)
      legend.setStyleMargin(QgsComposerLegendStyle.Title,2)
      legend.setTitle("Legend")
      legend.setSymbolHeight(2)
      legend.adjustBoxSize()
      c.addItem(legend)

      # render the composition
      imagePainter = QPainter(image)
      imagePainter.setRenderHint(QPainter.Antialiasing)
      sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight())
      targetArea = QRectF(0, 0, width, height)
      c.render(imagePainter, targetArea, sourceArea)
      imagePainter.end()
      imageFile = "missing_boundaries"+ts+".png"
      print "saving to "+imageFile
      image.save(imageFile)



      yes, i do know the QqsComposer has gone but i can't find any documentation or example for QGIS3 plotting. Exept the API description of course.
      :(



      any hints how to start will help. don't need the whole script converted by you, only the first few lines should be enought.







      pyqgis qgis-3 plot






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 11 mins ago









      wambacherwambacher

      317




      317






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314170%2fcreating-png-images-using-qgis3-pygis%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f314170%2fcreating-png-images-using-qgis3-pygis%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          (145452) 2005 RN43 Классификация | Примечания | Ссылки |...

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Энтрерриос (город) Содержание История | Географическое...