Tuesday, 22 May 2018

qgis - Extra conditions in composer controlled by atlas


I want to create a map series controlled by atlas, but some of my features have very different scales. I want to insert a condition to never use a scale lower than X (for instance: 1:5000). Any idea?


This is the result for one of the maps that zooms too much because it is shown just one point in the map.


enter image description here



Answer



In Main Properties tab -> Scale -> Data Defined Override, you need to write the following expression:


case 
when @map_scale < 5000 then 5000
else @map_scale

end

The above means that if the scale that fits the feature is less than 5000 then use the scale of 5000, and if the scale that fits the feature is more than 5000 then use the best fit.


The above expression will prevent the scale to zoom in more than 5000.


For example, I am using data from Natural Earth Data (UK Boundary) to test the above expression (but for this case I used a scale of 50,000):


Without the above expression, the best fit for Bristol County is 39,688 as you can see below:


enter image description here


After applying the above expression with 50,000 instead of 5000 (as in your case), Bristol County zoomed out to 50,000 and it cannot be zoomed in less than the defined scale:


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...