|
POST
|
Can you post the full error you are receiving so we can see what has been passed that causes the error? It should look something like this. Executing: CalculateField blocks TEST_LABEL "!SOURCEID![: !TEXT_INTS! ]" PYTHON_9.3 #
Start Time: Tue Mar 04 12:48:53 2014
ERROR 000539: Error running expression: u"FA07908426251"[: u"2014" ]
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: slice indices must be integers or None or have an __index__ method
Failed to execute (CalculateField).
Failed at Tue Mar 04 12:48:53 2014 (Elapsed Time: 0.04 seconds)
You can find it under the 'Results' tab
... View more
03-04-2014
09:50 AM
|
0
|
0
|
1720
|
|
POST
|
As an aside, I find it much easier to use a dictionary in these cases. reclass_dict = {'bus': 338,
'light rail': 281,
'metro': 335,
'rail': 282,
'commuter bus': 336,
}
def Reclass(inputTansitType):
inputTansitType = inputTansitType.lower().strip()
try:
return reclass_dict[inputTansitType]
except:
return 0
... View more
03-04-2014
07:00 AM
|
0
|
0
|
2305
|
|
POST
|
Is that your entire expression? Can you take a screenshot of your field calculator window with the code you execute that returns that error? Also can you post the entire error message? And what version of ArcGIS are you using? Something isn't adding up here.
... View more
03-04-2014
06:49 AM
|
0
|
0
|
1720
|
|
POST
|
If neither of the posted samples worked for you something odd is going on with your data or how you are executing the calculator. Are you sure you are enabling Python instead of VB? What errors or messages do you get?
... View more
03-04-2014
05:11 AM
|
0
|
0
|
1720
|
|
POST
|
But surely the Arc way to do it ... Yes, you are right Neil. I had forgotten about the projectAs method on geometry objects. I haven't done much testing with it and am not sure about how efficient it is, but I imagine that it would garner the same results the OP is after. At that point the only advantage to mine is that it does not require an arc license.
... View more
03-04-2014
05:09 AM
|
0
|
0
|
6096
|
|
POST
|
Are you trying to calculate a field or create a label?
... View more
03-03-2014
01:30 PM
|
0
|
0
|
2405
|
|
POST
|
Could you post a sample of your table you are trying to calculate and the applicable field types?
... View more
03-03-2014
12:57 PM
|
0
|
0
|
2405
|
|
POST
|
If using field calculator try this. !TEXTSTRING![:int(!position!)] int() may or may not be required depending on field type of "position"
... View more
03-03-2014
12:35 PM
|
0
|
0
|
2405
|
|
POST
|
You don't need to make any edits to the makeaddin.py at all. Usually you only get that error if it is being run through an interpreter. Do you have some strange file associations with .py files by any chance?
... View more
03-03-2014
10:20 AM
|
0
|
0
|
1144
|
|
POST
|
I don't believe anything is built in that has the functionality. You can pass geometry objects and use project to change coordinate systems. Otherwise it is a fairly simple and well known formula. I have a function that works, but I am not sure where it came from. def geographic_to_web_mercator(x_lon, y_lat): if abs(x_lon) <= 180 and abs(y_lat) < 90: num = x_lon * 0.017453292519943295 x = 6378137.0 * num a = y_lat * 0.017453292519943295 x_mercator = x y_mercator = 3189068.5 * math.log((1.0 + math.sin(a)) / (1.0 - math.sin(a))) return x_mercator, y_mercator else: print('Invalid coordinate values for conversion')
... View more
03-03-2014
07:24 AM
|
0
|
0
|
6098
|
|
POST
|
You can access dict values directly as a variable of sorts using the key value, or you can assign them to independent variables. var1 = dict["key1"]
var2 = dict["key2"]
... View more
03-03-2014
05:49 AM
|
0
|
0
|
1916
|
|
POST
|
So you have a field with multiple values you want to parse into individual values? Could you give us an example of some values that field may contain? Are they space, comma, something separated values? Are they geometry objects? Or something else? Also you are using a rather odd method of accessing your row values. Is there a particular reason that you need to use the field names vs the field index to access the values?
... View more
03-03-2014
05:36 AM
|
0
|
0
|
1916
|
|
POST
|
What error are you getting? Try reading through this if you are having issues. http://docs.python.org/2/faq/windows
... View more
02-27-2014
05:09 AM
|
0
|
0
|
1831
|
|
POST
|
There were many things that changed with Python between 10.0 and 10.1. That shouldn't stop you from importing the model though. Can you post your toolbox and model?
... View more
02-27-2014
04:43 AM
|
0
|
0
|
1908
|
|
POST
|
Your pythonpath system variable is most likely set to your Python 3 version. Try following the steps in the following link, depending on how you want to resolve this. https://stackoverflow.com/questions/7472436/add-a-directory-to-python-sys-path-so-that-its-included-each-time-i-use-python I would recommend uninstalling and reinstalling your entire ArcGIS and Python installations.
... View more
02-26-2014
11:51 AM
|
0
|
0
|
1617
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|