Trouble with Calculating Geometry in Python

745
3
Jump to solution
06-22-2022 07:35 PM
Labels (3)
HarryHewson
New Contributor II

Hi everyone,

 

I am working on my Masters capstone project and running into an issue that is hindering my team from moving forward on our project. In our project, we are intersecting county parcels with sea level rise data. We need the area of both the county parcels and intersect to continue the project. To automate this process, I have written up some Python code in a Jupyter notebook (Python 3.7, ArcGIS Pro 2.9). 

 

Here's the catch, however. The new area columns are being created, but the calculations are not happening. Both keep returning values of 0, despite the fact that they calculate properly when I point and click in ArcGIS. I even used the built in Python code generator to write my code.

Here is a piece of the code I am using to run this. Also attached is a screenshot of my output, where Par_Area and Area_1ft are the areas I am trying to calculate.

 

for fc in fcList:

arcpy.management.AddField(fc,
field_name = "Par_Area",
field_type = "DOUBLE")

arcpy.management.CalculateGeometryAttributes(in_features = fc,
geometry_property = [["Par_Area", "AREA_GEODESIC"]],
lenght_unit = "",
area_unit = "SQUARE_FEET_US",
coordinate_system = fc,
coordinate_format = "SAME_AS_INPUT")

 

The fc and fcList variables are file path parts and work just fine. Any help would be fantastic.

0 Kudos
1 Solution

Accepted Solutions
HarryHewson
New Contributor II

As it turns out, for some reason Jupyter and Arc weren't communicating with each other. Running the exact same code in Arc worked flawlessly. 

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

in the "fields view" for the shape_area field, check the field type and decimal display options.  It could be that your data are in decimal degrees and the areas are so small in those units that they aren't displaying.

It would be useful if your featureclasses were using a projected coordinate system (not Web Mercator, which is awful for area calculations). 

Report on the shape_area field type as well as the properties of the other field you are calculating.

Calculate Geometry Attributes (Data Management)—ArcGIS Pro | Documentation

Specify an appropriate projected coordinate system for your area using this option

Coordinate System
(Optional)
The coordinate system in which the coordinates, length, and area will be calculated. The coordinate system of the input features is used by default.

Any suitable conformal or equal-area coordinate system would be good (eg even UTM, State Plane etc etc)


... sort of retired...
HarryHewson
New Contributor II

Hi Dan,

 

My feature class does use a projected coordinate system, specifically the PROJCS - NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901_Feet version. 

 

I'll check the fields_view in a minute. If it is the case that field is in decimal degrees, is there a way to convert it easily?

0 Kudos
HarryHewson
New Contributor II

As it turns out, for some reason Jupyter and Arc weren't communicating with each other. Running the exact same code in Arc worked flawlessly. 

0 Kudos