0

I'm working on writing a script that will calculate facility ID's for feature classes in a feature dataset. Is there a way to do this without making feature layers and doing select/field calculate operations on all of them?

Basically, I'm wanting to iterate through the feature dataset and create a list of feature classes that can then have the field calc ran on each. The problem is that each feature class has a different expression for field calculation, and I need to select only null values, and the select layer by attribute function requires a feature layer.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 2, 2018 at 22:53
3
  • 1
    It's not hard to make a feature layer from a feature class, read resources.arcgis.com/en/help/main/10.2/index.html#//… about MakeFeatureLayer. Your question is a little to vague to be helpful in any specific way; are you looking for a particular field that has Null values? Making a feature layer with a where clause '<field> is NULL' coupled with int(arcpy.GetCount_management(YourFeatureLayer).getOutput(0)) will very quickly give you an idea of how many features have a null in their <field>. Commented Jul 3, 2018 at 3:11
  • Make an attempt using da.UpdateCursor and post a new question if you get stuck and include your code attempt. Commented Jul 3, 2018 at 8:03
  • I just need to calculate facility ID's for every feature class in a feature dataset, all using a common field. The problem is that each feature class has a different method if calculating the ID's. I'll try the update cursor. Thanks, guys! Commented Jul 3, 2018 at 12:06

1 Answer 1

2

I would not use the Field Calculator for this. Instead I would use an arcpy.da.UpdateCursor():

UpdateCursor establishes read-write access to records returned from a feature class or table.

Returns an iterator of lists. The order of values in the list matches the order of fields specified by the field_names argument.

You will need to write various if/elif/else statements, use ListFeatureClasses, etc to complete your code.

answered Jul 2, 2018 at 23:00

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.