I have shapefiles of contour lines that I have imported in QGIS. At the moment the contour lines are all the same stroke weight. I wanted to know if it is possible to change the stroke weights of the contour lines based on the elevation?
1 Answer
I assume your goal is to have different stroke weights for multiples of certain values - ie, one line weight for lines that are multiples of 10M, another for multiples of 100M, and so on. The details of how to do this depend on your software, but my general approach is to open the attribute table associated with the shapefile and add a new field which will indicate which group of lines (i.e. stroke weight) that particular line belongs to. In my example of looking for specific multiples, you test if the contour elevation is a multiple of 100 (using the modulus operator %: elevation % 100 = 0). If true, set the field to 1, otherwise to 0. You can now style the lines based on categories. The details of these steps vary from one program to another, but the basic idea applies in a variety of programs, esp. ArcMap and QGIS.
Edit:
OK, here's a stab at detailed instructions in qgis. I am assuming your shapefile has a field that contains the elevation of your contours. Further, I'm assuming that this field has nice round values - for this example, I'm assuming they're multiples of 10 units (whatever the unit is for your file).
Select the contour layer in the TOC and click "Properties", then Style. In the style pane, set the style type to "Rule Based" (this is a drop-down box just below the Layer Rendering block at the top of the pane. You should see a single default rule. Select the first rule, then click on the pencil icon at the bottom to open the rule editor. In the Filter line, type
"Elevation" % 100 = 0
substitute the name for the field in your shapefile that gives the elevation of each contour line for the "Elevation". The quote marks are essential.
In this same dialog, set the color and line weight (width) for the 100' contours. Click OK
Now, to add all the other contours, create a new rule by clicking the plus icon. This time your rule is
"Elevation" % 100 <> 0
This is all the lines that are not a multiple of 100. If you want more classes, generalize from here. My limited testing indicates that a feature is symbolized by the first rule it satisfies. So, you could write the 10' rule as
"Elevation" % 10 = 0
and the 100' contours will not be colored by this rule since they are colored by the earlier rule they satisfy.
-
About ArcMap: gis.stackexchange.com/q/7673/22405 - About QGIS: gis.stackexchange.com/q/84967/22405 Commented Feb 27, 2014 at 9:03
-
I am using QGis. Also a little disclaimer... I'm a graphic designer, not a map software guru. I'm simply trying to create a great topography map for graphics purposes so the more detailed you can be the better. Sorry! Commented Feb 27, 2014 at 22:04
-
This worked great! I played around with various styles and output some cool looking topos. Now the only problem that I'm having is exporting the layer to vector or shapefile... I am clicking Vector > Save as Vector File I ultimately want to export the "styled" contours and import into indiemapper so that I can turn into a working vector file for Adobe Illustrator. Maybe I am exporting incorrectly but I can't seem to get the files to export. Commented Feb 28, 2014 at 17:30
-
2exporting does not export the style, since that is not part of the shapefile spec. You could create a map layout in Composer and export it as PDF or SVG, either of which should work in Illustrator. BTW, while writing up the answer, I generated a topo where the major intervals not only had different weights, but different colors. Not the standard approach, but it looked good to my eye.– LlavesCommented Mar 1, 2014 at 20:33