|
POST
|
Reclassify is a tricky thing - just wanted to add to the thread that to allow more than two ranges, you could put your range remaps into a single string variable like this: "start end newvalue, start end newvalue, start end newvalue" These could be converted into a Python list for the RemapRange() function: rangeText = "0 1 99, 1 2 100"
temp = rangeText.split(",") # split to two strings at the comma
temp = [k.split() for k in temp] # split each remap group into strings
temp = [ [int(j) for j in k] for k in temp] # integerize values I tested this in a Python window:
>>> rangeText = "0 1 99, 1 2 100"
>>> temp = rangeText.split(",")
>>> temp
['0 1 99', ' 1 2 100']
>>> temp = [k.split() for k in temp]
>>> temp
[['0', '1', '99'], ['1', '2', '100']]
>>> temp = [ [int(j) for j in k] for k in temp]
>>> temp
[[0, 1, 99], [1, 2, 100]]
... View more
05-10-2012
10:46 AM
|
0
|
0
|
3089
|
|
POST
|
Could it be due to some bad installation (I installed some other flavor of python after installing ArcMap.) This is only supported if you update "dot versions". For example, Python 2.6.2 to 2.6.8. ArcGIS 10 will not work correctly with Python 2.7.
... View more
05-09-2012
07:36 PM
|
0
|
0
|
2237
|
|
POST
|
Does anyone have an example on how to set this up in python (i'm using ArcGIS10) and how to set up the model parameters correctly? You could get pretty fancy with parameter validation and such, but to do it the way you're trying to would be pretty straightforward:
listString = arcpy.GetParameterAsText(3) # "[11,94,0],[95,95,1]"
# compose a line of python code and run it with exec()
exec("remap = arcpy.sa.RemapRange(%s)" % listString)
# the variable remap now has your remap range for the Reclassify tool
An easy way to get the python syntax right for complex functions like this is to run the tool interactively and then open the geoprocessing results, right click the record of your tool run, and "Copy As Python Snippet". Update: I edited this post to change my advice, but not before Amelie implemented my original suggestion (below), which was to build the lists from input text parameters with the .split() function. The reason I changed my suggesion to what is above is because the reclass input can be very complex and entering string representation of a python list and interpreting it with exec() allows for more flexibility in syntax.
... View more
05-09-2012
07:08 PM
|
0
|
0
|
3089
|
|
POST
|
Thanks i am using ver 10 as well, i used this it worked without the " ", i just wrote con(isnull(myraster.tif),0,myraster.tif) and it worked one time and that was it, it stoped again, is there any syntax error in my used format? The quotes are required if you are using the Raster Calculator tool. The text inside the quotes must either be the path to a raster (or simply its name if the raster is in the current workspace) or the name of a raster layer in ArcMap.
... View more
05-08-2012
06:25 PM
|
0
|
0
|
1479
|
|
POST
|
what I really want to do is see if a folder exists in the same folder as the script and if it doesn't then create the folder. sys.argv[0] is the path of the script. I think this is what you're trying to do: import sys import os import arcpy # create a scratch folder in the same folder as the script Here = os.path.dirname(sys.argv[0]) if not arcpy.exists(os.path.join(Here,"working"): arcpy.CreateArcInfoWorkspace_management(Here, "working")
... View more
05-08-2012
05:23 PM
|
0
|
0
|
3283
|
|
POST
|
And does anyone know why arcpy vs. manual selection would produce different counts, and/or why my arcpy results were correct most of the time, but incorrect some of the time? The tool SelectLayerByLocation and spatial joins are different algorithms. There are differences in what the tolerances used are and the algorithms. To get consistent results, you should use the same tool with the same options and tolerances.
... View more
05-08-2012
04:54 PM
|
0
|
0
|
3505
|
|
POST
|
Once a tool has started, your script cannot interact with it. The only approach I can suggest is to launch a script asynchronously using the subprocess module and check on it. Python 2.6 has a new method that allows you to kill processes in Windows in a pretty straightforward way. I think you may have better luck determining why the process is "randomly" taking a couple of hours and try to trap for that before you start the tool.
... View more
05-07-2012
03:32 PM
|
0
|
0
|
1160
|
|
POST
|
This error message occurs when you try to add a nullable field to a non-geodatabase feature class. I'm wondering if your model is working on a temporary dataset in a folder scratch workspace when previously this was a geodatabase scratch workspace. Something else I thought of is perhaps the field was there before (which makes the add field skip processing with a warning) and now it isn't there so it's now actually trying to create the field, causing the error mesage. Since the model builder is 120+ processes to do this restructuring of the table, maybe this is a good opportunity to re-engineer your process using the Merge tool with a field map (created with Calculate Value) may be a more efficient and maintainable approach then adding, dropping, and calculating fields.
... View more
05-07-2012
03:26 PM
|
0
|
0
|
2372
|
|
POST
|
I've tried Zonal Histogram many different ways for this task, and nothing works well. Outputting to a table in a file gdb worked once, but then ArcMap and ArcCatalog choke trying to export the output table to DBF. Dbase is extremely limited for large files. Microsoft Query (maybe Jet too -- used by ArcGIS) only" rel="nofollow" target="_blank">http://support.microsoft.com/kb/110601]only supports 199 fields, even though the file format supports 255. There's also that pesky 4000-byte record length, regardless of number of fields. In your case you also may be reaching the 2GB file size limit. (Note dbf is entirely uncompressed storage, a 25 character field takes up 25 bytes.) We have been warned in the help, here's the link, for the thread: Geoprocessing" rel="nofollow" target="_blank">http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002t0000000m000000.htm]Geoprocessing considerations for shapefile output
... View more
05-04-2012
03:40 PM
|
0
|
0
|
3197
|
|
POST
|
Will the debugger only help me identify where the problem is or also what the problem might be? Maybe. The debugger can be very helpful because you can step through the code line at a time and easily examine values of variables while the code is executing. For me, using the debugger is usually overkill if I have wrapped my code as above, as then I get much more complete error messaging that usually makes the problem obvious. I usually just use print statements to help me check values of variables, but that's mostly because I haven't become very skilled using debugging software. When I entered your code, Python crashed. To learn how to use try/except blocks, I'd start with a simpler test than entering the whole kaboodle above, or the examples in the online help I pointed you too. For the thread, [thread=48475]here's that code tag link, repaired.[/thread]
... View more
05-04-2012
03:23 PM
|
0
|
0
|
2424
|
|
POST
|
I have a Python script that mines a directory (and sub directories) for mxds and writes the fine names and data paths to a text file. The script works fine as a stand alone. I am trying to attach the tool to a Toolbox tool and notice some odd behavior. I have the output parameter set to type = Text File in my toolbox tool. After I fill in the input parameter (a directory) the output path is auto-completed using a .dbf file. Does anyone have any clues on how to fix this so that it defaults to a .csv or a .txt? What's your output parameter Data Type setting in the script tool properties? By default, if it is "Table", it will default to .dbf for folder workspaces. You probably want to set Data Type to "File". You can also control valid file extensions using the Filter property. Arc 10 Help: Setting script tool parameters
... View more
05-04-2012
02:30 PM
|
0
|
0
|
598
|
|
POST
|
When I run my script, Python crashes with no helpful error message. I suggest looking into the online help examples on exception handling -- these techniques can really help - for example, you can print which line the script failed on. Arc 10 Help: Error handling with Python Here's a try/except wrapped around your code that will do that:
import sys
import traceback
import arcpy
try:
# Set local environment:
Path = "E:\\MichaelBrady\\Graduate_work\\MAIN\\Classes\\spring2012\\ind_study\\nexrad\\data\\irene_nexrad\\"
Working = Path + "nexrad_Irene_Working"
arcpy.env.workspace = Working
arcpy.env.overwriteOutput = 1
# Set local variables:
NEXRAD2grid = arcpy.ListFeatureClasses()
HRAP_Projection = "PROJCS['HRAP_Projection',GEOGCS['HRAP_GCS',DATUM['D_HRAP',SPHEROID['HRAP_Sphere',6371200.0,0.0]],PRIMEM['<custom>',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Stereographic_North_Pole'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-105.0],PARAMETER['Standard_Parallel_1',60.0],UNIT['HRAP_Grid',4762.5]]"
arcpy.env.outputCoordinateSystem = HRAP_Projection
arcpy.env.extent = "-236 -1476 661 -806"
arcpy.env.cellSize = "1"
for fc in NEXRAD2grid:
desc = arcpy.Describe(fc)
filename = desc.name
NEXRADgrids = filename[:-4]
arcpy.PointToRaster_conversion(fc, "Globvalue", NEXRADgrids, "MAXIMUM", "NONE", "1") #execute point to raster
print NEXRADgrids
except:
# print python errors
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
print tbinfo
# print geprocessing errors messages (if any)
print arcpy.GetMessages(2) PS Please tags when posting Python code.
... View more
05-03-2012
07:20 PM
|
0
|
0
|
2424
|
|
POST
|
With your picture this makes more sense to me what you're trying to do. Just using the elevation as your cost surface won't do what you want?
... View more
05-02-2012
10:43 AM
|
0
|
0
|
2978
|
|
POST
|
I am fairly sure that I have followed the steps from the guide, but the result is not what you say it should be, nor do I understand how it should be possible. I suggest experimenting with the path_type argument to the Cost path function.
... View more
05-02-2012
10:39 AM
|
0
|
0
|
2978
|
|
POST
|
That is where I found the "AttributeError: object has no attribute '_arc_object'" error being called. Looking at the error message, I'm wondering if it's recognizing your layer LayerSite - though you'd think it would fail on your check check = LayerSite.supports("DEFINITIONQUERY") Might want to run this one by support.
... View more
05-02-2012
10:26 AM
|
0
|
0
|
403
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-11-2021 01:26 PM | |
| 5 | 12-10-2021 04:58 PM | |
| 1 | 02-27-2017 09:30 AM | |
| 2 | 12-04-2023 01:05 PM | |
| 1 | 04-12-2016 10:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
06-19-2024
12:10 AM
|