4

One aspect of GIS that wasn't covered in my training was the best way to manage shapefiles within a project.

In my hypothetical example I have a shapefile with a number of attributes. I want to produce a map comparing 4 different combinations of various attributes.

So I want 4 map windows in my print composer, I then have three options for how to set up the layers (that I have thought of):

A) 1 layer, 1 shapefile. I then use the 'lock layers' and 'lock styles' for each map window, adjusting the properties and styles of the shapefile for each desired attribute combination as I go. The problem is, there is no record of what rules or attributes I used if I come back to it in 6 months time.

B) 4 layers, 1 shapefile duplicated in each layer. I can set the propoerties and style for each layer to correspond with each submap but the shapefile itself still refers to the original .shp file.

C) 4 layers, 4 shapefiles. Duplicate the shapefile and load each separate shapefile into its own layer and set style and properties for each shapefile . This seems to cause performance issues for me.

So far, I tend to follow B, this lets me fine tune settings and styles with ease and also gives reasonable performance but I don't know whether this may give rise to other problems down the line. What is generally considered best practise in this situation for performance and stability?

2

I think this is a matter of personal preference. I tend to use the method associated with C). If I have copies (not duplicates) of the same shapefile, I can add unique attributes to each shapefile which would distinguish them from each other. This, for me, does not cause performance issues though.

In regards to A), remember that you can save your style as a .qml file which will store what styling properties/rules you used so when you come back to it at a later date, you can see exactly what you did.

In regards to B), you could have a single shapefile. But later on, you might need to add more attributes to the shapefile. This could be problematic if you're dealing with large datesets which could consequently increase the filesize. I personally try to avoid this as it normally degrades performance.

I'm sure others will provide a more insightful answer which hopefully would help you decide :)

0

Since a good few versions of QGIS ago, it is possible to do a variant of A), which is the cleanest option, without having to use 'lock layers' or 'lock styles'. It is possible to assign a rule-based symbology to a layer where the rules are applied according to variables.

Setting an item ID for each map item (in this example, 'Map 1'), it is then easy to configure the symbology to respond to which map item the features are shown in. Simply set a rule where the expression looks like:

@item_id LIKE 'Map 1' AND *whatever other filters you need to use*

The features will not get displayed in the main QGIS window so an all encompassing ELSE rule can be used to at least be able to visualise them while editing. Bear in mind, not all variables seem to be selectable from the expression builder but they can still be used in expressions. For a good primer on variables, check out this three part blog post.

enter image description here

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.