I'm trying to save the map canvas as an image in Python in QGIS. I've looked in a few places but haven't been able to get something to work. I need a function where I can specify the extent of the map and the image size. Very similar to the "snapshot" command line function that can be used with QGIS. But the problem with the snapshot function is that it has to start QGIS each time and then close it.
I wrote a script to create a big number of heat maps for a given scenario. I would like to save the result of every heat map as an PNG image. I have figured it out doing it with simple Map Rendering but the quality of the result is too low. Furthermore I would like to export to OpenLayers using the same code, which does not seem to be possible with simple rendering.   Now I am trying to do it with QgsComposition instead. Manually in the Map Composer you can just set the paper color to transparent and disable the background of the map canvas.   This is the code that I have so far. I just cannot figure out why it is not working. The result png-file always has a white opaque background.   My OS is Windows 7 and I'm using QGIS 2.6 Brighton.  I hope someone can help me out here.  # PARAMETERS mainPath = 'path/to/folder/' filename = 'filename' imageType = "png" imageWidth_mm = 400 imageHeight_mm = 160 dpi = 300  mapRenderer = iface.mapCanvas().mapRenderer()  c = QgsComposition(mapRenderer) c.setPlotStyle(QgsComposition.Print)  c.setPaperSize(400, 160)  x, y = 0, 0 w, h = c.paperWidth(), c.paperHeight() composerMap = QgsComposerMap(c, x ,y, w, h) c.addItem(composerMap)  # get all items and disable the backgrounds itemList = c.items() c.removeItem(itemList[2]) c.removeItem(itemList[2]) itemList[2].setBackgroundEnabled(False) itemList[3].setBackgroundEnabled(False) # add them to the composition c.addItem(itemList[2]) c.addItem(itemList[3])  c.refreshItems() c.refreshDataDefinedProperty(QgsComposerObject.AllProperties)  c.setPrintResolution(dpi) dpmm = dpi / 25.4 width = int(dpmm * c.paperWidth()) height = int(dpmm * c.paperHeight())  # create output image and initialize it # image = QImage(QSize(width, height), QImage.Format_ARGB32) image = QImage(QSize(width, height), QImage.Format_ARGB32_Premultiplied) image.setDotsPerMeterX(dpmm * 1000) image.setDotsPerMeterY(dpmm * 1000) #image.fill(0)  imagePainter = QPainter(image)  # This part does not seem to have any effect #brush = QBrush(Qt.BrushStyle(0)) # transparent brush # #imagePainter.setBackgroundMode(0) #c.setBackgroundBrush(brush)  c.renderPage( imagePainter, 0 ) imagePainter.end()   imageFilename =  mainPath + filename + '.' + imageType image.save(imageFilename, imageType) print 'image saved' print 'done'
If an opponent casts  to gain control of  then sacrifices it who will draw the card? How do I remove gapps from CyanogenMod I installed CyanogenMod 11 on my HTC One with CyanogenMod Installer. So I got also the google Apps (gapps) on my device. But I need a CM11 without gapps. I did then the following without success:   copy cm-11-20140308-SNAPSHOT-M4-m7.zip to /sdcard/ boot to recovery mode -> recovery -> ClockworkMod Recovery v6.0.4.6: "wipe data/factory reset" "install zip" choosing the zip-file "reboot system now"  So I got a new CM11 but with gapps still installed.  What should I do in addition to "wipe data/factory reset" to get rid of this apps? Can I use Mage Hand to fly by Polymorphing myself and picking myself up with the hand? Could I first cast Mage Hand, then Polymorph into a Tiny creature less than 10 pounds then use the Mage Hand to pick myself up and fly at 30 Ft per turn?  Polymorph says:     The new form can be any beast ... The target's game statistics,   including mental ability scores, are replaced by the statistics of the   chosen beast. It retains its alignment and personality ... The   creature is limited in the actions it can perform by the nature of its   new form and it can't speak, cast spells, or take any other action   that requires hands or speech.   This keeps me from casting spells, which keeps me from just casting Mage Hand to fly as long as I want to over and over. But for that initial duration of the Mage Hand cantrip, could I use the Mage Hand to fly as a Tiny polymorphed creature until the spell runs out? Word to describe someone who goes to all the events in town! I'm looking for a short word that could describe people who are always going to every event in town. It doesn't need to be an existing word, feel free to create one of your own. It can also be made of words related to events and parties. (ex: club, event, guest list, etc.)  Edit  The word will serve as a new term to describ these people in a favorable way. It will probably be used for an app name so it need to be catchy and fun. ( Preferably ) Pay real money to set bounties (another method, not replacing rep method) It may seem like a stupid thing, but could we please be able to pay real money to set a bounty.  For example, if I had only 1 rep, I want to be able have a bounty.   Here late the suggested prices in USD. Convert money    $0.49 for each 50 reputation $0.99 for each week $1.99 for a month $9.99 for a year   Every month, the bounty fee would come in. This would mean you would have to enable your account with a bounty fee button on your profile. every eigenvalue of $T$ has only one corresponding eigenvector up to a scalar multiplication For a linear transformation $T$ on a vector space $V$ of dimension $n .$ Suppose it is given that for some vector $\mathbf{v},$ the vectors $\mathbf{v}, T(\mathbf{v}), T^{2}(\mathbf{v}), \ldots, T^{n-1}(\mathbf{v})$ are linearly independent, then is it true that every eigenvalue of $T$ has only one corresponding eigenvector up to a scalar multiplication. Turning a cipher into a hashing function Well, you can see it for yourself. The badge multiplier is a bit misaligned. Can you fix this please? (I know it's kinda a minor issue but it's bugging me and it's somehow off)    If it helps, I'm using Chrome version 44.0.2403.125 m. (Also repro'ed on FireFox 39.0 and )    For no good reason, that's a screenie from 's profile page. I can't seem to find a few of the Stones, so, is there a list available with the location of all the stones? I had a tin of golden syrup for a long time - longer than I care to admit. When I opened it up yesterday (to sweeten up some mulled wine), it was granular (a bit like honey can be), and black around the edges.   Is this 'bad', or just different?   Is the blackness the result of some chemical reaction with the tin?  And in general, does it eventually go off, or does it last indefinitely? Can't open a folder in windows 7 64bit, by double clicking, it shows me that the default option for opening folder is "cmd" (it's highlighted when i'm right clicking a folder, and the "open" option comes next). I've tried running some registry fixing tools, but it didn't fix it. Can someone suggest me what should I do. I have the following sequences $(a_n)$, $(b_n)=(a_{2n})$, and $(c_n) = (a_{2n-1})$.  I have to show that:   if $(b_n)$ and $(c_n)$ both convergence to $a$, then $(a_n)$ also converges to $a$; if $(a_n)$ converges then $(b_n)$ and $(c_n)$ also converge; there exist $(a_n)$ not converging but with $(b_n)$ and $(c_n)$ converging.   I am not sure how to solve this since I only know that $(b_n)$ > $(c_n)$ > $(a_n)$ on the terms how the sequences are defined. What is the maximum height a settlement can reach in Fallout 4? See title. Obviously the maximum base is determined by the perimeter, but the maximum height is not specified. If $x_1,x_2,\ldots,x_n$ are real numbers larger than $1$, prove that $$\dfrac{1}{1+x_1}+\dfrac{1}{1+x_2}+\cdots+\dfrac{1}{1+x_n} \geq \dfrac{n}{\sqrt[n]{x_1x_2\cdots x_n}+1}$$   Attempt  AM-GM doesn't work here since we will get an upper bound. I don't see Cauchy-Schwarz working either. Thus, I think a substitution might work, but I am unsure of which one to use. Would raising the review limit help with the Close Votes queue? I mean a average human can run at his full speed for 15 to 20 mins before getting tired. Trained athletes can go on running for much more time without tiring out.  Do Superheroes like Quicksilver or Flash ever get tired due to excessive running? How to emulate titletoc with tocloft I was using titletoc until I realized that it has some incompatibilities with hyperref. The thing is, that titletoc can do the same thing in a easier way, less one.  \titlecontents*{subsection}[5.4em] {\small} {\thecontentslabel~ } {} {} [.~\textbullet\ ] [.]   this part does the subsection as a paragraph (with section number and without page number). I have realized that the problem is the pseudo-code used by tocloft for the entries in the TOC  {\cftXfont {\cftXpresnum SNUM\cftXaftersnum\hfil} \cftXaftersnumb TITLE}% {\cftXleader}{\cftXpagefont PAGE}\cftXafterpnum\par   I mean, the last command \par make impossible to leave two subsection entries in the same textline. Any idea? Another interesting solution is with etoolbox, some examples with that package are awesome, but it's not on my hands.  This is a MWE:  \documentclass{book}  \usepackage{titletoc} \titlecontents*{subsection}[5.4em]{\small} {\thecontentslabel~ }{}{}[.~\textbullet\ ][.]  \begin{document}  \tableofcontents  \chapter{Test Chapter 1} \section{Test Section 1.1} \subsection{First Test Subsection} \subsection{Second Test Subsection} \subsection{Third Test Subsection} \subsection{Fourth Test Subsection} \section{Test Section 1.2} \subsection{First Test Subsection} \subsection{Second Test Subsection}  \chapter{Test Chapter 2} \section{Test Section 2.1} \subsection{First Test Subsection} \subsection{Second Test Subsection} \subsection{Third Test Subsection} \subsection{Fourth Test Subsection} \section{Test Section 2.2} \subsection{First Test Subsection} \subsection{Second Test Subsection}  \end{document} Conveying "under the radar" in a less colloquial way I am searching for a word to contrast with iconic  I want to characterize views of the city as both iconic and under the radar, maybe "non-iconic."  I was thinking about saying that a view of the city was undiscovered, but I think that maybe that overstates what I'm think-- I more mean under-appreciated. Are there any other words that come to mind? Azure DNS does not lookup SPF policies for certain domains 2.8 mesh select mode hotkey changed The hotkey for mesh select mode (vertex, edge, face) while in edit mode Ctrl + Tab has been reassigned in 2.8. Is there another hotkey assigned for this?