10/2/2023 0 Comments Calculate geometry x arcpy![]() Then bring your XY points back into the original coordinate system. Then add fields and calculate the geometry of the points in decimal degrees. Actually I only wrote the code once and then saved the query expressions for subsequent uses, but still, it’s much easier to use the newer Calculate Geometry functions. Im not sure about a script, but Ive this accomplished in a somewhat automated fashion using model builder: import your xy coordinates and project them into WGS 1984. I greatly enjoy and make frequent use of the Calculate Geometry functions and appreciate not haveing to write the VBA code blocks that I used to write to add X and Y coordinates to attribute tables or calculate polygon areas. I should point out that there are some wonderful simplications to field editing in ArcGIS 9.x and 10 that esri programmers should be commended for. Don’t get me wrong, it’s not that I hate change or dislike Python I use it often. This kind of editing used to be easier and I hope someone at esri figures this out and simplifies it again. Users shouldn’t have to write a Python function and then pass an attribute field value into that function to edit a field. Replacing dialogs and functions that worked well for casual users with Python code blocks works well for programmers and power users, but it leaves casual users to struggle with stuff they used to know how to do. But it seems that as ArcGIS has grown more powerful some portions of it have grown more difficult for casual users. Calculate Geometry - We used the calculate geometry tool within the attribute table to calculate the length of lines between points and the area of polygons. I’m not worried that they going to lose their customer base or market share. But not anymore, why?Īs a long time esri user, this kind of stuff concerns me. We coudl do it in VBA and even Avenue (for those who remember the ArcView 3.x Query Builder), AML allowed this too. This worked fine but I was really surprised that I could not just use the field names within the code block. We’ve always been able to do this in esri projects. Pre-Logic Script Code: def DoMath(field1, field2):Īssignment Code: DoMath(!SUM_delive!, !SUM_weeks_!) Field Calculation Example with Python ![]() So I composed the following Python code to send my colleague: Much to my surprise this code generated a parsing error, and try as I did, I could not change it in a way that would work, despit the fact that it appears to be perfectly valid Python code.Īfter reviewing some portions of the ArcGIS Desktop help file, I learned that in order for me to execute the same statement in Python, I needed to write a Python function and then pass the field values into that function. In response, I initially tried to simply convert the Pre-Logic code block to the following Python code: if (!SUM_weeks! 0): While this worked fine, he mentioned that he would rather have Python code, since it is rumored that esri is removing VBA in future releases of ArcGIS. ![]() Pre-Logic Script Code: if ( 0) thenĪssignment Code: = newval Field Calculation Example with VBA In response to his question, I quickly provided him the following VBA code for his field calculator tool: He was building a model in ModelBuilder and wanted to perform a conditional (If Then) calculatuion to evaluate whether a field’s value was Zero (0) before he tried to divide another value with it. Video 130In this video, you will see how to extract geometry properties from your features and store them in your layer.Using 'Calculate Geometry' in the At. Give it a try or export the script from the toolbox and modify.I got a call from a colleague who was having dificulty getting ArcGIS to calculate the value of a field in an attribute table.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |