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.

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.

  • 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 '17 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 '17 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 '17 at 12:59
0

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

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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