0

I have 39 different .shp files of the same locations but different data values and I need to output a map for each of them. Is there a way to build a map template and then run a process that will loop through each .shp file and output a map, either .pdf or .png, of the map template with the individual .shp files?

0

you can achieve this with the atlas function of QGIS. Let's say you have different themes with names 1..n. Then you have to make an additional pointtheme to control the atlas, e.g. called 'control'. Just put one point for each theme on the same coordinates into the control layer (copy and paste the same point from 1..n). Then put all the names of your 39 themes into the control layer into an attribute column. enter image description here Then make an ATLAS with your maplayout and set the controllayer to your layer 'control'

enter image description here

At least use the data defined override to control the visiblity of the layers through our control layer. Just put the column name (in this example it is called ID, together with the atlasfeature into the expression builder:

enter image description here

  • I have not dealt with themes at all up to this point. It seems to me that I still have the tedious task of creating a theme for each individual file and then copying that file into a control theme. From there, it does appear that the mapping will be much easier but it still requires me to deal with each file individually to get set up for the atlas map production. Is that correct? – Casivio Jan 7 at 22:17
  • yes this is correct more or less, you have to deal with the themes names, but this process can be automated with a python script: collecting all theme names and putting one record for each into a point control theme. – eurojam Jan 8 at 6:03
  • can you give me an example of what a point control theme file looks like so that I can generate it? – Casivio Jan 8 at 18:06
  • Hi, you can download a a project from my dropbox account: dropbox.com/s/g21hamaibdcziwq/control.zip?dl=0 there is also a layout included, where you can see the expression. The only thing is, how to include more themes in the expression. The help is a bit unclear in that... may be someone can help with that issue....best regards Stefan – eurojam Jan 8 at 21:29
0

Update: I figured out a good way to do this using the Basemap package in Python. I wrote up a tutorial that walks through how to plot several .shp files on different maps all with the same extent. It is posted at https://mapping-with-python.herokuapp.com/index.html

The essential components are to open a map object map = Basemap2(llcrnrlon= LongLeft,llcrnrlat= LatBottom,urcrnrlon=LongRight,urcrnrlat=LatTop, projection='tmerc', lat_0 = midLat, lon_0 = midLong, epsg=3857) and then to read in the .shp file you want to map map.readshapefile(file[:-4], 'Param')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.