Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Courtesy of Geofabrik I have a "places" point shapefile which includes in the attribute table a column named "type". As can be seen in the attached image the column contains fields such as "city", "town" and "village". For labelling purposes I wish to populate the "font" column with integers such that when "type" = 'village' then "font" will be set to (say) 7, or when "type" = 'city' then "font" will be set to (say) 12, and so on.

Best wishes.

enter image description here

share|improve this question
up vote 4 down vote accepted

If You want to have separate column use CASE statements in the Field Calculator - similar to what underdark suggests. Write something like this:

 WHEN  "type" = 'village' THEN 7
 WHEN  "type" = 'city' THEN 12
 .....more statements
share|improve this answer
This was the solution I used, but thanks to all. – nhopton Feb 19 '14 at 11:18

Create a CSV with type and font values and join it to the points. Save the result as a new file. I think that should be fastest.

Alternatively, you can write CASE WHEN ... THEN ... ELSE ... END statements in field calculator to select the correct font size.

But actually, you don't even have to save the font size in a separate column. You can use expression-based label size to define the size on-the-fly.

share|improve this answer

You can use the Fields option. Right click on your layer > Properties > Fields. There you can choose the widget Value map for your target attribute and set a description for the values stored in this column. The type "village" would have the description 7. After that you have the numbers for labelling.

This is like a replacement and the original types cannot be seen anymore. It depends on your labelling purposes, if you want to label your points with the original types as well.

Otherwise you have to "copy/paste" this column:

One solution could be to add a column with unique IDs (e.g. new column name type_id) to your layer (for joining it with itself). How you can do this is explained here. For your business you can revert to the osm_id of your layer. After that you export your attribute table of point layer to dbf/ or csv file. Then you join your layer with the dbf/ or csv file (type_id-type_id join, or osm_id-osm_id). This solution is explained in this answer as well. Before you export your attribute table you can kick out the columns you don't want to export. Right click your layer > Properties > Fields and choose the widget Hidden instead of Line Edit to hide unwanted columns.

After the join you have two identical columns. With one of them you can do the "value mapping" mentioned above.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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