Skip to main content
deleted 11 characters in body
Source Link
ThomasG77
  • 31.2k
  • 1
  • 55
  • 95

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

 project = QgsProject.instance()         
 manager = project.layoutManager()       
 layout = QgsPrintLayout(project)        
 layoutName = "Strand_012"

 #initializes default settings for blank print layout canvas
 layout.initializeDefaults()  

 layout.setname(layoutName)
 manager.addLayout(layout)

 canvas = iface.mapCanvas()
 map.setExtent(canvas.extent())
 layout.addLayoutItem(map)

I would like to open my map canvas in print layout and export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

 project = QgsProject.instance()         
 manager = project.layoutManager()       
 layout = QgsPrintLayout(project)        
 layoutName = "Strand_012"

 #initializes default settings for blank print layout canvas
 layout.initializeDefaults()  

 layout.setname(layoutName)
 manager.addLayout(layout)

 canvas = iface.mapCanvas()
 map.setExtent(canvas.extent())
 layout.addLayoutItem(map)

I would like to open my map canvas in print layout and export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

project = QgsProject.instance()         
manager = project.layoutManager()       
layout = QgsPrintLayout(project)        
layoutName = "Strand_012"

#initializes default settings for blank print layout canvas
layout.initializeDefaults()  

layout.setname(layoutName)
manager.addLayout(layout)

canvas = iface.mapCanvas()
map.setExtent(canvas.extent())
layout.addLayoutItem(map)

I would like to open my map canvas in print layout and export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here

added 1 character in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

 project = QgsProject.instance()         
 manager = project.layoutManager()       
 layout = QgsPrintLayout(project)        
 layoutName = "Strand_012"

 #initializes default settings for blank print layout canvas
 layout.initializeDefaults()  

 layout.setname(layoutName)
 manager.addLayout(layout)

 canvas = iface.mapCanvas()
 map.setExtent(canvas.extent())
 layout.addLayoutItem(map)

I would like to open my map canvas in print layout adand export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

 project = QgsProject.instance()         
 manager = project.layoutManager()       
 layout = QgsPrintLayout(project)        
 layoutName = "Strand_012"

 #initializes default settings for blank print layout canvas
 layout.initializeDefaults()  

 layout.setname(layoutName)
 manager.addLayout(layout)

 canvas = iface.mapCanvas()
 map.setExtent(canvas.extent())
 layout.addLayoutItem(map)

I would like to open my map canvas in print layout ad export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

 project = QgsProject.instance()         
 manager = project.layoutManager()       
 layout = QgsPrintLayout(project)        
 layoutName = "Strand_012"

 #initializes default settings for blank print layout canvas
 layout.initializeDefaults()  

 layout.setname(layoutName)
 manager.addLayout(layout)

 canvas = iface.mapCanvas()
 map.setExtent(canvas.extent())
 layout.addLayoutItem(map)

I would like to open my map canvas in print layout and export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here

Source Link
Geographos
  • 3.8k
  • 4
  • 37
  • 111

PyQGIS - problem with launching the print layout

I would like to open the QGIS Print layout by using Python.

I found some hints here:

QgsPrintLayout Setup from PyQGIS 3? PyQGIS - Managing print layouts

and here:

https://data.library.virginia.edu/how-to-create-and-export-print-layouts-in-python-for-qgis-3/

but unfortunately everywhere is the same problem. I am getting an error:

IndentationError: unexpected indent

https://stackoverflow.com/questions/3920628/indentationerror-unexpected-indent-error

and I don't really know how to solve it

My simple code looks like this:

 project = QgsProject.instance()         
 manager = project.layoutManager()       
 layout = QgsPrintLayout(project)        
 layoutName = "Strand_012"

 #initializes default settings for blank print layout canvas
 layout.initializeDefaults()  

 layout.setname(layoutName)
 manager.addLayout(layout)

 canvas = iface.mapCanvas()
 map.setExtent(canvas.extent())
 layout.addLayoutItem(map)

I would like to open my map canvas in print layout ad export it as PNG setting 170 Dpi resolution for it. How can I do it?

enter image description here