[GIS] Automatically aggregate German ZIP codes by the first two digits in a shapefile

qgisshapefilezip-codes

I have a shapefile which contains all German Zip-Codes in a a five-digit format (e.g. 80637). For what I intend to do, this is way to much detail. I would like to aggregate all Zip-Code areas by the first two digits (e.g. 80).

enter image description here

My approach is ordering ZIP codes in the QGIS attributes table numerically, then selecting them manually, then joining them. This is somewhat cumbersome I'll have to do this a hundert time.

Is there a way of doing this programmatically? I tried automate this process following this instruction, but I failed at importing sextante.

Best Answer

create a new field and copy the first two digits from the left using the field calculator

-> for text, you can use (left(fieldname,2)) in the field calculator. With numeric field you can use floor(fieldname/1000)

dissolve your polygons based on this new field

-> this command is in vector -> geometry -> dissolve

Related Question