|
POST
|
I tried copying the example in the white paper and adapting it for my suburb aliases but haven't got it right.
<include uri="Urbanisations.xml" xpath="/def/"> This is a top level extension, so maybe that is why the xpath parameter is added to poke it into the right place. I cannot find any XML documentation on the <include> tag on the web. Here is what I tried after the other Aliases:
<include uri="NZaltSuburb.xml" >
<include uri="file://NZaltSuburb.xml"> I tried it with and without the xpath set to /def/ or /alias_list/ I copied the file into the <arcgis>/locators folder with the lot file. Cutting and pasting the contents into the file does work, but it would be nice for the customer to be able to re-run the python script for updates without having to edit the XML.
... View more
03-25-2013
05:02 PM
|
0
|
0
|
664
|
|
POST
|
Yes, that is easy to select. You just have to do your own logic with the selected sets to add or subtract until you are left with the cases you are interested in. If you can logically describe to me what you need, you can create a program to do the same. That is what makes programming so fascinating. First you select intersected features (INTERSECT), and from that subset (using a layer) you select features that are touching (BOUNDARY_TOUCHES). You can then also remove contained polygons from the selection using CONTAINS. In my case I made up a separate selection to identify a group that I did not want (touching but outside) and used an attribute selection to remove them from the intersecting and inside set. It does not matter that an operator selects other cases you are not interested in if you have already selected them out so that you know that those cases do not apply for your set. Try it interactively using the SelectbyLocation option on some samples to get the logic.
... View more
03-04-2013
11:07 PM
|
0
|
0
|
1966
|
|
POST
|
I think your problem will be that a single point does not have an extent so you cannot zoom to it. You will have to create your own extent from the point by choosing a suitable buffer rectangle and zoom to that.
... View more
03-02-2013
01:43 PM
|
0
|
0
|
761
|
|
POST
|
I used the diagrams in the help called Select By Location: graphic examples. These have nice summaries of each selection operator summaries in a set of diagrams A - M Suppose you want to exclude polygons touching on the outside (diagram I) Case I is covered in INTERSECT, BOUNDARY_TOUCHES, SHARE_A_LINE_SEGMENT_WITH Other operators do not include diagram I so you add and remove using other operators until you are left with case I. I made up a matrix of the letters so that I could see which ones to add or subtract. Since we do not want to confuse the list with features that are not touching at all, I start with an intersect subset and make a temporary featureclass. At the end I simply get the remaining keys (par_id) of the features required and make a normal SQL selection using a "KEY IN (key,key,key)" expression. This snippet of code illustrates the flaming hoops that you have to jump through compared to ARC/INFO coverage selections. Since the new data is not topologically correct I have to add a snap as well to avoid errors from sliver overlaps.
# ...snip
# get all intersections ACDEFGHIJKM (see help diagrams for letters)
arcpy.management.SelectLayerByLocation(fcLayer,'INTERSECT',gaLayer,selection_type='NEW_SELECTION')
# copy to a temp layer, snap, then remove those outside but touching
snapFC = prefix+fcAbbrev+"_snap"
arcpy.management.CopyFeatures(fcLayer,snapFC)
arcpy.management.MakeFeatureLayer(snapFC,touchLayer) # Have no selection to start
arcpy.management.SelectLayerByLocation(gaLayer,'INTERSECT',fcLayer,selection_type='ADD_TO_SELECTION')
arcpy.edit.Snap(touchLayer,[[gaLayer,'VERTEX',4],[gaLayer,'EDGE',4]])
# get outside touching to exclude DIJ (help diagram cases)
arcpy.management.SelectLayerByLocation(touchLayer,'BOUNDARY_TOUCHES',gaLayer,selection_type='NEW_SELECTION')
arcpy.management.SelectLayerByLocation(touchLayer,'WITHIN',gaLayer,selection_type='REMOVE_FROM_SELECTION')
arcpy.management.SelectLayerByLocation(touchLayer,'CONTAINS',gaLayer,selection_type='REMOVE_FROM_SELECTION')
# subtract outside touching if any DIJ (see help)
cTouch = int(arcpy.management.GetCount(touchLayer).getOutput(0))
if cTouch == 0:
arcpy.analysis.SpatialJoin(fcLayer,gaLayer, prefix+fcAbbrev,'JOIN_ONE_TO_MANY','KEEP_COMMON',"#",'INTERSECT')
count = int(arcpy.management.GetCount(prefix+fcAbbrev).getOutput(0))
if count > 0:
dCount[fcAbbrev] = count
msg = "GA %s %s %s %d" % (aggregate_area,arcpy.management.GetCount(gaLayer),fcAbbrev,dCount[fcAbbrev])
logging.info(msg)
print msg
else:
arcpy.management.Delete(prefix+fcAbbrev)
else:
lstPar = [row.par_id for row in arcpy.SearchCursor(touchLayer)]
if len(lstPar) > 0:
if len(lstPar) == 1:
expr = "PAR_ID = "+str(lstPar[0])
else:
expr = "PAR_ID in "+str(tuple(lstPar))
# print "touching outside",cTouch #,expr
# remove from list of new parcels of interest
try:
arcpy.management.SelectLayerByAttribute(fcLayer,"REMOVE_FROM_SELECTION",expr)
except:
print "error",expr
#
if int(arcpy.management.GetCount(fcLayer).getOutput(0)) > 0:
arcpy.analysis.SpatialJoin(fcLayer,gaLayer, prefix+fcAbbrev,'JOIN_ONE_TO_MANY','KEEP_COMMON',"#",'INTERSECT')
count = int(arcpy.management.GetCount(prefix+fcAbbrev).getOutput(0))
if count > 0:
dCount[fcAbbrev] = count
# tag touched GA layers
arcpy.management.SelectLayerByLocation(gaLayer,'INTERSECT',fcLayer,selection_type='ADD_TO_SELECTION')
msg = "GA %s %s %s %d" % (aggregate_area,arcpy.management.GetCount(gaLayer),fcAbbrev,dCount[fcAbbrev])
logging.info(msg)
print msg
else:
arcpy.management.Delete(prefix+fcAbbrev)
... View more
03-01-2013
10:53 AM
|
0
|
0
|
1966
|
|
POST
|
Yes, but you might have to use several operators to get exactly what you want. Look up the SelectByLocation help for some useful diagrams. I ended up having to select intersections, then snap a temporary subset, select outside or touching, then use those that are just touching or intersecting to remove from the original set. I used select by attributes using an sql query having created an expression with the touching features.
... View more
02-28-2013
06:23 PM
|
0
|
0
|
1966
|
|
POST
|
In your script parameters ask for a folder or workspace not featureclasses. Also ask for a wildcard string, default to "*". This avoids the long pathnames because you are using a workspace setting. It also removes the tedious cut and paste of hundreds of featureclasses (or shapefiles) Note that the wildcard string can be something like "B*" or even an exact match to limit the list.
import arcpy,sys
wkspace = sys.argv[1] # or arcpy.GetParameterAsText(0)
wild = sys.argv[2] # or arcpy.GetParameterAsText(1)
arcpy.env.workspace = wkspace
lstFC = arcpy.ListFeatureClasses(wild)
# process the list...
... View more
02-25-2013
10:09 AM
|
0
|
0
|
873
|
|
POST
|
When you get this sort of jungle it is best to weed out the overlaps somehow and choose the best representation. Since the data is channels, perhaps you can convert the points to 3D lines? There are some simple utilities for this or a python script can do it. you might have to convert the points to xyz points first. Is there a structure to the data that you can exploit, eg are there codes to identify cross sections or bottom of the channel and banks? Then it is easier to identify the clashes and reduces the number of points significantly. Lines are also useful as break lines if they mark an edge and will improved the shape of the channel significantly even with sparse readings away from the rivers. If you have a spot height on a hill and no other data around, find some contours or make up a ring around the boundary at the bottom of the hill to avoid interpolation jumping from peak to peak. I set up a process (maybe a model) to load all the data as lines, then build a surface and view it, then go back to edit the sources and reload.
... View more
02-09-2013
05:38 PM
|
0
|
0
|
1529
|
|
POST
|
I recommend you use the model as a documentation diagram and recode it completely in Python without using any geoprocessing tools. Each tool takes time to start and writes out a lot of temporary results. They are not designed to be iterated. Have you considered using the new geometry objects? you can use these to clip, intersect and do the operations you seem to be doing on simpler objects in memory without calling a tool. http://resources.arcgis.com/en/help/main/10.1/index.html#//018z00000070000000
... View more
02-09-2013
01:50 AM
|
0
|
0
|
3648
|
|
POST
|
There is a keyfile select custom tool in ArcScripts by Bruce Harold that does this. You might be able to manage a similar goal using the MakeQueryTable that can do a more complex database query than a simple join.
... View more
02-09-2013
01:40 AM
|
0
|
0
|
632
|
|
POST
|
There is a tool to clean up crashed objects from a MXD, called MXD Document Defragrementer. This is a fancy name for the earlier MXD Doctor. The MXD does fill up with indexes and tables from some processes such as network analysis to be huge, but for normal viewing my MXD files are less than 1MB.
... View more
02-09-2013
01:21 AM
|
0
|
0
|
950
|
|
POST
|
I doubt your are running out of memory, just overflowing the buffer that contains the list of input files. Unfortunately the input form expands every featureclass to the full path. I am guessing that you have excessively long paths so you will have a buffer length of say 100 x 100 characters = 10,000 chars which is more than a likely 8K block limit in the code. This was a problem when we used sys.argv[] to pass parameters, and the arcpy.getParameter is supposed to be unlimited. You could test this by making your paths much smaller. I always write my scripts to set a folder and a wildcard string, and then assemble the list of files without the full path in the script. Then set the workspace to the folder to execute the merge. Saves specifying the list in the input form, which is more general, but a nuisance for a special case. I have found other limits merging rasters, max 20 at a time. In that case I did a staged merge. First merge all the images in a row, then merge the rows into a block, then merge the blocks. It was easy to do from the names of the image tiles which had a good pattern. Works much faster too.
... View more
02-09-2013
01:04 AM
|
0
|
0
|
873
|
|
POST
|
I have just run out of memory with too large a dictionary containing large strings (132 chars) to update a table. The symbology classification using quantile intervals gave me an idea of the way to split using the key into equal batches of records. Here is a more useful Python function that did the job to partition the data splendidly. quantile function I was able to use this to create a list of breakpoints which then limited the dictionary size and updaterow counts to 250K each. Each step ran in a few seconds for a total time of 3 minutes for 3 million records, instead of over an hour for smaller sets. I needed to trap missing code errors.
dBreaks = {"parcel":[3272715, 3542277, 3812689, 4079535, 4350267, 4620430, 4890728, 5160184, 6770930],
"pother":[6845367, 6940090, 7017134, 7077541, 7135010, 7190427, 7248224, 7301079, 7359295]}
# ....
breaks = dBreaks[fcSource]
print breaks
for step in range(len(breaks)):
if step == 0:
expr = "PAR_ID < "+str(breaks[step])
elif step == len(breaks)-1:
expr = "PAR_ID >= "+str(breaks[step])
else:
expr = "PAR_ID >= "+str(breaks[step-1])+" and PAR_ID < "+str(breaks[step])
print "step",step,expr
e = 0
dApp = dict([(row[0],row[1]+" "+row[2]) for row in arcpy.da.SearchCursor(wsSource+"/"+fcLabel,["par_id","legal1","legal2"],expr)])
print "recprds",len(dApp)
with arcpy.da.UpdateCursor(fcTarget,["PAR_ID",fldApp],expr) as cur:
for row in cur:
try:
row[1] = dApp[row[0]]
except:
e+=1
cur.updateRow(row)
if e > 0: print "errors",e
[/URL] This only works if the key is numeric. When the key is not numeric and there is no other field to split the source and target featureclasses I copy one of the tables into the same geodatabase so that I can use the MakeQueryTable tool and then CopyFeatures immediately to a new featureclass. (You don't seem to be able to do any further processing on this strange layer.) Further processing might be FeatureToFeature to rename fields because MakeQueryTable prefixes the table name even if QualifedFieldNames is set to False.
... View more
02-09-2013
12:44 AM
|
0
|
0
|
5237
|
|
POST
|
You change the draw symbol by defining a layer with the symbol you need and use that as the schema in the parameter property. Using a tool at the start is the only way before 10.1 to interactively draw a box with python scripting unless you use .NET and ArcObjects. I have no idea how you are using TKinter inside your script, so I cannot help you further. I have used TKinter for some forms and feedback, but not to interact with the map page. I have already mentioned that the TKinter message queue is not the same as the ArcMap queue. For a much better interactive experience, use the 10.1 AddIns that allow you to have interactive control of the mouse from inside a python tool. You can have buttons in an AddIn that initiate dragging a box, in fact the Esri example in the help is exactly that. AddIns To make an AddIn you have to download the AddIn Wizard, program up a loop that watches for windows events, and responds to them. Event based programming is very different from the batch style programming used in the geoprocessing tools. Once the scripts have been written correctly and tested for syntax errors, they have to be assembled into a folder of resources and installed. Then you must restart ArcMap to test the AddIn. For any script edits you have to close down ArcMap and repeat the compilation and installation, and then re-open ArcMap. It is fairly difficult and tedious to debug. That is why I suggested you abandon Tkinter and get the rectangle first using an easy-to-program geoprocessing tool. If you want a robust and reliable process in ArcMap with interaction using the mouse then use AddIns with Python or .NET and C#.
... View more
02-03-2013
11:39 PM
|
0
|
0
|
1071
|
|
POST
|
It's a very good question, and one would expect a facility to do exactly that. Link to a nice form from ArcMap without having to redevelop the Access form. It might be possible to call up the form from a Python script using the COM interface, but I have not done it myself. I have opened Excel spreadsheets and Word documents. How to do this is well described in the book Python Programming on Win32 by Hammond. http://www.amazon.com/Python-Programming-WIN32-Windows-Programmers/dp/1565926218 I expect that if you are familiar with programming in Access you will be able to call your form from a Python script running in ArcMap. Do post a how-to if your are successful. You will need to install the win32all module which is also needed for the Pythonwin IDE. Here is an example opening a spreadsheet:
from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")
xlApp.Visible = 1
xlApp.Workbooks.Add()
... View more
02-02-2013
11:53 PM
|
0
|
0
|
2757
|
|
POST
|
Don't use a model, just create a script tool. You set a schema to define the featureclass and fields in the dialog wizard when adding the parameters to the tool. It uses that schema to create a polygon when you draw interactively. It has to exist, you are not defining a new featureclass. After you open the tool there is a hidden property to change the drawing style by right-clicking the input in the tool dialog for the template properties. It defaults to drawing a polygon, but you can change it to draw a box. It requires a line and then drag which is a bit strange but it enables you to draw a box at any angle. But you can right click again and set a horizontal property. You would use the feature to select other layers directly, I only printed the json dump and the extent to demonstrate that it is a polygon feature that can be used in other tools or in Python.
... View more
02-02-2013
11:16 PM
|
0
|
0
|
6701
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 hours ago | |
| 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 |
Online
|
| Date Last Visited |
3 weeks ago
|