|
POST
|
You are reinventing ArcGIS in a Python script. There is rarely a need to loop through a set of features to do a selection. You will be running out of memory in double quick time. It is tempting to run a cursor with a few hundred records, but calling a tool while in a cursor is also very slow. I am not sure what your process is, but there must be a command in the toolbox that would do what you appear to be wanting to do with one overlay command that will attach the respective objectids as an attribute in one fast step. I have been doing a similar overlay process this week with 700,000 records on a route system made from 500,000 records and it completes in around 7 minutes. I did avoid CalibrateRoutes and used a modified PointsToPolylines to build a routesystem directly.
... View more
09-18-2010
01:14 AM
|
0
|
0
|
862
|
|
POST
|
pnt = part.Next()
partnum += 1
This doesn't look right either, setting a point object to the next part.
... View more
09-12-2010
04:48 PM
|
0
|
0
|
1410
|
|
POST
|
Vertices in Parts are not properly pythonic iterable. You have to use a next() operator or wrap the function in an iterator. See my example on the resources for stepping through parts to find and delete donuts in polygons. The same applies to polylines. http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=C4E10FE5-1422-2418-A06D-33952BB8D1D7
... View more
09-12-2010
04:44 PM
|
0
|
0
|
1410
|
|
POST
|
Surely you don't need to iterate the split list? It is already a list after a split print len(fidSet.split(";")) just being economical.
... View more
09-10-2010
06:04 AM
|
0
|
0
|
1837
|
|
POST
|
To update the shape field you have to create an array and assign it to the shape in the buffer before you write the buffer out. You have created a pnt object and updated that, but have not written it back into the row. If the feature is a polyline or polygon then the object needs to be an array of arrays of points to handle multiparts. row.feat = pnt curA.updateRow(row) Also in your search cursor you are mixing the old and new methods, the for loop automatically interates the cursor. either row = cur.next() while row : .... process ....row = cur.next() or for row in cur : ....process
... View more
09-10-2010
05:57 AM
|
0
|
0
|
825
|
|
POST
|
How hard could it be?? Unfortunately this example script is read-only at 9.3. You will have to upgrade to arcpy to insert dates as I have found to my cost. 1/08/2010 <type 'unicode'> Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\eudora\Attachdir\datetest93.py", line 16, in <module> row.timestamp = row.timestamp + datetime.timedelta(hours=10,minutes=30,seconds=15) TypeError: coercing to Unicode: need string or buffer, datetime.timedelta found # datetest93.py
# convert to 9.3 after a problem
import arcgisscripting,datetime
gp = arcgisscripting.create(9.3)
ws = "d:/workspace/datetest.gdb"
gp.workspace = ws
rows = gp.UpdateCursor("fcdate")
row = rows.next()
while row :
print row.timestamp,type(row.timestamp)
if row.timestamp == None:
row.timestamp = datetime.datetime.now() ## fails
pass
else :
row.timestamp = row.timestamp + datetime.timedelta(hours=10,minutes=30,seconds=15) ## fails
pass
rows.updateRow(row)
row = rows.next()
del row,rows
... View more
08-31-2010
12:42 AM
|
0
|
0
|
1320
|
|
POST
|
You could look at the MakeQueryTable tool. This will effectively join a number of tables very efficiently. I have tried it with extremely large tables that would fail with a Join. Haven't tried a cursor on the resulting layer....
... View more
08-26-2010
01:40 AM
|
0
|
0
|
1903
|
|
POST
|
You don't need all the complications of defining a function as a string. Just create the function in the codeblock and use a simple expression that uses the function. Indents and extra lines will be honoured. Calculator is very bad at handling data errors. If your expressions result in an exception, then you won't get any feedback. Better to use a cursor in a script and trap the errors so you can see the faulty data. It is just as fast, because a cursor implements your expression anyway. codeblock that goes in the box : def getvalue(string):
valuelist=string.split(',')
valueset=set(valuelist)
value=str(valueset)[5:-2]
value.replace('"','') # not sure what you are trying to replace - a double quote?
return value expression in the box: getvalue(!parce_test_spatial_join.FLD_ZONE!) Maybe a python script equivalent:
import arcpy
cur = arcpy.UpdateCursor("parce_test_spatial_join")
try:
for row in cur:
value = row.fld_zone
valuelist=string.split(',')
valueset=set(valuelist)
value=str(valueset)[5:-2]
value.replace('"','')
row.target_field = value # enter your own field here
cur.updateRow(row)
del cur
except :
print "failure on ",value
... View more
08-25-2010
12:55 AM
|
0
|
0
|
1903
|
|
POST
|
ArcPy is minimalist in philosophy. It is not a VBA/ArcObjects replacement (yet). You can only change a few basic properties of map elements that are in the properties dialog for an element, such as position. The suggestion is to keep a range of objects off the page in the MXD template and move the required one on to the map. If you are a wizard at ArcObjects, then anything is possible if you load the comtypes module and call ArcObjects directly. See Mark Cederholm's excellent examples. http://www.pierssen.com/arcgis/upload/misc/python_arcobjects.pdf
... View more
08-17-2010
12:15 AM
|
0
|
0
|
1459
|
|
POST
|
A very interesting thread which is raising a number of topics. 1. Storing a shape object in a dictionary I wondered how to do this too to be able to compare shapes to create a 'delta' list. I eventually used a simple property such as centroid, length or area. Bruce Harold has gone the whole hog and converted the shape to gml, after rounding all vertices, then compressing it using binascii. See his just posted ChangeDetector. http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=351BEE10-1422-2418-8815-82074A3E6B6C( By the way I challenge anyone to find this script themselves using the seach or browsing the circular menus) 2. Sorting is all very well but getting the sort field populated is the hard part. I need to have a sort field for a polyline featureclass that is to be exported to KMZ. Otherwise the tree is randomly exported after edits. So I need a route system first to be able to traverse, and even then I need to get access to the measures. This is very clumsy. My method is to build a new route (which goes into a NEW layer with no attributes -aagh) then create a new temp midpoints layer, then find the measures from the temporary route, then join that back to the original sections, so I finally have a sort field. There may be a few shortcuts at 10 to use featuresets.
... View more
08-07-2010
10:58 PM
|
0
|
0
|
1750
|
|
POST
|
I wanted to gp.Delete("table_rel") but the Delete() function or Exists() function does not even see them. I see a note that suggests that I set OverwriteOutput = True when writing them, but that doesn't clean them out of a file geoadatabase. The only option looks like a GeeWiz Basic style "poke" using ArcObjects, remember those? Can someone give me that syntax?
... View more
07-29-2010
03:19 PM
|
0
|
0
|
2711
|
|
POST
|
Which gave me the idea to try a cursor on a featureset, and that worked too! # latlong.py
# get a point from NZTM and convert to lat/long
#
import arcgisscripting
gp = arcgisscripting.create(9.3)
inFeatSet = gp.GetParameter(0)
row = gp.SearchCursor(inFeatSet,"","c:/arcgis/nzgd2000.prj").next()
lat = row.shape.centroid.Y
long = row.shape.centroid.X
gp.AddMessage(str(lat)+" "+str(long))
del row
... View more
07-28-2010
03:02 AM
|
0
|
0
|
608
|
|
POST
|
Well I suppose an in_memory featureclass is OK latlong.py
# get a point from NZTM and convert to lat/long
#
import arcgisscripting
gp = arcgisscripting.create(9.3)
inFeatSet = gp.GetParameter(0)
gp.OverwriteOutput = True
inFeatSet.Save("in_memory/pointer")
row = gp.SearchCursor("in_memory/pointer","","c:/arcgis/nzgd2000.prj").next()
lat = row.shape.centroid.Y
long = row.shape.centroid.X
gp.AddMessage(str(lat)+" "+str(long))
del row
... View more
07-28-2010
02:54 AM
|
0
|
0
|
608
|
|
POST
|
If you use the tool form setting to collect an interactive point as a featureset you get the coordinates in the current projection. I want to turn that into a WGS84 lat/long to query a web service that requires that format. The only way I can see to do this is by setting an output projection and using a cursor to write a table, then open it up again to see what happened. But the whole point of featuresets is to avoid exactly that sort of inefficiency. There (was), IS an AML function to project a point returned by &Getpoint &Map. Here is the Workstation help snippet [SHOW CONVERT <in_units> <xy> <out_units>] Returns the converted x,y coordinates from units in one specified coordinate space to units in another specified coordinate space. UNITS can be PAGE, MAP, PROJECTEDMAP, or GRAPH. The respective MAPEXTENT, MAPPROJECTION and GRAPHEXTENT must be set first.
... View more
07-28-2010
02:17 AM
|
0
|
2
|
751
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | Tuesday | |
| 1 | 3 weeks ago | |
| 1 | 03-11-2023 03:54 PM | |
| 1 | 09-15-2024 10:32 PM | |
| 1 | 03-12-2026 01:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
Tuesday
|