|
POST
|
The featureset is part of the ArcGIS toolbox parameters. It does not use TKinter at all. Your code attempts to use objects only available using a full AddIn. http://resources.arcgis.com/en/help/main/10.1/index.html#//014p0000001q000000 You can use Tkinter to draw rectangles on a Tkinter window, but not the ArcMap window, so the coordinates will not be transformed to map units. The message queues between ArcGIS and TKinter are also not the same. That is what AddIns are for. Then you do have access to the ArcMap message queue and can detect all the mouse events such as the code you have pasted. My solution is for the case when you want to select a box interactively at the start and then run a script, not using the AddIn objects. Since you can add a script tool as a button, this is almost equivalent to Avenue tools we were use to, and it is easy to implement. http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Feature%20sets%20and%20record%20sets The Esri example concentrates on modelbuilder, but it can work in simple tools just as well. Create a tool and add a parameter. Set it to featureset. Set a schema that is a polygon featureclass. When you run the tool, open the properties to set drawing rectangles Draw one or more rectangles and start the tool In your script collect the polygon featureset entered interactively when the tool is run This is just like an on-the-fly featureclass but in memory # DemoBox
# draw a box interactively and report extent
import arcpy
fSet = arcpy.GetParameter(0)
desc = arcpy.Describe(fSet)
# print a JSON representation, version 10.1
arcpy.AddMessage(str(desc.pjson))
# print the extent of each box version 9.3+
for row in arcpy.SearchCursor(fSet):
arcpy.AddMessage(str(row.shape.extent))
... View more
02-01-2013
05:29 PM
|
0
|
0
|
6706
|
|
POST
|
Well, everything is moving (again) to ArcGIS.com "The Resource Center Galleries are changing. Please upload your content to ArcGIS Online-the single place to share maps, apps, and tools. If you're unsure how to share within ArcGIS Online, follow this step-by-step guide to uploading." Will people move their stuff (again)? Who knows... As a quick test - Does my recent share work? It does! Installed on 10.1 very nicely. Very timely considering that Bing Maps are being discontinued. Replaced with Esri imagery which is even lower resolution in my country. Google imagery is much better everywhere. Cities are sourced from aerial imagery. Are we all expected to build AddIns for publishing? It does work well for beginners, but not hackers who want to share techniques. I tried a search on "Python" and got a lot of studies on the real snake - but no code!
... View more
01-28-2013
01:00 AM
|
0
|
0
|
2104
|
|
POST
|
At the start of a script you can use the FeatureSet input type in a dialog. You need to have a template featureclass to refer to, in this case a polygon, as a layer to define the symbol to draw. Then when you run the tool you can interactively draw one or more polygons or rectangles just like using the draw tools. In the script you can pick up the geometry object if it was the first parameter and use it
inRecSet = arcpy.GetParameter(0) This has been available since 9.3 You would have to run the tool again to repeat. If you want more control then 10.1 AddIns will give you access to the message queue of mouse clicks, and tracking. But AddIns are significantly more trouble, so try the featureset first.
... View more
01-28-2013
12:43 AM
|
0
|
0
|
6706
|
|
POST
|
The selected features definition is part of the layer properties. All you are doing is counting the number selected before you delete them. Selected features from a featureclass can be defined by a definition expression and a selection set that is arbitrary There is an arcpy.Describe() property FIDSet that will enable you to get a list of selected FID's that you can build into a set then invert the set and make a new layer definition, but it is a bit geeky. You have to manipulate a list of FIDs and use an SQL query with a list.
... View more
01-20-2013
06:22 PM
|
0
|
0
|
2208
|
|
POST
|
Have a look at PIL (Python Image Library) module. http://www.pythonware.com/products/pil/. I have used this extensively at 8.x and 9.x to compensate for problems in ArcMap image handling.
... View more
01-17-2013
12:32 AM
|
0
|
0
|
726
|
|
POST
|
It sounds more like an edge problem than a donut problem. If you are using a projection there is a lot of validation and clipping going on behind the scenes that may be deleting your 0,0 point. Could you try making a point at (0.001,0.001) to see if that works? You also have to be careful to add the points in the expected clockwise order for the outer ring and anticlockwise for the donut ring. Running RepairGeometry afterwards cleans up these issues, so it might be there, but just not drawing. The help for this tool is useful to browse to see a simple list of topology rules that you need to be aware of when writing a polygon from source coordinates.
... View more
01-17-2013
12:21 AM
|
0
|
0
|
1004
|
|
POST
|
Correction: I note that the ? metacharacter is not supported in regular expressions in the locator.
... View more
11-26-2012
12:01 AM
|
0
|
0
|
1902
|
|
POST
|
I have simple scripts that sometimes report a file lock and when I run them again immediately, just run normally. It is very hard to make some processes give up the file locks. At 10.1 it has been suggested in the technical sessions to use the 'with' construct which is guaranteed to close cursors instead of relying on garbage collection after a del cursor. Any other hints and experiences?
... View more
11-22-2012
12:35 AM
|
0
|
0
|
7035
|
|
POST
|
Time to move to loading the data and transforming it with FME (otherwise disguised as the Data Interoperability Extension) No scripting required, much better performance, easy to debug, the ETL standard tool for good reason.
... View more
11-12-2012
11:22 PM
|
0
|
0
|
3670
|
|
POST
|
You might look at the standard logging module which handles calling other modules seamlessly, but still writes to a log file.
... View more
11-12-2012
11:12 PM
|
0
|
0
|
2210
|
|
POST
|
The space is a valid character and the questionmark is a metacharacter. So <space>? means an optional space character in the regular expression. You cannot put an encoded html string in a regular expression to mean a space because only metacharacters defined for regular expressions have a meaning other than their literal value. ' ' means exactly those 5 literal values. The one regular expression will match postcodes with or without an included space, but it won't score unless it finds the exact string in the reference point field. To get a score you would have to have aliases (and set up postcodes to have aliases) or simply duplicate every point with the alternative postcode format. You can include the generated alias XML file using an XML include statement as page 74 of the white paper. Can't Canada decide on a standard postcode format? 8-) It is very hard to debug the geocoder, but I have found if you match a few records and then use the AddressInspector to rematch, you can see how the address is being parsed on the right hand side. This has given me clues such as street types in a name being parsed as units. eg Green Valley Road ended up as Green Valley, Unit Road
... View more
11-12-2012
10:52 PM
|
0
|
0
|
1902
|
|
POST
|
I have just had a thought to combine the datetime stamp in a model. You could export the model to a script and paste in a message after each tool. This is not the way I recommend to learn Python scripting, it is machine generated code that is hard to read.
begin = datetime.datetime.now()
# the tool
arcpy.AddMessage("tool took "+str(datetime.datetime.now() - begin)) There may need to be a bit of tweaking of the code to make it run as a script, watch for layers, not featureclasses as inputs.
... View more
11-09-2012
01:40 PM
|
0
|
0
|
3455
|
|
POST
|
What about this simple expression to include an optional space? <def name="GenZIP">
<alt ref="Postcode" />
</def>
<def name="Postcode">
<alt>
`[a-zA-Z][0-9][a-zA-Z] ?[0-9][a-zA-Z][0-9]`
</alt>
</def> I am worried about the large alias problem for performance. What takes so long? Are you using an include statement or are you actually pasting in the alternatives? Do you duplicate the reference features to handle the same (only different by a space) postcodes? The key point is that the reference data has to have both forms, all the geocode does is score them when found, based on the regular expression filter. Placename alias tables are really for use with a set of Vanity Addresses. These are well known landmarks used instead of a real address. The alternative way to handle these would be to create a composite locator with the placenames as points and keep the real address as an alternative field. They are not really designed for parsing address components for matching and scoring.
... View more
11-09-2012
11:53 AM
|
0
|
0
|
1901
|
|
POST
|
You have to create a layer object from the pathname and then specify the DataFrame that you are adding the layer object into. import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
addLayer = arcpy.mapping.Layer(r"C:\Project\Data\Orthophoto.lyr")
arcpy.mapping.AddLayer(df, addLayer, "BOTTOM")
... View more
11-09-2012
11:32 AM
|
0
|
0
|
1118
|
|
POST
|
Maybe reduce the resolution of your DTM? Does it need to be so dense? I found that a background hillshade for my maps works much better at 80m instead of 20m cells even though the contours can create a 20m DTM. I have tasks that take a day to complete, they contain many steps too. I am never happy if a tool takes more than a few minutes. Many tools need to be more scaleable. If it takes too long I look carefully to see why and change it if possible. Often it is inconvenient to use a different package inside a workflow, but Python enables that more easily. Esri developers are aware of the worst areas and you can see their efforts to fix some by building-in partitioning at 10.1 In the meantime you just have to abandon slow tools if you have large datasets to process. Yes, I do think that on-the-fly syncing will cause the processes to be disk-bound, and even worse, network bound. Similarly many people find that a virus checker (Norton comes to mind) that checks each new file created for a virus will cripple geoprocessing. Using modelbuilder style of chaining tools creates a lot of intermediate featureclasses which require a lot of disk read/writes. That is something that you can often minimise by recoding in Python. There are lots of list processing functions that run in memory that can be substituted for temporary geoprocessing featureclasses that are being used as a temporary set for selection. Dictionaries, Lists, Sets are all very efficient, as is the numpy module for raster and other analysis using matrices. There are many modules that can be used instead of tools. ET GeoTools are my favourite for alternative geoprocessing tools. How to profile modelbuilder? I would run each tool interactively and look a the elapsed time. In my python scripts I print out the time after each gp tool, sometimes to a log file using the logging module. import datetime
starttime = datetime.datetime.now()
# .. do something
print datetime.datetime.now() - starttime
# this does all the date arithmetic to print an elapsed time When a tool takes too long I try to fix it or otherwise replace it with a different process. Why should we accept ArcGIS processes to be slower than equivalent ARC/INFO workstation tools? Surely it is just poor programming? Maybe brought on by object oriented methods rather than geo-relational operations. If I can accelerate a process in an interpreted Python substitute that must say something about Microsoft .NET structures. The COM interface environment can be very flexible, but not if used to call each feature. Similarly if each write to a database is committed that will slow performance dramatically, but with simple tools you have no choice.
... View more
11-09-2012
10:54 AM
|
1
|
0
|
3455
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | yesterday | |
| 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 |
yesterday
|