|
POST
|
import win32api
win32api.MessageBox(0,"msgbox", "title")
win32api.MessageBox(0,"ok cancel?", "title",1)
win32api.MessageBox(0,"abort retry ignore?", "title",2)
win32api.MessageBox(0,"yes no cancel?", "title",3)
You can use the Windows API to popup messages and store the response. Have a look in the Pythonwin help for additional tools. You can also use Tkinter (standard library) to create a full dialog. See the example to create a scrolling list to supplement the data driven pages tool on the Resource Centre. Python Selection Script with Tkinter User Interface http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=F0B54854-1422-2418-A0F6-37042FE94472
... View more
11-29-2010
12:43 PM
|
0
|
0
|
1287
|
|
IDEA
|
Tabular data from a GPS has more than lat and long, so it would be great if the Z and M values could be loaded at the same time. The previous samples tools did allow for these point options. The new tool to create polylines from points has to have the Z and M values in the points (not just attributes) to be able to generate a 3D line or a linear reference route. But the XY events does not load them. I was able to modify this script to use the Z and M values to build a route system many times faster than using calibrate routes. Maybe this tool should also have the option to load Z and M from attributes as well. After all who creates points with measures?
... View more
11-29-2010
03:44 AM
|
14
|
1
|
737
|
|
POST
|
It's a good question we all ask ourselves every day. I have the "Cup of Coffee Rule". -If any single process takes longer than a cup of coffee, then interrupt the process and Find a Better Way. I don't bother to run any process for days, it will not be likely to produce anything useful, as you have found. Too much is done in memory, then virtual memory, then paging to disk and then there is none left to write out the results. This happens to me when I try to create a large XY event table from a route, but it only takes an hour to crash! I watch the CPU spinning with no I/O. Its obviously a very poor algorithm. I'm not quite sure why you are using a spatial join, presumably using the interactive join tool? Have you calculated the likely size of that output? 250,000 x 250,000 = 6.25E10 ! Yes, it would be a good idea to limit the comparisons to a buffer if you can. It's a worry that you cannot get a process to work on a sample of 35,000 polygons. That should work in minutes, so you are missing something.To just give you a benchmark time I ran a union between 33,000 parcels with a 428,000 polygon landcover dataset as the hardest process I could think of with similar sizes. That gives me a parcel-landcover combined set of polygons with all attributes for further statistical summary in 5 minutes. Tune your PC. I have a similar machine, but I know that 8 CPU's are irrelevant, only one is used. Do you have heaps of virtual memory on a separate disk in a contiguous partition, or even better a dedicated disk for it? Do you have a local scratch workspace defined as a file geodatabase (not just a folder). Have you got a RAID 0 array running at 10,000RPM? Is there plenty of free disk, unfragmented. Since the process is equivalent to an old clean, you probably still need 13 times the space of the source before starting. Is all your data in local file geodatabases, not on a network or in SDE? Dragging data across to do analysis is likely to be unsuccessful. Tune your data. Have you run a Repair Geometry on the data first? Check for uniform size of polygons. If there are some very large ones, split them up. At 10 there is a dice tool to automate this. Do you have multi-part polygons? These are a great evil for geoprocessing. Explode them first. Be reasonable with your requests. ArcGIS does not often warn you if you have not thought through the task. You might get a hint that a join does not have an attribute index, but not that you do not have a spatial index or simply multiplying the two sets to give you a predicted output size. If I can recast my problem into a simpler one which does not requires polygon splitting then I do. eg Will a point in polygon do? Extract one layer as centroids. Not the same, but maybe good enough. Finding a better way would be to use another Python module or another tool such as FME.
... View more
11-28-2010
11:29 PM
|
0
|
0
|
2722
|
|
POST
|
There is a better way to sort points for labelling. The technique uses a Peano curve to sort the points into a snakes and ladders type of route where the next number is always near the last. This is similar to the way that we used to number labels on polygons when we used to digitise by hand! The Peano Curve is an option on the ArcGIS 10 sort (data management) tool. It basically comes up with a single index for the x,y pairs that is a very useful figure to sort a point cloud so that you can easily find any point if they are sequentially numbered.
... View more
11-15-2010
01:58 AM
|
1
|
0
|
1655
|
|
POST
|
Maybe it is a bug? NIM060284 - The Point class constructor arguments m and z are reversed. fixed in 10 SP1
... View more
11-11-2010
04:16 PM
|
0
|
0
|
597
|
|
POST
|
You can directly calculate DMS using the calculate geometry interactive tool on a table in ArcMap. The trick is to create a TEXT field to calculate into and you will be given more output format options. Doesn't work for a script, I know.
... View more
11-11-2010
09:50 AM
|
0
|
0
|
579
|
|
POST
|
How hard can it be?! The maths to calculate the distance between two points could use good old Pythagoras once you have the point coordinates in a list. The numbers may balloon out because the product of the two sets will often be large. To reduce this, use the Python module itertools in 2.6 to generate the permutations of the point pairs n*(n-1)/2 so that you don't measure to-from as well as from-to (n*n). To make running through lists repeatedly more efficient, load the ID,x,y for each point into a Python structure such as a dictionary. Numpy has a function to do the maths even faster than Pythagoras implemented in a script. distance = numpy.linalg.norm(x-y)
... View more
11-03-2010
12:07 AM
|
0
|
0
|
376
|
|
POST
|
If all you want is the bearing differences of vertices within a single polyline then a cursor can step through the vertices and calculate the angles like this:
# vertex_angle.py
# find change in angle along a polyline at each vertex
# assume :
# in a projected coordinate system, not dd
# don't know what to do with output, maybe add value to a point
# Kim Ollivier
# 29 October 2010
#
import arcgisscripting
import math
import sys
gp = arcgisscripting.create(9.3)
try:
inlay = sys.argv[1]
except :
inlay = "d:/work/test.gdb/wiggle"
desc = gp.Describe(inlay)
shapefield = desc.ShapeFieldName
cur = gp.SearchCursor(inlay)
row = cur.next()
n = 0
m = 0
p = 0
while row:
feat = row.getValue(shapefield)
print "Feature",n
for partNum in range(feat.partCount) :
part = feat.getPart(partNum)
ptLast = None
bearingLast = None
print "Part",m
for ptNum in range(part.count):
pt = part.next()
if ptLast:
bearing = math.atan2((pt.Y - ptLast.Y),(pt.X - ptLast.X))
if bearingLast:
delta = bearing - bearingLast
print p,delta/math.pi*180.0
bearingLast = bearing
ptLast = pt
p+=1
m+=1
n+=1
row = cur.next()
del cur,row
Otherwise getting the vertices required is a lot harder if you do not have arc-node topology available. You would have this in a coverage if you built for nodes. This provides a unique list of nodes and tags on each "polyline" for the node at each end in the attribute tables AAT and NAT. I could then run a valence script to count the number of segments at each node to assist with the angle calculations. A simple extension of the valence concept can tag nodes as sources, sinks or passthrough. I know that a network dataset has all these capabilites, but the relationships and status are not accessible for python scripting, so I build my own network attributes. To build arc-node topology that is accessible for scripting in ArcGIS there is a very good tool in ET GEOTools called RenodePolylines. To get implied nodes at a T junction, clean the layer to a temporary layer using ETGeotools CleanPolyline in the absence of workstation clean. I would make sure there were no multi-parts to complicate the calculations. It is easy to then select each node and do some angle calculations between each segment. Rather than run a buffer I would just look up the last or first point of a polyline and then step back one vertex. A useful python function math.atan2() gives the absolute bearing of two points. The next issue is to get direct access to the polyline verticies. Opening a cursor on a featureclass is not enough, so I open it once and load the parts of the featureclass into Python list and dictionary structures. After processing in double-quick time, then open an update cursor and write out the results. It all sounds like reinventing Network in Python, and it is. Maybe this could be done with C#.NET and ArcObjects? I challenge anyone with idle time to a competition!
... View more
10-28-2010
12:34 PM
|
0
|
0
|
1347
|
|
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
|
281
|
|
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
|
514
|
|
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
|
610
|
|
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
|
336
|
|
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
|
5566
|
|
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
|
1527
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-26-2025 03:48 PM | |
| 1 | 05-08-2025 02:07 PM | |
| 1 | 05-07-2025 05:13 PM | |
| 3 | 04-04-2025 03:16 PM | |
| 2 | 05-07-2025 05:21 PM |
| Online Status |
Offline
|
| Date Last Visited |
10-20-2025
06:39 PM
|