0

I have a roads dataset downloaded for Christchurch, New Zealand, from OpenStreetMap. The attribute table contains a column titled 'fclass', which contains the type of road each feature represents (e.g. motorway, secondary, service, etc).

Using ModelBuilder, I would like to loop through each feature in the dataset and, for each type of road, assign a numeric value to a new column (e.g. '4' if road type is 'motorway' and '1' if road type is 'tertiary'). The column I wish to add the score to already exists, it is just a case of calculating it for each road type.

This loop, or lookup, forms a small part of a much larger model.

2 Answers 2

1

If just dealing with a few road types then the manual approach suggested by @Arthur_Crawford should suffice.

If you wanted to assign a specific number to a specific road type you need to create a look up table. So first field is the textual road type "motorway" the second would contain the number. Then join that table to your featureclass. No need for looping or select and update, can be done with one tool (Join Field) if the lookup table exists.

3
  • The loop / lookup forms a part of a much larger model, hence why doing this manually isn't an option (question edited to reflect this). I've not created a lookup table - there doesn't seem to be much online about how this is done.
    – the_bonze
    Jan 6, 2017 at 17:40
  • A look up table is nothing more than a table with the 2 fields, road type and number with each row a road type.
    – Hornbydd
    Jan 6, 2017 at 20:27
  • I agree with @Hornbydd that you should create a lookup table and just join it to the OSM data.
    – capie69
    Jan 10, 2017 at 12:59
0

You could use a select by attribute tool, then calculate field in series. You don't really need a loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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