How to choose between data frame coordinate or data source coordianate to calculate geometry?

3888
17
07-13-2015 11:54 AM
SaidAkif
New Contributor III


Hi

I looked on the web for a way to calculate geometry ("shape.area@hectares!") with an easy way to choose between the data frame coordinate or data source coordiane to complete this thast with arcpy (python). Unfortunatly, I fourd something related to the use or the sursor (updateCursor).

is there an easy way to do so?

Thanks

0 Kudos
17 Replies
DarrenWiens2
MVP Honored Contributor

Unfortunatly, I fourd something related to the use or the sursor (updateCursor).

is there an easy way to do so?

This is confusing. Did you find a solution using updateCursor that is too complicated and you're looking for a simpler solution? If so, post a link to the complicated solution, or better yet, the code itself. If not, please explain further what you are looking for.

0 Kudos
SaidAkif
New Contributor III

Hi

I am looking for an alternative way to do it, more efficient or a way that I don't know

0 Kudos
DarrenWiens2
MVP Honored Contributor

Please post what you found so we have a starting point.

edit: I will assume you are looking for a way to use the field calculator (or Calculate Field tool) rather than learning how to use an Update Cursor. I'm guessing the reason Update Cursor works while field calculator does not, is that the field uses the CRS of the layer, while you can specify the CRS of an Update Cursor. I can't say whether simply specifying a different CRS in the Update Cursor will actually yield correct results, but you are free to change it nonetheless.

SaidAkif
New Contributor III

Hi

I just past rapidly when I see not easy (efficient procedure)

http//:gis.stackexchange.com/questions/73170

Thanks

0 Kudos
SaidAkif
New Contributor III

Me too I did not test the code. But it is like this

0 Kudos
SaidAkif
New Contributor III

Sorry but I dont know why i can't copy/paste here

0 Kudos
XanderBakker
Esri Esteemed Contributor

You could use the tool "Add Geometry Attributes (Data Management)", this will add a new field of the property (e.g. AREA or AREA_GEODESIC) to your featureclass: Add Geometry Attributes—Help | ArcGIS for Desktop

arcpy.AddGeometryAttributes_management (Input_Features, Geometry_Properties, {Length_Unit}, {Area_Unit}, {Coordinate_System})

As you can see you can provide the coordinate system as parameter.

SaidAkif
New Contributor III

I believe this tool is available just in 10.2 and I use 10.1

XanderBakker
Esri Esteemed Contributor

True, this tool was introduced at 10.2 and is not available in 10.1. 

What is exactly the reason that you are asking for a python script?  If it is just a single time you have to apply this, there is no need to script it and with a few clicks you can get the result.

Is it something that you have to do repetitively (on multiple featureclasses)?

Do you want to create a tool and offer the functionality to other users?

It is possible to create a tool and/or to create a script that loops through multiple datasets, but knowing a little more of what you are after, helps to define what option is best for you.