Whenever a script is reading coordinates for polygons in a geodatabase or shapefile, it should contain logic for handling inner rings if this information is required by the script otherwise, only the exterior ring is read.Ī multipart feature is composed of more than one physical part but only references one set of attributes in the database. The exterior ring is always returned first, followed by inner rings, with null point objects as the separator between rings. The array of point objects returned for a polygon contains the points for the exterior ring and all inner rings. If a polygon contains holes, it consists of a number of rings. All other feature types-polygon, polyline, and multipoint-return an array of point objects, or if the feature has multiple parts, an array containing multiple arrays of point objects. PointGeometry features return a single Point object instead of an array of point objects. If an index is not specified, an array containing an array of point objects for each geometry part is returned. The getPart method returns an array of point objects for a particular part of the geometry if an index is specified. The geometry object's partCount property returns the number of parts for a feature. These points can be accessed with geometry objects ( Polygon, Polyline, PointGeometry, or MultiPoint), which returns them in an array of Point objects.įeatures can have multiple parts. 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.Each feature in a feature class contains a set of points defining the vertices of a polygon or line, or a single coordinate defining a point feature. 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. 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. 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 |