Sunday, 22 January 2017

qgis - How do I clip OSM basemap with a polygon?


I've created a map in qgis 2.0. The map uses the OpenLayers plug-in to add the OSM layer as a basemap. I would like to restrict the basemap to be visible only inside a given polygon defined in a shapefile layer. How do I achieve this?



Answer



This way it works for me:




  1. Create a worldwide polygon shapefile stretching from +180°E to -179,99°E and from +85.5°N to -85.5°N with a text file containing




    Nr;WKT


    1;POLYGON ((180 85.5, -179.9 85.5, -179.99 -85.5, 180 -85.5, 180 85.5))





  2. Add that file as Text delimited layer, using semicolon as separator and WGS84 as CRS.




  3. Save the layer as shapefile in the CRS of your polygon, add that to the canvas and delete the text file layer.





  4. Subtract your polygon shapefile from that, and set the fill of the remaining polygon to 100% white.




  5. Put it on top the Openlayers layer, and only the wanted area will be visible for all zoom levels:




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...