|
POST
|
Or at least delete the in_memory output (after writting it to disk). In my experience, there is only so much space in the RAM (about 1.7 GB) before the in_memory workspace fills up.
... View more
12-14-2010
05:22 AM
|
0
|
0
|
3485
|
|
POST
|
Kim, Seems weird but I ran your edited code on my own FC (with some minor edits for the field name), It worked twice (flawlessly), and bombed 8 times with one of those bad memory errors that says something like "Can't read memory at BG55XXX05... Application must close." When it bombs it's always on the 1st attempt to read some aspect of the geometry object (where it prints the .extent property of the geom obj - I edited it to spit out the .xmin BTW). Even manually I can load the thing into the dictionary, and I start typing the '.' (as in fcDictionary[idx][fieldNameDict[shapeFieldName]].*) denoting I want a property of the geom object, and POOF. But not always, which is really weird. I will try some other stuff tommorrow (like running it on another machine). Just curious, but what type of processor do you have? I have a somewhat older (4 or 5 years) AMD Opteron, and I know that it has led to some other quirky ArcGIS-related issues in the past related to raster processing, but nothing like this... i think I am the only goofball that uses an AMD. New machine will be Intel!
... View more
12-09-2010
04:03 PM
|
0
|
0
|
1706
|
|
POST
|
Can't verify that behavior in v10, but as a work around: 1. Copy the rows you want to keep to a new table 2. Use an update cursor (the .DeleteRow method) to delete the rows
... View more
12-09-2010
07:27 AM
|
0
|
0
|
2416
|
|
POST
|
Could it be that the misbehaving featureclass isn't versioned?
... View more
12-08-2010
11:22 AM
|
0
|
0
|
1323
|
|
POST
|
No, -1 gives you the last value (which may coincidentally be the 2nd item if there are only two items). For example: list = ["a","b","c","d"] list[0] = "a" list[1] = "b" list[2] = "c" list[3] = "d" list[4] = ERROR! Index out of range... list[-1] = "d" list[-2] = "c" list[-3] = "b" list[-4] = "a" list[0:2] = ["a","b"]
... View more
12-07-2010
03:51 PM
|
0
|
0
|
11239
|
|
POST
|
You might want to explicitly be using integer values with this line: getSTAnnoSel >= "1" since you are attempting to quantitatively compare two string values (which "sort of" works BTW, but in an alphabetical sort of way). For example: >>> "3" >= "2" True >>> "2" >= "3" False >>> "3" > "20" True >>> #oh crap!!! http://forums.arcgis.com/threads/16409-Check-if-FeaturLayer-has-Selection-FAIL?p=51277&viewfull=1#post51277
... View more
12-07-2010
03:23 PM
|
0
|
0
|
1412
|
|
POST
|
Fortunately Python is very good with text manipulation. All you need to do is the "lstrip" string method (to cut off a specified character of the left side of the text string): address = "000718 Puget St. SW" newAddress = address.lstrip("0") print newAddress '718 Puget St. SW' In a Field calculator expression, it would look like this: gp.CalculateField_management(myFC, "NEW_ADDRESS", "!FUBAR_ADDRESS!.lstrip('0')", "PYTHON") or you feel invincible, you could overwrite the existing field: gp.CalculateField_management(myFC, "ADDRESS", "!ADDRESS!.lstrip('0')", "PYTHON")
... View more
12-07-2010
09:52 AM
|
0
|
0
|
1665
|
|
POST
|
In my experiences, points, simple lines (a few vertices or so), and simple polygons (again - a few vertices or so), were fine. Try this: 1) Copy the geometry object from a large polygon into a dictionary (it will let you do it). 2) Spit out the vertices Are they the same coordinates as the original FC (when you read from the FC directly)? In my adventures with this, they were not always the same, and seemed to be corrupted somehow. Also, sometimes running this code would also give me random memory errors and make PythonWin bomb. Maybe I'm doing something wrong. Can you get this to work? Like I said, point layers, and very small polygonns/lines don't seem to be a problem, but test it on a "real" FC: #THIS CODE LOADS A FC INTO A PYTHON DICTIONARY IN RAM (AT LEAST IT SHOULD)
import arcgisscripting, sys
gp = arcgisscripting.create(9.3)
fc = r"D:\csny490\overlay_20100115\gis_layers\county.gdb\county" #THE INPUT FC
#Process: Build a field list and a mini dictionary to look up the field order (aka index) given a field name
fieldList = gp.listfields(fc)
fieldIndex = 0
fieldNameDict = {}
for field in fieldList:
fieldNameDict[field.name] = fieldIndex
fieldIndex = fieldIndex + 1
#Process: Load the fc into a dictionary
fcDictionary = {}
oidFieldName = gp.describe(fc).oidfieldname
searchRows = gp.searchcursor(fc)
searchRow = searchRows.next()
while searchRow:
oidFieldValue = searchRow.getvalue(oidFieldName)
fcDictionary[oidFieldValue] = []
for field in fieldList:
fcDictionary[oidFieldValue].append(searchRow.getvalue(field.name))
searchRow = searchRows.next()
del searchRow
del searchRows
#Print the values of OBJECTID = 1
print fcDictionary[1]
#Print the "COUNTY_NM" field value of OBJECTID = 1
print fcDictionary[1][fieldNameDict["COUNTY_NM"]]
#Print the extent rectangle of OBJECTID = 1
print fcDictionary[1][fieldNameDict[shapeFieldName]].extent
#Print the coordinate pairs of OBJECTID = 1 (assuming it is a single part feature)
shapeObj = fcDictionary[1][fieldNameDict[shapeFieldName]]
pointArray = shapeObj.getpart(0)
pointObj = pointArray.next()
while pointObj:
print str(pointObj.x) + ", " + str(pointObj.y)
pointObj = pointArray.next()
... View more
12-07-2010
08:11 AM
|
0
|
0
|
1706
|
|
POST
|
When calcing a field in a vat from a joined table via Python (v93), you must first: 1. Create a table view from the vat table. 2. Join the vat to the lookup table 3. CRITICAL: Select all the records (this is bag and is specific to vat tables). Use the SelectByAttribute tool - leave the SQL blank , and specify "SWITCH_SELECTION", or something to get all the records selected. 4. Calc the field 5. Remove the join
... View more
12-06-2010
11:18 AM
|
0
|
0
|
1451
|
|
POST
|
A regular "Text" field type should be fine, and no, you are not limited to 50 characters - that is just the default (i.e. "suggested") value. The max character limit will be different depending on the database type (FGDB vs Oracle vs Shapefile/dbf vs PGDB). I think there may be more elaborate ways to store formatting (page breaks, indents, bullets, etc.) using a BLOB field type, but I don't know much about that. If it's just a "note", I think just a regular text field would work fine though.
... View more
12-06-2010
06:48 AM
|
0
|
0
|
886
|
|
POST
|
Try changing: phrase1 = "\"Line_No\" =" + str(LineNo) + " AND \"Station_No\" > " + str(FromStation) phrase2 = "\"To_Station\" <=" + str(ToStation to this: phrase1 = "Line_No = " + str(LineNo) + " AND Station_No > " + str(FromStation) phrase2 = "To_Station <= " + str(ToStation) Thhat is, get rid of all the \s
... View more
12-03-2010
01:07 PM
|
0
|
0
|
1496
|
|
POST
|
Anyone know why the an ESRI geometry object isnt transferable (at least in an uncorrupted format) to a Python dictionary???
... View more
12-03-2010
11:29 AM
|
0
|
0
|
1706
|
|
POST
|
If you want to write new data to the table you would need to use an update cursor (not a search cursor). Also, you have to use cursor syntax, not field calculator syntax.
... View more
12-01-2010
09:52 AM
|
0
|
0
|
11239
|
|
POST
|
Two ideas that don't really relate to your code structure directly: 1. Copy the FCs locally to a FGDB (e.g. your C:\ drive). Network/SDE = slow, local FGDB = fast. 2. If possible, store the "i" features/attribute values in a dictionary object. This would eliminate the need for the embedded cursor (which I have found to be very slow). In your code I see that for each parcel you open up a whole gaggle of cursors for the "i" FCs. This would be way faster if all this stuff was in a hash table of some sort. Unfortunately, I have had mixed results loading the geometry objects (the shape field) into a Python dictionary in v9.3. I found that for simple geometry it seemed to always work, but more complicated shapes it seemed to get corrupt somehow... See: http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30010&viewfull=1#post30010 and http://forums.arcgis.com/threads/9555-Modifying-Permanent-Sort-script-by-Chris-Snyder?p=30024&viewfull=1#post30024 Once something is in a dictionary (assumingly uncorrupted) it seems to be the fastest method of emulating embedded cursor behavior (hundreds/thousands of times faster). It has worked out extremely well for me using tabular data, but the shape stuff is different story... Maybe this is fixed (or at least works better) in v10? Also, maybe improvements could be made to the looping structure, but I don't know your data well enough... What exactly is your work flow? For each parcel see if it intersects any of the other "i" FCs, right? Would a looping SelectByLocation work the same?
... View more
12-01-2010
07:35 AM
|
0
|
0
|
2247
|
|
POST
|
Not sure if it would help in this case, but the .fidset property of a featurelayer that contains selections is a pretty usefull thing. Basically it just returns a delimited string of all the OBJECTIDs that you have selected. Perhaps in the cursor then, you could cross refernce the cursor with the OBJECTIDs in fidSetList. For example: fidSetList = gp.describe(featureLayer).fidset.split(",") #Note: the feature layer has to have a selected set
... View more
11-29-2010
03:20 PM
|
0
|
0
|
591
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-25-2014 12:57 PM | |
| 1 | 08-29-2024 08:23 AM | |
| 1 | 08-29-2024 08:21 AM | |
| 1 | 02-13-2012 09:06 AM | |
| 2 | 10-05-2010 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|