|
POST
|
Python, like most programming languages, uses the period as the decimal separator regardless of what your local language uses. Try this: def reclass(ALTITUDE):
if ALTITUDE == 39.99:
return 40
else:
return ALTITUDE
... View more
09-26-2012
02:46 AM
|
1
|
0
|
633
|
|
POST
|
It's always a bit of a confusing hassle to manage multiple installations of the same software on one machine, I'm constantly running into this myself on 64 bit systems where I have 64 and 32 bit installs of the same thing, or the fact that TortoiseHg uses its own local Python, etc. For further reference/esoterica, the two source files that drive the sys.path in Python 2.7.2: http://hg.python.org/cpython/file/8527427914a2/PC/getpathp.c http://hg.python.org/cpython/file/8527427914a2/Python/pythonrun.c Follow the PySys_GetPath() calls to get some idea of what's going on.
... View more
09-24-2012
12:15 PM
|
0
|
0
|
1581
|
|
POST
|
Try str(self.params[0].value) or self.params[0].value.value in the validator.
... View more
09-24-2012
11:52 AM
|
0
|
0
|
2136
|
|
POST
|
I'm more that a little curious about the motivations for needing to know this and dubious that it matters, but I'll indulge you: 1. There are some entries in the sys.path in both setups that I honestly don't see where they came from. The first one in the lists above came from my PYTHONPATH, and the the last three are in the .pth file in site-packages. Where did all the others entries come from? From the bootstrapping process Python does when it first initializes itself in the process. There are other places Python looks (%PATH%, %PYTHONPATH%, registry keys, site.py and sitecustomize.py). Additional bin directories are injected in the path in the CPython code based on the current path. 2. There are some imports (sys, arcpy) that the ArcMap python window has loaded already. Where did that happen? When the Geoprocessing framework bootstraps itself to run Python scripts. It imports some commonly-used modules for script tools/Field Calculator that users tend to forget to import just as a courtesy. 3. The ArcMap python prompt is picking up some paths from somewhere mysterious (in italic above) The same items would be found in python.exe if it didn't know to short-circuit that process. Since the working directory of python.exe is c:\python27\arcgis10.1, it knows to ignore the bin dircetories of other Python 2.7 installs it finds. When it's running embedded in another program such as arcmap.exe, it isn't necessarily as sure as to which install is canonical so it errs on the side of inclusiveness. Again, look in the registry and environments in addition to where you've looked already 4. In all setups, what's up with the path: C:\WINDOWS\system32\python27.zip. That file does not exist in my install. Legacy reasons. It's part of Python itself. I'm sure it's deprecated by now, I think as the current bootstrap process was being refined it was a part of it. Basically you can place a python27.zip in that location and fill it with .py files and they will show up as importable modules. For instance, you can place a site.py or sitecustomize.py in there that sets the sys.path and you'd get a uniform sys.path across the board in all places. (cp - reformatted)
... View more
09-24-2012
11:45 AM
|
0
|
0
|
1581
|
|
POST
|
Why not just put the import at the top of updateParameters? Python's smart about how it imports modules and if it's already imported it once it'll stay in memory and won't take any time at all if it hits another import line later for the same thing. What version of ArcGIS are you using?
... View more
09-24-2012
11:32 AM
|
0
|
0
|
2136
|
|
POST
|
I have never, ever heard of that behavior occurring at all in the UI. What version of ArcGIS are you using? I suppose it would make sense to export your model (or at least just this part) to a Python script.
... View more
09-24-2012
11:24 AM
|
0
|
0
|
1898
|
|
POST
|
.value will be a semicolon delimited string. If you use the .values attribute (note the plural), it will be a list instead, which is likely what you want. We couldn't make .value return a list for backwards compatibility reasons.
... View more
09-24-2012
08:16 AM
|
0
|
0
|
2209
|
|
POST
|
Are you viewing the text file in Notepad? Windows usually uses \r\n (and not just \n) in most places for its line break marker. Some text editors will interpret both as a new line, but they are in the minority. The solution is just "Hello\r\n" instead of "Hello\n"
... View more
09-23-2012
10:41 AM
|
0
|
0
|
1898
|
|
POST
|
Use the not operator. layer.visible = not layer.visible
self.checked = layer.visible
... View more
09-12-2012
11:34 AM
|
0
|
0
|
1008
|
|
POST
|
You can't use input or raw_input in the Python window in ArcMap. If you'd like to manage user input, rewrite your script as a Python script tool. If you're using the Python window as a learning tool, try using another one like Idle instead.
... View more
08-30-2012
12:57 PM
|
0
|
0
|
503
|
|
POST
|
Expression: Reclass(!LUCode!, !LU_2005!)
Codeblock: def Reclass(LUCode, LU_2005):
if LU_2005 == "AG":
return "Pasture"
elif LU_2005! == "ST":
return "Urban"
else:
return "???" Python uses == for equality, and you can't use !Field!s in the codeblock.
... View more
08-29-2012
02:48 PM
|
0
|
0
|
652
|
|
POST
|
add_to_map = arcpy.env.addOutputsToMap
arcpy.env.addOutputsToMap = False
... Your code ...
arcpy.env.addOutputsToMap = add_to_map
... View more
08-21-2012
08:15 AM
|
0
|
0
|
1339
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-26-2012 02:46 AM | |
| 2 | 01-06-2011 08:22 AM | |
| 1 | 03-25-2014 12:18 PM | |
| 1 | 08-12-2014 09:36 AM | |
| 1 | 03-31-2010 08:56 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:22 AM
|