[Qgis-user] script to simplify 'Set to Map Canvas Extent'

Ramon Andinach custard at westnet.com.au
Mon May 15 02:52:56 PDT 2017


Hi Willem,

I can give you an example of where I really, really don’t want the extent to be updated with the refresh button.

One of the things I use QGIS for requires making a series of maps using two or more of a set of layers.
So I can have a composer set to a wide view to give a regional overview, and another composer set to a narrower more local view. I can then turn on one set of layers and generate maps at both scales with that set. After that I can change to set B, hit refresh to check it looks right (and I didn’t forget a layer) then have maps for set B straight up.
(I keep different QGIS projects, with a similar set of composers for each project area I work in. Once I’ve got the map extents set, then I don’t have to meddle with the composers too much. You sound a lot like you’re expecting to people to recreate maps on the fly over and over again - this is really time consuming.)

Another reason might be that you’ve got your composer set up and you zoom into somewhere on the map to check a detail, fix it and you want to see what it looks like on the map - but you don’t want to zoom back out. 

I really like that the extent for each composer is fixed - unless I choose to change it. It seems perfectly intuitive to me :)



On a slight tangent, I notice that Christine did answer the question you asked. 
Did you mean to ask, “Is there a way to automate creating a map?"
or,
"Can I create a button that combines functions in the Composer window?"
instead?
In current QGIS, the composer is pretty isolated from the rest of the program, as it’s not possible to directly make changes to composers through scripts. This is a limitation of the libraries used in the composer. I know there’s been a major overhaul of the Composer in the upcoming QGIS 3 release, and I’m pretty sure this is one of the changes.
I’m sure Nyall will correct me if I’m wrong.

Ramon.


> On 15 May 2017, at 16:00, Willem Coetzer <W.Coetzer at saiab.ac.za> wrote:
> 
> I was amazed that QGIS doesn't have a button to simplify this critical function. Thank you Christine, I do appreciate the response. I found a script that makes a new composer and then zooms to the extent of the map canvas in the new composer, but the script is not ideal (dependent on objects that won't always be present e.g. the filename of the QGIS template). Ideally one should be able to create a new button on a toolbar and then simply associate the 'Set to Map Canvas Extent' function with the button. If that is not possible I guess the next best thing would be a python script that does the same i.e. zooms to the extent of the map in the active composer.
> 
> I teach basic GIS skills to non-technical people and without this simple function it will be very hard to make any progress. Even the default procedure is too complex for them to remember.
> 
> I strongly suggest that QGIS developers look at this.
> 
> I really expected the 'Refresh' button to refresh the zoom extent as well. Why wouldn't a user want to refresh the zoom extent when refreshing the display of layers? It doesn't make sense to me.
> 
> If anyone can help with that script I'd be grateful.
> 
> 
> 
> Somerset StreetWillem Coetzer
> Grahamstown, 6139Biodiversity Information Manager
> Private Bag 1015Tel:+27 46 603 5841
> Grahamstown, 6140Fax:+27 46 622 2403
> South AfricaEmail:mailto:W.Coetzer at saiab.ac.za
> http://www.saiab.ac.za/
> Disclaimer: http://www.nrf.ac.za/email-legal-notice.php
> 
> -----Original Message-----
> From: Qgis-user [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of qgis-user-request at lists.osgeo.org
> Sent: 13 May 2017 09:00 PM
> To: qgis-user at lists.osgeo.org
> Subject: [Marketing Mail] Qgis-user Digest, Vol 135, Issue 17
> 
> Send Qgis-user mailing list submissions to
> qgis-user at lists.osgeo.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.osgeo.org/mailman/listinfo/qgis-user
> or, via email, send a message with subject or body 'help' to
> qgis-user-request at lists.osgeo.org
> 
> You can reach the person managing the list at
> qgis-user-owner at lists.osgeo.org
> 
> When replying, please edit your Subject line so it is more specific than "Re: Contents of Qgis-user digest..."
> 
> 
> Today's Topics:
> 
>   1. refresh zoom extent in composer (Willem Coetzer)
>   2. Re: refresh zoom extent in composer (Christine)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Sat, 13 May 2017 10:44:44 +0000
> From: Willem Coetzer <W.Coetzer at saiab.ac.za>
> To: "qgis-user at lists.osgeo.org" <qgis-user at lists.osgeo.org>
> Subject: [Qgis-user] refresh zoom extent in composer
> Message-ID: <5f079d395252426b9a6f1f0d6af33499 at ZAGRH01EX02.saiab.local>
> Content-Type: text/plain; charset="utf-8"
> 
> If the zoom extent in the view changes, is there a way to update the composer to reflect the same extent or do you need to create a new composer?
> 
> Thanks
> 
> 
> [cid:image40e5f3.PNG at 44bf3bf6.42823550]<http://www.saiab.ac.za/>
> 
> 
> 
> 
> Somerset Street
>        Willem Coetzer
> 
> Grahamstown, 6139       Biodiversity Information Manager
> Private Bag 1015        Tel:    +27 46 603 5841
> Grahamstown, 6140       Fax:    +27 46 622 2403
> South Africa    Email:  W.Coetzer at saiab.ac.za<mailto:W.Coetzer at saiab.ac.za>
> http://www.saiab.ac.za/<http://http://www.saiab.ac.za/>
> 
> 
> Disclaimer:<http://www.nrf.ac.za/email-legal-notice.php> http://www.nrf.ac.za/email-legal-notice.php
> 
> 
> Please consider the environment before printing this message.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20170513/19d720de/attachment-0001.html>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: image40e5f3.PNG
> Type: image/png
> Size: 33578 bytes
> Desc: image40e5f3.PNG
> URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20170513/19d720de/attachment-0001.png>
> 
> ------------------------------
> 
> Message: 2
> Date: Sat, 13 May 2017 06:42:50 -0700 (MST)
> From: Christine <geo.guide at web.de>
> To: qgis-user at lists.osgeo.org
> Subject: Re: [Qgis-user] refresh zoom extent in composer
> Message-ID: <1494682970839-5320434.post at n6.nabble.com>
> Content-Type: text/plain; charset=us-ascii
> 
> Willem Coetzer wrote
>> If the zoom extent in the view changes, is there a way to update the
>> composer to reflect the same extent or do you need to create a new
>> composer?
> 
> Dear Willem,
> you don't need to create a new composer. Procedure may depend on your QGIS version, in elder versions the window to select an item may be missing.
> 
> First select the map item in the composer view (right column). In the item properties tab (below) scroll to the extents section. There you can find the two buttons "set to map canvas extent" and "view extent in map canvas".
> 
> Click the first one to transfer your map window extent coordinates (your
> "view") to your composer map extents (your "composer"). That's what you wanted to do as I understand it.
> 
> With the second button you might do the reverse: transfer the composer map extent coordinates (your "composer") to your map window (your "view").
> 
> Regards, Christine
> 
> 
> 
> 
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/refresh-zoom-extent-in-composer-tp5320428p5320434.html
> Sent from the QGIS - User mailing list archive at Nabble.com.
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> 
> ------------------------------
> 
> End of Qgis-user Digest, Vol 135, Issue 17
> ******************************************
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user




More information about the Qgis-user mailing list