|
POST
|
I suggest that you have a look at the logging standard library module. This is easy to setup to record each use of the tool into a separate file for later review.
... View more
10-23-2010
08:18 PM
|
0
|
0
|
352
|
|
POST
|
The easiest way is to use the existing [ARCINFO Licence] ArcTool CalculateEndTime which moves the next rows datetime to the previous row. Then you can use simple subtraction to get the difference. If you look up the python datatype for datetime you can see that you can show the interval in any units. If you have not got an ArcInfo licence, then a short python script would get around this meanness. Read the dates in in sort order with a key and put in a dictionary. Then write out the dates using the dictionary as a lookup.
... View more
10-20-2010
05:37 PM
|
0
|
0
|
685
|
|
POST
|
Use the tool DataManagement>Features>MinimumBoundingGeometry. This will create polygon rectangles with attributes for the max length and orientation without coding.
... View more
10-08-2010
09:55 PM
|
0
|
0
|
805
|
|
POST
|
Use the numpy module , already included in ArcGIS 10 import numpy
a = numpy.array((xa,ya,za))
b = numpy.array((xb,yb,zb))
diagDist = numpy.linalg.norm(a-b)
... View more
10-08-2010
09:51 PM
|
0
|
0
|
446
|
|
POST
|
Try turning of the ArcGIS Desktop Index Service. This has been a strange fix, but proven for this error message. (Use Google desktop indexing for searching if you need to search)
... View more
09-28-2010
02:27 AM
|
0
|
0
|
6545
|
|
POST
|
There is a soft interrupt. Click on the Pythonwin icon in the tray at the bottom of the screen and you will get an option "break into running code" that will do a soft interrupt, very useful if you have got into a loop by forgetting the row = cur.next().
... View more
09-27-2010
03:27 AM
|
0
|
0
|
1863
|
|
POST
|
You must have a strange installation. The os module works for me without any hacking. My pythonpath is set to C:\arcgis\bin (which I am not all that comfortable with) but I don't seem to need to set it to c:\python25\lib as well to work as a script. The os module behaves at 10 for me as well.
... View more
09-27-2010
03:15 AM
|
0
|
0
|
2503
|
|
POST
|
Load the ElementTree module. This is very helpful to parse XML files of metadata. Here is an example where I read in an old metadata file, fiddle with the dates and rewrite it. # LoadMetadata.py
# with altered dates for current month
# using element tree
# create original Metadata with same name as layer
# run this to alter to name_et.xml
# reload into filegeodatabase
# Note there is no tool to unload metadata
# 15 March 2010
import arcgisscripting,sys,os
import elementtree.ElementTree as ET
import sys,os,datetime
print
print
def alter(xmlfile,edDate,publishDate,createDate) :
"""
read xml file for featureclass or table
change dates to today,loading date and extract date
empty processing logs
write out file with _et suffix
return file name
"""
print xmlfile
tree = ET.parse(xmlfile)
## print tree.getroot().tag, tree.getroot().text,tree.getroot().tail,tree.getroot().attrib
# Edition Date
elem = list(tree.iter("resEdDate"))[0]
# print elem.tag,elem.text
elem.text = edDate
## print elem.text
# Reference Date 001 (Creation)
elem = list(tree.iter("refDate"))[0]
# print elem.tag,elem.text
elem.text = createDate
## print elem.text
# note there may be two of these dates
# DateTypCd 001 and 002
# Reference Date 002 (Publication)
if len(list(tree.iter("refDate"))) > 1 :
elem = list(tree.iter("refDate"))[1]
# print elem.tag,elem.text
elem.text = publishDate
else :
print "skipping publication date",xmlfile
## print elem.text
# clear out lineag if it exists
try :
lin = list(tree.iter("lineage"))[0]
# print lin.tag
lin.clear()
lin.text = "Cleared"
except :
gp.AddMessage("skipping clear lineage")
outfile = xmlfile.replace(".","_et.")
tree.write(outfile)
return outfile
# ---------------------- main ----------------------
try :
publishDate = sys.argv[1]
createDate = sys.argv[2]
if createDate == '#' :
createDate = publishDate
gp.AddMessage(publishDate+type(publishDate))
except :
today = datetime.datetime.now()
firstSat = today.replace(day=1) + datetime.timedelta(5 - datetime.datetime.now().replace(day=1).weekday())
publishDate = firstSat.strftime("%Y%m%d")
createDate = publishDate
# override
publishDate = '20100804'
createDate = '20100710'
gp = arcgisscripting.create(9.3)
os.chdir("e:/crs/metadata")
edDate = str(datetime.datetime.now().date()).replace("-","")
edDate = '20100914'
gp.AddWarning(edDate+" edit date")
gp.AddWarning(publishDate+" publish date")
gp.AddWarning(createDate+" create date")
ws = "e:/crs/corax.gdb"
metasrc = "e:/crs/metadata"
gp.Workspace = ws
os.chdir(metasrc)
print
print ws
print metasrc
print
lstFC = gp.ListFeatureClasses("*")
for fc in lstFC :
# print fc
fcxml = metasrc+"/"+fc+".xml"
if os.path.exists(fcxml) :
etxml = alter(fcxml,edDate,publishDate,createDate)
gp.MetadataImporter_conversion (etxml,fc)
print fc,"updated"
else :
pass
print etxml,"not found"
lstTab = gp.ListTables("*")
for tab in lstTab :
# print tab
tabxml = metasrc+"/"+tab+".xml"
if os.path.exists(tabxml) :
etxml = alter(tabxml,edDate,publishDate,createDate)
gp.MetadataImporter_conversion (etxml,tab)
print tab,"updated"
gp.AddMessage(tab+" updated")
else :
pass
print etxml,"not found"
gp.AddError(etxml+" not found")
... View more
09-27-2010
02:51 AM
|
0
|
0
|
935
|
|
POST
|
I have a rule that any process that takes longer than a "cup of coffee" should be interrupted and a better way found. Multiple ring buffer is a particularly difficult process because it is a script that repeats the problem many times. You problem is likely to be inappropriate data. Can you get a single buffer to work? Buffers can be miss-applied if you have the wrong tolerances and over complex source that you are buffering. You can easily end up with millions of intersections that have to be resolved, and eventually after an hour the process runs out of memory. There is a good presentation by Dale Honeycutt and al "Overlay and Proximity" technical workshop http://proceedings.esri.com/dvd/uc/2009/uc/tws/workshops/tw_715.pdf that explains what happens in a buffer_dissolve. Start with a very simple shape and get that working. Experiment with simplifying the source first and make sure it finishes in seconds. Then try the multiple buffer.
... View more
09-27-2010
02:32 AM
|
0
|
0
|
723
|
|
POST
|
I am told that there was a deliberate decision to not create one for 10.0. We are supposed to use the intellisense for syntax and the help documentation. I miss the 9.3 diagram, I found it a helpful quick reference. Maybe we can set up a request on ideas.arcgis.com and vote for it for 10.1?
... View more
09-18-2010
01:48 AM
|
0
|
0
|
774
|
|
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
|
700
|
|
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
|
1241
|
|
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
|
1241
|
|
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
|
1664
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-15-2024 10:32 PM | |
| 1 | 03-12-2026 01:10 AM | |
| 1 | 03-13-2026 08:30 PM | |
| 1 | 03-13-2026 05:17 PM | |
| 1 | 03-12-2026 05:14 PM |
| Online Status |
Offline
|
| Date Last Visited |
03-13-2026
05:04 PM
|