Hello All,
I have polygons in a geo-databases - WGS84
I want to calculate the extent (XMin, ...)
I have added a field XMin_Test (double)
In the field calculator I added the Python expression !extent.XMin!
I am getting the following error:
ERROR 000539: Invalid field extent.XMin
Failed to execute (Calculate Field).
I have tried the field as text, changed the expression to !extent.shape.YMin!
Same error.
Thanks.
I am getting the same error.
however when I use the expression: !test!extent.XMin
It runs but no values are added to the field. All are NULL
Thanks,
Below is the result:
Executing (Add Field): AddField Geo_Index_All_test test DOUBLE # # # # NULLABLE NON_REQUIRED #
Start Time: Mon May 20 12:00:04 2013
Adding test to Geo_Index_All_test...
Succeeded at Mon May 20 12:00:05 2013 (Elapsed Time: 1.00 seconds)
Executing (Calculate Field): CalculateField Geo_Index_All_test test !TEST.Extent.XMin! PYTHON #
Start Time: Mon May 20 12:00:05 2013
ERROR 000539: Invalid field TEST.Extent.XMin
Failed to execute (Calculate Field).
Failed at Mon May 20 12:00:05 2013 (Elapsed Time: 0.00 seconds)
However,
Below are the results when with different expression (runs - but all NULL)
Geo_Index_All_test test DOUBLE # # # # NULLABLE NON_REQUIRED #
Start Time: Mon May 20 12:02:19 2013
Adding test to Geo_Index_All_test...
Succeeded at Mon May 20 12:02:20 2013 (Elapsed Time: 1.00 seconds)
Executing (Calculate Field): CalculateField Geo_Index_All_test test !TEST!.Extent.XMin PYTHON #
Start Time: Mon May 20 12:02:20 2013
Succeeded at Mon May 20 12:03:22 2013 (Elapsed Time: 1 minutes 2 seconds)
Thanks a lot.
The syntax that works in model builder is as follows:
!SHAPE!.extent.ymin
Obviously the shape field needs to be capitalized and surprisingly the xmin field need not be.
import arcpy import os from arcpy import env # Set the current work Space - the input feature folder arcpy.env.workspace = r'Y:\USGS_HiRes\Appended_Polygons_BK\Test_Join.gdb\Placemarks_Join' # Select the input feature inputFeature = r'Y:\USGS_HiRes\Appended_Polygons_BK\Test_Join.gdb\Placemarks_Join\Geo_Index_All_test' inputFilename = os.path.basename(inputFeature) print 'The input feature is ...' print inputFilename # Process: Add all 4 Fields arcpy.AddField_management(inputFeature, "X_Min", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") arcpy.AddField_management(inputFeature, "Y_Min", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") arcpy.AddField_management(inputFeature, "X_Max", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") arcpy.AddField_management(inputFeature, "Y_Max", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") print '' addedFields = arcpy.ListFields(inputFeature) for addedFields in addedFields: print ("Fields-Present:{0}".format(addedFields.name)) #Process: Calculate all 4 Fields arcpy.CalculateField_management(inputFeature, "X_Min", "!SHAPE!.extent.XMin", "PYTHON_9.3", "") arcpy.CalculateField_management(inputFeature, "Y_Min", "!SHAPE!.extent.YMin", "PYTHON_9.3", "") arcpy.CalculateField_management(inputFeature, "X_Max", "!SHAPE!.extent.XMax", "PYTHON_9.3", "") arcpy.CalculateField_management(inputFeature, "Y_Max", "!SHAPE!.extent.YMax", "PYTHON_9.3", "")