Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 13 down vote accepted

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

share|improve this answer
2  
I suggest to use text fields. Otherwise the leading 0 in East German postal codes gets lost. –  AndreJ Apr 14 at 14:32
1  
Thanks for the quick response and saving me a lot of time. The field calculator is a mighty tool I've never noticed/used before. I think this solution can be applied to many problems. –  stekhn Apr 14 at 15:25

Your Answer

 
discard

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.