POST
|
I'm copying features (polygons) from one feature class to a new feature class, using arcpy.Polygon() and an insert cursor. (I'm basically doing a copy, the hard way. But Append() wasn't working for me...long story, so here I am...) In my code below, the record for the polygon is added, but the area and length fields are zero. When I print out the area and length values from the object created from Polygon(), I get zero values as well. The last point in the array of points for the polygon is also the first point, so the polygon should be closed. Any ideas/suggestions about what I'm doing wrong? Here is my code: import os, arcpy coordList = [] copyFeats = arcpy.SearchCursor(r"C:\temp\GDBs\20130521203526.gdb\polygon") for feat in copyFeats: poly = [] for feat in feat.shape.getPart(): for pnt in feat: poly.append([pnt.X,pnt.Y]) coordList.append(poly) print "coordList: %s" % str(coordList) # Create empty Point and Array objects point = arcpy.Point() array = arcpy.Array() # A list that will hold each of the Polygon objects featureList = [] sr = arcpy.Describe(r"C:\temp\GDBs\20130515145336.gdb\polygon").spatialReference for feature in coordList: # For each coordinate pair, set the x,y properties and add to the # Array object. for coordPair in feature: point.X = coordPair[0] point.Y = coordPair[1] print "add %s to array" % (str(coordPair[0]) + ' ' + str(coordPair[1])) array.add(point) # Create a Polygon object based on the array of points print "creating polygon" polygon = arcpy.Polygon(array) print 'area: %s, length: %s' % (str(polygon.area),str(polygon.length)) # Clear the array for future use array.removeAll() # Append to the list of Polygon objects featureList.append(polygon) arcpy.CreateFeatureclass_management(r"C:\temp\GDBs\20130521203526.gdb", "polygon_py", "POLYGON", "","DISABLED","DISABLED", sr) ins = arcpy.InsertCursor(r"C:\temp\barbados\GDBs\Ruth_20130521203526.gdb\polygon_py") for poly in featureList: print "insert polygon" row = ins.newRow() row.shape = poly ins.insertRow(row) del row del ins
... View more
05-23-2013
07:55 AM
|
0
|
1
|
289
|
POST
|
Thanks, Neil. Good to know. I thought it was a reason for an error I'm getting further in the code, but maybe not. I'll look into it more now, with this new knowledge 🙂
... View more
12-06-2012
08:18 AM
|
0
|
0
|
199
|
POST
|
I'm using ArcObjects with .NET, and have ArcGIS Desktop 10 SP 4 installed. In my code I have the following line: [INDENT]IFeatureClassName outFeatureClassName = (IFeatureClassName)new FeatureClassName();[/INDENT] When I look at the outFeatureClassName object in debugging, the following exceptions have been thrown by objects in the class: [INDENT]CanEditMetadata.Metadata InteropServices.COMException CanEditMetadata.ModelName InteropServices.COMException NativeType InteropServices.COMException ObjectClassID InteropServices.COMException SQLPrivileges InvalidCastException[/INDENT] A little more info on the SQLPrivileges error... [INDENT]Unable to cast COM object of type 'ESRI.ArcGIS.Geodatabase.FeatureClassNameClass' to interface type 'ESRI.ArcGIS.Geodatabase.ISQLPrivilege'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{A867A185-C5CB-11D2-AAE2-00C04FA37849}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).[/INDENT] Is there a known issue with this class? Is there a way I can get around this issue? p.s. I also tried "new FeatureClassNameClass()", instead of casting it, but got the same results. Thanks, Ruth
... View more
12-06-2012
06:29 AM
|
0
|
2
|
793
|
POST
|
I'm importing a toolbox into my Python script using arcpy.ImportToolbox(..). When I call one (or any) of the method(s) from that toolbox, I get the error message "takes 0 arguments ...". I'm using the toolbox alias, when calling the method. Also, I've opened the method in ArcMap and verified there are 2 parameters. What could be wrong? (fyi...my first time doing this...somewhat new to arcpy) {ArcGIS 10, Python 2.6} Below is what I've tried in my Python console. Thanks! import arcpy arcpy.ImportToolbox(r"mypath/mytoolbox.tbx") arcpy.tbMethod_tbAliasName("parm1","parm2") Traceback (most recent call last): File "<console>", line 1, in <module> TypeError: tbMethod() takes no arguments (2 given)
... View more
03-19-2012
08:38 AM
|
0
|
0
|
351
|
POST
|
I have a script on the server, which I execute using javascript using: var myjobGP = new esri.tasks.Geoprocessor('ourserver/ArcGIS/rest/services/GPServer/MyJob') myjobGP.submitJob(parms, myjobComplete, myjobStatus, myjobError) However, I'm getting the "TypeError: esri.bundle is undefined" error before (so it seems) getting to MyJob on the server. I've also included the FireBug console output (see below), but I can't find anything helpful there (it refers to line 48, which is one LONG line of code that is not readable at all). Any suggestions/ideas?? TypeError: esri.bundle is undefined ()?v=2.2 (line 48) ()?v=2.2 (line 48) undefined = "[object Object]" ()?v=2.2 (line 48) undefined = "[object Object]" undefined = "myjobComplete" undefined = "myjobStatus" undefined = "myjobError" undefined = "[object Object]" ()?v=2.2 (line 48) undefined = "[object Array]" _144()?v=2.2 (line 14) d3 = self.declaredClass;if ()?v=2.2 (line 14) undefined = "_2d3 && _2d3.indexOf("F...1) {self._resolve([err]" undefined = " null" undefined = " _2cc[sig.e]" undefined = " _2cd" undefined = " true);} else {self._errorHandler(err" undefined = " _2cc[sig.e]" undefined = " _2cd);}})" undefined = "(function () {})" ion ()?v=2.2 (line 14) undefined = "err) {var _2d3 = self.d...1) {self._resolve([err]" undefined = " null" undefined = " _2cc[sig.e]" undefined = " _2cd" undefined = " true);} else {self._errorHandler(err" undefined = " _2cc[sig.e]" undefined = " _2cd);}})" ()?v=2.2 (line 48) undefined = "[object Object]" undefined = "myjobComplete" undefined = "myjobStatus" undefined = "myjobError"
... View more
03-07-2012
10:29 AM
|
0
|
1
|
776
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|