I am using ArcGIS Pro 2.8.2 Model Builder. I have been working on a model that makes a feature layer based on a selection criteria then calculates the geometry attributes of that feature layer's acreage field. The only problem I am facing now is that when I check the feature class and the newly calculated acreage, it is a decimal with 6 decimal places. I need this to be 2 decimal places. Any suggestions on how to accomplish this? Any help will be greatly appreciated! See the model's python code below.
# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2021-09-30 10:58:27
"""
import arcpy
def GeometryCalc(): # GeometryCalc
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
# Model Environment settings
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp10544\1ba0f558-c873-4c6c-be6d-dc08393016c0\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp10544\1ba0f558-c873-4c6c-be6d-dc08393016c0\Default.gdb"):
mcpagis_DBO_Parcels = "K:\\GIS_TOOLS\\DB\\merlin.sde\\mcpagis.DBO.Cadastre__Features\\mcpagis.DBO.Parcels"
# Process: Make Feature Layer (Make Feature Layer) (management)
DBO_Parcels_Layer = "DBO.Parcels_Layer"
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb"):
arcpy.management.MakeFeatureLayer(in_features=mcpagis_DBO_Parcels, out_layer=DBO_Parcels_Layer, where_clause="GIS_ACRES = 0 Or GIS_ACRES IS NULL", workspace="", field_info="OBJECTID OBJECTID VISIBLE NONE;PARCEL PARCEL VISIBLE NONE;PREFIX PREFIX VISIBLE NONE;SUFFIX1 SUFFIX1 VISIBLE NONE;SUFFIX2 SUFFIX2 VISIBLE NONE;GIS_ACRES GIS_ACRES VISIBLE NONE;KIND KIND VISIBLE NONE;ANGLE ANGLE VISIBLE NONE;SIZE_ SIZE_ VISIBLE NONE;DATE_CREATED DATE_CREATED VISIBLE NONE;DATE_UPDATED DATE_UPDATED VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;SHAPE.area SHAPE.area VISIBLE NONE;SHAPE.len SHAPE.len VISIBLE NONE")
# Process: Calculate Geometry Attributes (Calculate Geometry Attributes) (management)
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb"):
DBO_Parcels_Layer_2_ = arcpy.management.CalculateGeometryAttributes(in_features=DBO_Parcels_Layer, geometry_property=[["GIS_ACRES", "AREA"]], length_unit="", area_unit="ACRES", coordinate_system="PROJCS[\"NAD_1983_StatePlane_Florida_West_FIPS_0902_Feet\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",656166.6666666665],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-82.0],PARAMETER[\"Scale_Factor\",0.9999411764705882],PARAMETER[\"Latitude_Of_Origin\",24.33333333333333],UNIT[\"Foot_US\",0.3048006096012192]]", coordinate_format="SAME_AS_INPUT")[0]
if __name__ == '__main__':
GeometryCalc()
@ABishop does the following guide help? https://support.esri.com/en/technical-article/000025170
Hello David,
I am aware you can set the field properties to display the acreage field with two decimals and also do this with labeling functions, but that does not change the raw data. I need the raw data that is calculated by the model to produce the output with two decimal places.
@ABishop but the Round() function will round your result to N decimal places.
Where would you insert that in the model python code?
like this at the end?
round(DBO_Parcels_Layer_2_, 2)? At the end of the script?
or....
round(DBO_Parcels_Layer, 2) ??
@ABishop im not entirely sure if you can add that into the calc geometry process directly, but you could add a field calculator process after this and just state that:
DBO_Parcels_Layer = round(DBO_Parcels_Layer, 2)
OK... I think I know what you are suggesting... I put it in the code below. I apologize but I am not a pro at programming... Can you check it out and let me know if this is accurate? If I am missing something?
# -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2021-09-30 10:58:27
"""
import arcpy
def GeometryCalc(): # GeometryCalc
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
# Model Environment settings
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp10544\1ba0f558-c873-4c6c-be6d-dc08393016c0\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp10544\1ba0f558-c873-4c6c-be6d-dc08393016c0\Default.gdb"):
mcpagis_DBO_Parcels = "K:\\GIS_TOOLS\\DB\\merlin.sde\\mcpagis.DBO.Cadastre__Features\\mcpagis.DBO.Parcels"
# Process: Make Feature Layer (Make Feature Layer) (management)
DBO_Parcels_Layer = "DBO.Parcels_Layer"
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb"):
arcpy.management.MakeFeatureLayer(in_features=mcpagis_DBO_Parcels, out_layer=DBO_Parcels_Layer, where_clause="GIS_ACRES = 0 Or GIS_ACRES IS NULL", workspace="", field_info="OBJECTID OBJECTID VISIBLE NONE;PARCEL PARCEL VISIBLE NONE;PREFIX PREFIX VISIBLE NONE;SUFFIX1 SUFFIX1 VISIBLE NONE;SUFFIX2 SUFFIX2 VISIBLE NONE;GIS_ACRES GIS_ACRES VISIBLE NONE;KIND KIND VISIBLE NONE;ANGLE ANGLE VISIBLE NONE;SIZE_ SIZE_ VISIBLE NONE;DATE_CREATED DATE_CREATED VISIBLE NONE;DATE_UPDATED DATE_UPDATED VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;SHAPE.area SHAPE.area VISIBLE NONE;SHAPE.len SHAPE.len VISIBLE NONE")
# Process: Calculate Geometry Attributes (Calculate Geometry Attributes) (management)
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp8392\0686a1b7-5a62-4965-97f7-463b179295c6\Default.gdb"):
DBO_Parcels_Layer_2_ = arcpy.management.CalculateGeometryAttributes(in_features=DBO_Parcels_Layer, geometry_property=[["GIS_ACRES", "AREA"]], length_unit="", area_unit="ACRES", coordinate_system="PROJCS[\"NAD_1983_StatePlane_Florida_West_FIPS_0902_Feet\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",656166.6666666665],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-82.0],PARAMETER[\"Scale_Factor\",0.9999411764705882],PARAMETER[\"Latitude_Of_Origin\",24.33333333333333],UNIT[\"Foot_US\",0.3048006096012192]]", coordinate_format="SAME_AS_INPUT")[0]
# Process: round acreage
with DBO_Parcels_Layer = round(DBO_Parcels_Layer, 2)
if __name__ == '__main__':
GeometryCalc()
or something like this at the end?
round(DBO_Parcels_Layer_2.GIS_ACRES, 2)