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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jan 6, 2017 at 15:40

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.

answered Jan 6, 2017 at 16:34
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. Commented 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. Commented 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. Commented 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.

answered Jan 6, 2017 at 16:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.