POST
|
Hi Matt, If you specify the coordinate system when creating the polygons (lines 51 and 53 of your original code) it appears to work... print arcpy.Polygon(array, coordinateSystem).pointCount cursor.insertRow([arcpy.Polygon(array, coordinateSystem)] + attributes) Let me know how you get on. Stacy
... View more
01-13-2014
02:04 PM
|
1
|
0
|
968
|
POST
|
I think you need to add it to your system path, check this post for more info: http://pythongisandstuff.wordpress.com/2013/07/10/locating-python-adding-to-path-and-accessing-arcpy/ Also ff, when attempting to install an additional library to Python, you receive an error stating that the correct Python version is not found in the registry: Download the package source (usually a .zip file, not specific to any Python version) Unzip the package Open a command prompt within the package folder and run: python setup.py install where python is the Python you want to install the library to. If it is not on the path (either temporarily or permanently) you must supply the full path to it.
... View more
01-13-2014
01:14 PM
|
0
|
0
|
1008
|
POST
|
The index increasing was to get the next layer for your report to be created on, previously you were creating the exact same report four times, you need to change one of the inputs to the report export tool, my guess is that it was the layer. It may be the data frame which changes...? Can you run the process manually in Arc? I mean, open the tool, select the same inputs and output locations and run it. Does that work correctly? If it does, open the Results window (Geoprocessing menu > Reults), right click on the just-completed operation and select Copy as Python snippet. You can then paste this into your editor and check that it looks the same as what you have... If that doesn't work, hopefully someone who has experience with this tool sees this post, I am out of ideas!
... View more
12-10-2013
01:52 PM
|
0
|
0
|
575
|
POST
|
I have a few guesses: C:\CAD tables backup\CAD tables working\Reports\Wells.rlf file doesn't exist C:\CAD tables backup\CAD tables working\CAD tables\ folder doesn't exist C:\CAD tables backup\CAD tables working\CAD tables\Wells.xls file already exists I also note that your code attempts to export the exact same thing four times; shouldn't the index increase, like so: mxd = arcpy.mapping.MapDocument(r"C:\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[0]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells.xls")
###
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[1]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells2.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells2.xls")
###
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[2]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells3.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells3.xls")
###
lyr = arcpy.mapping.ListLayers(mxd, "Wells", df)[3]
arcpy.mapping.ExportReport(lyr,
r"C:\CAD tables backup\CAD tables working\Reports\Wells4.rlf",
r"C:\CAD tables backup\CAD tables working\CAD tables\Wells4.xls")
... View more
12-09-2013
09:59 AM
|
0
|
0
|
575
|
POST
|
Glad you found the answer. Your initial post would suggest to me that the message from the tool was the problem at that point in time. Multiprocessed workers can't really write output in the normal way. What I typically do is pass a string along with the results that contains any useful information.
... View more
12-05-2013
10:29 AM
|
0
|
0
|
1522
|
POST
|
Calculate field calculates the values for all rows, unless there is a selection on the layer... You possibly need an update cursor...? I still don't entirely understand what you are doing, but maybe this will help: arcpy.CalculateField_management(input ,"NAME", "%s" % name , "PYTHON") The difference is that name is a variable in your script, the CalculateField can't really access it in the normal way (or at all, which might be causing your error). The line above is simply setting the field to a string, and the string is defined within the script, so it will update with each x. If this doesn't answer your question please post an explanation of your desired output versus what is actually coming out (you did this part last time, but I still don't know how that differs from what you are after).
... View more
12-03-2013
10:17 AM
|
0
|
0
|
475
|
POST
|
The problem is with the composite locator! For some reason they work from Model Builder but fail from Python scripts, here is a previous forum post regarding this: http://forums.arcgis.com/threads/81528-Python-crashes-running-stand-alone-script-composite-locator-AGS-10.1-SP1-desktop I forgot about that until your last post, which allowed me to isolate where the error is occurring (before any of the tests can even start). You have three options: get hold of a different ArcGIS version; seems to be OK in 10.2 SP1 make your process not require a composite locator, by doing a series of individual locators, each time selecting addresses that haven't been geocoded (into a feature layer) use the Parallelised Composite Geocoding script I developed (posted here), which will do the same thing as a composite locator but can make use of multiple CPUs I am happy to help out if you want to do number three - it would be good for it to have some testing! The green comment section at the top of the code should explain all the inputs required. If you download the script you can then add it as an import at the top of your script and call it.
... View more
12-03-2013
10:07 AM
|
0
|
0
|
536
|
POST
|
Seems like you are on the right track, although it may be possible to do something with regular expressions too (unfortunately I do not understand them enough to know if they will help). Something like this should do what you want: d = {'TJMaxx': ['TJ Maxx', 'TJ Max', 'TJX', 'TJMaxx']} SearchTerm = 'TJ Maxx' selected = None # iterate through dictionary, seeing if term in sub list for k in d: if SearchTerm in d : selected = k if selected is not None: ## do something else: ## report invalid entry It is potentially inefficient in that it has to search through all entries of the dictionary, but even with a hundred thousand retailers it takes less than 0.1 seconds to perform the search on my rubbish computer (with a million it takes about a second). If you were really worried about the search efficiency you could index the dictionary into a list, like so: d = {'TJMaxx': ['TJ Maxx', 'TJ Max', 'TJX', 'TJMaxx']} # make lists of value, key pairs as items in separate lists l = [[],[]] for k in d: for i in d : l[0].append(i) l[1].append(k) SearchTerm = 'TJ Maxx' # search for item in list, return 'key' value if SearchTerm in l[0]: selected = l[1][l[0].index(SearchTerm)] ## do something else: ## report invalid entry Creating the list takes about five times longer than searching the dictionary, but searching the list takes half the time of searching the dictionary. This means if you can find a way of only creating the list once per time you use the tool (rather than once per search entry), or create the list, print it, then hard code it (instead of the dictionary) you will be able to increase the efficiency. If you change the inputs you will need to recreate the list....
... View more
12-02-2013
12:25 PM
|
0
|
0
|
980
|
POST
|
Updated so it will now write a file to c:\CrimeMap_output.txt. It will add a description for each test before running it and note when each test is complete. You can change the file location by modifying the outTxtFile variable in the code. Please explain exactly how you are running the code.
... View more
12-02-2013
11:32 AM
|
0
|
0
|
536
|
POST
|
Can't see anything obviously wrong with it. Are you running it from the command line, or within ArcMap as a python tool? Does it spit out any information, or just crash? I have tidied it up (Model Builder produces pretty awful code), can you run it now and tell me if it fails too? I also added an arcpy.AddMessage() which will tell you the current test it is running, so you can establish if it is one particular test that is causing the problem...
... View more
11-28-2013
11:43 AM
|
0
|
0
|
536
|
POST
|
Here is a post on from blog describing another way to do it, using smtplib. http://pythongisandstuff.wordpress.com/2011/09/06/arcpy-sending-a-result-email/
... View more
11-17-2013
10:21 AM
|
0
|
0
|
1225
|
POST
|
Hello, I've got a very simple add-in that's just a drop-down menu that updates one attribute for the selected polygon. Whenever I open the keyboard shortcuts window, or, ever since I upgraded to 10.2, even click on the drop down menu containing the commands, I get an error of this type: TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: 'assign_269' object is not callable I have about 60 classes/buttons that all look like thatone, just the particular code is changed from 101 to some other number. Reading the traceback it appears you are trying to access (call) assign_269, but this has not been created. You need to go through your code and check it has been created the same way as the other classes.
... View more
11-05-2013
12:03 PM
|
0
|
0
|
224
|
POST
|
The 'Export to Excel' model tool mentioned here: http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2010/08/10/Working-with-Microsoft-Excel-in-ArcGIS-Desktop.aspx and available here: http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=95009B25-1422-2418-7FB5-B8638ECB2FA9 doesn't work with ArcGIS 10, as it relies on the old arcgisscripting library. I have fixed it up to use the new arcpy package, attached. Remember you will need to download and install the xlwt package, available http://pypi.python.org/pypi/xlwt, for Python to be able to export to Xls. If your Xlwt installation fails, check out my post in this thread: http://forums.arcgis.com/threads/34418-Is-it-possible-to-install-other-Python-distributions-on-top-of-the-ArcGIS. I have only tested it on one file, and haven't tested the CSV output, so let me know if you have any issues. There is an issue with this tool if you have 64 bit background geoprocessing installed. The tool may not allow you to select XLS output, forcing CSV. This is because the Tool Validator class does not use the same Python as the geoprocessor, it will use the old 32 bit version which may not have xlwt installed and thus the tool thinks it cannot use xlwt. The simplest workaround would be to install xlwt to the 32 bit Python also...
... View more
11-05-2013
12:00 PM
|
0
|
0
|
880
|
POST
|
Does anyone have suggestions for tweaking the export feature to allow creation of multiple sheets within a single workbook? I I am looking for a solution to this issue as well. Is it possible to append multiple attribute tables into a single worksheet? Or will this re-write the worksheet each time it's called? This is not a trivial change. Xlwt lets you write multiple sheets at one time. However to write sheets to the same workbook at different times you need to do the following: read in the existing workbook (using xlrd) add the new sheet delete the old workbook save the updated workbook with the old workbook name. This is a known issue, and may not be worth the effort of the above workaround. Your other option is to pass multiple tables to the tool in the first place, which lets it write all the tables at once to the same workbook before saving it. I am just not sure how to pass a bunch of tables to the tool; I think I remember seeing an option somewhere to have a list of tables/feature classes as a parameter input, but I cannot find it now. Alternatively you could define (say) 10 inputs, and have the tool ignore additional tables if no value is entered. This would be a pain if you wanted to do a larger number of tables, but may cover most bases. Let me know if you are interested in this, and I can code it up.
... View more
11-05-2013
11:55 AM
|
0
|
0
|
880
|
POST
|
The tool did not immediately work for me. I get: Traceback (most recent call last): File "C:\Users\rob\Documents\ArcGIS\RobToolBoxes\Scripts\tabletoexcel.py", line 85, in <module> export_to_xls(dataset_name, output_file) File "C:\Users\rob\Documents\ArcGIS\RobToolBoxes\Scripts\tabletoexcel.py", line 58, in export_to_xls worksheet = workbook.add_sheet(os.path.split(dataset)[1]) File "C:\Python26\ArcGIS10.0\lib\site-packages\xlwt\Workbook.py", line 345, in add_sheet raise Exception("invalid worksheet name %r" % sheetname) Exception: invalid worksheet name u'ACS_TransportGreaterPortland_byCBG' Completed script TableToExcel... Failed to execute (TableToExcel). Failed at Wed May 29 12:02:05 2013 (Elapsed Time: 9.00 seconds) Seems like you can't have a sheet name longer than 31 characters, the name you used is 34 characters. The sheet name is derived from the dataset name, as you can see here in the Traceback: worksheet = workbook.add_sheet(os.path.split(dataset)[1]) You could either change the name of your input dataset or change above line to: worksheet = workbook.add_sheet(os.path.split(dataset)[1][:31]) which will truncate the name to 31 characters (by removing characters after the 31st).
... View more
11-05-2013
11:33 AM
|
0
|
0
|
880
|
Title | Kudos | Posted |
---|---|---|
1 | 03-02-2012 11:29 AM | |
1 | 01-13-2014 02:04 PM | |
1 | 09-26-2011 02:52 PM | |
1 | 10-23-2013 05:23 PM | |
1 | 04-01-2012 08:16 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|