|
POST
|
In v9.3 I have loaded a large amount of contour data into a FGDB and would like to compress it (it's already been compacted) to get the file size down. About a minute into it, I get the error: Unknown compression error on field 'Shape' File: .\sources\GpSdcDataCompressor.cpp, line: 1734 Failed to execute (CompressFileGeodatabaseData). I have found another reference to this error here: http://forums.esri.com/Thread.asp?c=93&f=985&t=287940 Curiously this fellow was also trying to compress a FGDB with contour lines. Hmmm..... Anyone have any experience with this error???
... View more
02-03-2011
12:50 PM
|
0
|
0
|
977
|
|
POST
|
How about this script from Dan Patterson: http://arcscripts.esri.com/details.asp?dbid=14535 for doing teh convex hulls?
... View more
01-24-2011
01:28 PM
|
0
|
0
|
4652
|
|
POST
|
Oh yeah - convex hull - that's much easier, and you wouldn't have to use cursors.
... View more
01-24-2011
08:56 AM
|
0
|
0
|
4652
|
|
POST
|
An idea: Note this would only work if the line segment has only two vertices (the start node and end node), and you would have to use Python or ArcObjects to do this: 1. Extract the start/end points using the FeatureVerticesToPoints_management tool (specify the "BOTH_ENDS" parameter) 2. Buffer the points to different distances (one at 20 miles, one at 50 miles). 3. Now using the the original line segment, construct 4 new line segments that originate from the start/end nodes in a perpendicular fashion (relative to teh original line segment). Make these lines extent slightly past the buffer distance. You will then have something that looks "H" shaped. Make sure you start the new lines on the start end/nodes of the original line. This will take some math/python scripting to do. 4. Now intersect the new "sides of the H lines" with the buffers. The end nodes of the intersected lines now form the vertices of a new trapezoidal polygon. 5. Merge the buffer polys and the trapezoid, and dissolve it. 6. Presto!
... View more
01-24-2011
07:30 AM
|
0
|
0
|
4652
|
|
POST
|
True curves are evil indeed. I have had all sorts of issues with "true curve" features and many of the analysis tools. As memory serves, the buffer tool won't output true curves if you don't use the "dissolve" option... Work around: Shapefiles don't support true curves :). Sorry to say, but shapefiles are still generally faster than FGDB and certainly PGDB...
... View more
01-21-2011
09:51 AM
|
0
|
0
|
1537
|
|
POST
|
Here it is.... Like I indicated earlier, this is a pretty crude way to do this, and I'm sure there are better ways now in v10. # Description
# -----------
# This script assigns a unique identifier to features that are connected/close to each other.
# This may be useful for identifying interconnected networks of polygons or lines such as a road
# or stream networks. It is particularly useful when trying to do large single part dissolves...
# just dissolve by the unique identifier field (or in addition to other fields as well).
#
# Written By: Chris Snyder, WA DNR, 7/27/2007, chris.snyder(at)wadnr.gov
#
# Written For: Python 2.4.1 and ArcGIS v9.2 SP2
#
#Notes on input parameters:
#VARIABLE PAREMETER_INDEX PARAMETER_DATA_TYPE
#-------------------------------------------------------------------
#inLayer 0 Feature Layer
#networkIdField 1 Text (for example, "NET_ID") #new long int field that will be added
#selectionMethod 2 Text (for example, "INTERSECT") - this needs to be one of the selection keywords used in the SelectByLocation tool
#distThreshold 3 Linear Unit (for example, "1 METER") only used if selectionMethod = "WITHIN_A_DISTANCE"
# Import system modules and creates the Geoprocessor object
try:
#Import system modules and creates the Geoprocessor object (the v9.2 way)
import sys, string, os, glob, shutil, time, traceback, arcgisscripting
gp = arcgisscripting.create()
#Defines some functions used for getting messages from the gp and python
def showGpMessage():
gp.AddMessage(gp.GetMessages())
print >> open(logFile, 'a'), gp.GetMessages()
print gp.GetMessages()
def showGpWarning():
gp.AddWarning(gp.GetMessages())
print >> open(logFile, 'a'), gp.GetMessages()
print gp.GetMessages()
def showGpError():
gp.AddError(gp.GetMessages())
print >> open(logFile, 'a'), gp.GetMessages()
print gp.GetMessages()
def showPyMessage():
gp.AddMessage(str(time.ctime()) + " - " + message)
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
print str(time.ctime()) + " - " + message
def showPyWarning():
gp.AddWarning(str(time.ctime()) + " - " + message)
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
print str(time.ctime()) + " - " + message
def showPyError():
gp.AddError(str(time.ctime()) + " - " + message)
print >> open(logFile, 'a'), str(time.ctime()) + " - " + message
print str(time.ctime()) + " - " + message
#Sets a date/time stamp variable in the format yyyymmddhhmmss (example: 20060711132345)
dateTimeStamp = time.strftime('%Y%m%d%H%M%S')
#Specifies the root directory variable, defines the logFile variable, and does some minor error checking...
dateTimeString = str(time.strftime('%Y%m%d%H%M%S'))
scriptName = os.path.split(sys.argv[0])[-1].split(".")[0]
userName = string.lower(os.environ.get("USERNAME")).replace(" ","_").replace(".","_")
tempPathDir = os.environ["TEMP"]
logFileDirectory = r"\\snarf\am\div_lm\ds\gis\tools\log_files"
if os.path.exists(logFileDirectory) == True:
logFile = os.path.join(logFileDirectory, scriptName + "_" + userName + "_" + dateTimeString + ".txt")
try:
print >> open(logFile, 'a'), "Write test successfull!"
except:
logFile = os.path.join(tempPathDir, scriptName + "_" + userName + "_" + dateTimeString + ".txt")
else:
logFile = os.path.join(tempPathDir, scriptName + "_" + userName + "_" + dateTimeString + ".txt")
if os.path.exists(logFile)== True:
os.remove(logFile)
message = "Created log file " + logFile; showPyMessage()
message = "Running " + sys.argv[0]; showPyMessage()
#Attempts to check out the lowest grade license available...
if gp.CheckProduct("ArcView") == "Available":
gp.SetProduct("ArcView")
elif gp.CheckProduct("ArcEditor") == "Available":
gp.SetProduct("ArcEditor")
elif gp.CheckProduct("ArcInfo") == "Available":
gp.SetProduct("ArcInfo")
message = "Selected an " + gp.ProductInfo() + " license"; showPyMessage()
message = "Starting geoprocessing routine..."; showPyMessage()
#*****************GEOPROCESSING STUFF GOES HERE******************************
#Process: Sets some gp settings
gp.overwriteoutput = 1
#Defines the input feature layer
inLayer = gp.GetParameterAsText(0)
networkIdField = gp.GetParameterAsText(1)
selectionMethod = gp.GetParameterAsText(2)
distThreshold = gp.GetParameterAsText(3)
#Process: Tests for the existance of networkIdField - if it doesn't exists, add it
if gp.listfields(inLayer, networkIdField).next() == None:
gp.AddField_management(inLayer, networkIdField, "LONG"); showGpMessage()
else:
message = "Specified existing field type is: " + str(gp.listfields(inLayer, networkIdField).next().type); showPyMessage()
if gp.listfields(inLayer, networkIdField).next().type not in ["SmallInteger","Double","Integer"]:
message = "ERROR: Existing specified network id field type must be Long Integer, Short Integer or Double! Exiting script..."; showPyError(); sys.exit()
gp.CalculateField_management(inLayer, networkIdField, "0", "VB"); showGpMessage() #makes sure the field is nulled
#Process: Figures out how many features are in the input feature class
featureCount = int(gp.getcount(gp.describe(inLayer).catalogpath))
#Process: Figures out what the oidValue field is called
oidFieldName = gp.describe(inLayer).oidfieldname
#Process: Does a recursive select by location
featureLayer1 = "feature_layer_1"
featureLayer2 = "feature_layer_2"
identifiedFeatures = 0
networkId = 0
gp.MakeFeatureLayer_management(inLayer, featureLayer1, "")
while identifiedFeatures < featureCount:
#Process: Assign a counter
networkId = networkId + 1
#Process: Establishes a cursor in order to return a single OID of a non-identified feature
try: #this is in a try loop cause' it will fail on the last loop since networkIdField will be (hopefully) 100% populated
oidValue = gp.searchcursor(inLayer, networkIdField + " = 0 OR " + networkIdField + " IS NULL").next().getvalue(oidFieldName)
except:
message = "Breaking selection loop..."; showPyMessage()
break #break out of the loop
gp.SelectLayerByAttribute_management(featureLayer1, "NEW_SELECTION", oidFieldName + " = " + str(oidValue))
#Process: Keep selecting features until there are no more to select
count1 = 0
count2 = 1
count3 = 0
while count2 > count1:
count3 = count3 + 1
count1 = int(gp.getcount(featureLayer1))
if selectionMethod == "WITHIN_A_DISTANCE":
gp.SelectLayerByLocation_management(featureLayer1, "WITHIN_A_DISTANCE", featureLayer1, distThreshold, "NEW_SELECTION")
else:
gp.SelectLayerByLocation_management(featureLayer1, selectionMethod, featureLayer1, "", "NEW_SELECTION")
count2 = int(gp.getcount(featureLayer1))
if divmod(count3, 10)[1] == 0:
message = "Processed the " + str(count3) + "th loop of connected feature ID #" + str(networkId) + "..."; showPyMessage()
gp.CalculateField_management(featureLayer1, networkIdField, networkId, "VB")
#Process: Every 25th loop, spit out a status message (too many status messages makes the script run slow)
if divmod(networkId, 25)[1] == 0:
gp.MakeFeatureLayer_management(inLayer, featureLayer2, networkIdField + " > 0")
identifiedFeatures = int(gp.getcount(featureLayer2))
message = "Assigned identifier to " + str(float(identifiedFeatures) / float(featureCount) * 100) + " percent of the features"; showPyMessage()
#Process: Gives a final report
gp.MakeFeatureLayer_management(inLayer, featureLayer2, networkIdField + " > 0")
identifiedFeatures = int(gp.getcount(featureLayer2))
gp.MakeFeatureLayer_management(inLayer, featureLayer2, networkIdField + " = 0 OR " + networkIdField + " IS NULL")
nonIdentifiedFeatures = int(gp.getcount(featureLayer2))
message = "CONNECTED FEATURES REPORT:"; showPyWarning()
message = "--------------------------"; showPyWarning()
message = "Assigned " + str(networkId -1) + " unique network identifiers to " + str(identifiedFeatures) + " features!"; showPyWarning()
#*****************GEOPROCESSING STUFF ENDS HERE******************************
message = "Ending geoprocessing routine..."; showPyMessage()
#Indicates that the script is complete - both a visual and physical indicator...
message = sys.argv[0] + " is all done!"; showPyMessage()
except:
message = "\n*** LAST GEOPROCESSOR MESSAGE (may not be source of the error)***"; showPyError()
showGpMessage()
message = "PYTHON TRACEBACK INFO: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyError()
message = "PYTHON ERROR INFO: " + str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyError()
... View more
01-20-2011
07:02 AM
|
0
|
0
|
771
|
|
POST
|
I feel your pain... I pulled my hair for a few hours and then gave up.... Try converting something that uses .ITEM notation (i.e. using fields in the .vat or RAT or whatever they call it now). Never figured out if/how you can do it... Never found anything in the help... Anyone know how to convert something like this? somaExp = "con(" + grid + ".FIELDNAME == 1, 1, setnull(1))" FYI: You can still use the good ole' SOMA and MOMA tools in v10. You just need to also instantiate: import arcgisscripting, arcpy gp = arcgisscripting.create(9.3) arcpy.this(blah, blah) gp.SingleOutputMapAlgebra(blah, blah)
... View more
01-19-2011
10:22 AM
|
0
|
0
|
1207
|
|
POST
|
I'd like to see some functionality related to testing/examining joins as well! I'm not a v10 pro though, so maybe there is more functionality exposed there than in v9.3... It's probably a safe assumption that if a feature layer or table view has a "." in the field name, there is an active join. The table name of the table that is joined will of course have the same name as the part preceding the "." (mytable.fieldname). Not sure about the path though... Just curious but all the tools now have a "result object". Could perhaps one of the result objects from the RemoveJoin tool return the path of the join table??? Maybe one of the describe properties in v10?
... View more
01-19-2011
07:04 AM
|
0
|
0
|
1798
|
|
POST
|
Yes, but perhaps there is a case for some of these different methods of capitalizing the 1st letter in each word. I often find that many "out of the box" solutions don't do exactly what I want them to do. Just to be on the Devil's side... >>> print "1234 can't st".title() 1234 Can'T Street Pretty much any grammatical contraction (like "can't") and even some colloquialism (like "ain't" and "y'all") would suffer at the hands of any algorithm that assumed the letter following an apostrophe should be capitalized. In addition, many place names in the U.S. often have non-English derivations for example: Coeur d'Alene, Idaho (Bad Example, But Y'All Get My Drift).
... View more
01-19-2011
06:49 AM
|
0
|
0
|
369
|
|
POST
|
Seems there are many ways to skin this particular cat.
... View more
01-18-2011
06:48 AM
|
0
|
0
|
1690
|
|
POST
|
Try using the Delete_management() tool instead of the del statement: arcpy.Delete_management(my_layer)
... View more
01-16-2011
07:22 AM
|
0
|
0
|
1038
|
|
POST
|
Mustafa needs help with the new map algebra syntax (v10 syntax). I haven't gotten there yet, but... Here's the intro to the help topic though: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_is_Map_Algebra/00p600000002000000/
... View more
01-15-2011
03:01 PM
|
0
|
0
|
3740
|
|
POST
|
Apologies - I often just write the code out in the forum post without running it! This "should" work: updateRows = gp.UpdateCursor("sfora_2")
updateRow = updateRows.Next()
while updateRow:
newString = ""
for word in updateRow.MYFIELD.split(" "):
newString = word.capitalize() + " " + newString
updateRow.MYFIELD = newString[:-1]
updateRows.updaterow(updateRow) #<<< THIS WAS THE MISSING LINE!
updateRow = updateRows.Next()
del updateRow
del updateRows
... View more
01-14-2011
11:05 AM
|
0
|
0
|
1690
|
| 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
|