|
POST
|
You have your workspace set to your output directory. You need to fully qualify your path to your input data in the tool or change the workspace to your input directory and retain the fully qualified path to your output. Also instead of or, or, or you can do this. if dayofweek in [0, 1, 2, 3, 4]: Or this if dayofweek in range(5):
... View more
01-08-2013
04:33 AM
|
0
|
0
|
2231
|
|
POST
|
You have to pass it from the calculation expression as a variable. def GetVector(shape, xorigin): x0 = xorigin y0 = 2 x1 = 3 y1 = 4 a = [x0, y0] b = [x1, y1] vecsum = [a[0] + b[0], a[1] + b[1]] return vecsum[1] GetVector(!Shape!, !xorigin!)
... View more
01-08-2013
04:27 AM
|
0
|
0
|
944
|
|
POST
|
Nulls are a little tricky. You could give something like this a try. if not ID or not OPER_MAINT_LEVEL:
return SYMBOL
... View more
01-07-2013
10:45 AM
|
0
|
0
|
1199
|
|
POST
|
I think you want to do this. def myfunc(SYMBOL, ID, OPER_MAINT_LEVEL):
if ((ID == "4648" and OPER_MAINT_LEVEL == "1 - BASIC CUSTODIAL CARE (CLOSED)") or
(ID == "4663C" and OPER_MAINT_LEVEL == "1 - BASIC CUSTODIAL CARE (CLOSED)")
(ID == "4654")):
return 4
else:
return SYMBOL
... View more
01-07-2013
09:16 AM
|
0
|
0
|
1199
|
|
POST
|
Hello, this looks very close to what I'm trying to do, and failing at. Instead of hard-coding the values "BLOCKSTAGE", "OID", etc., I'm wondering if there is a way to get those values from a list of fields in another fc. In other words, I'd like to check against one fc and then and then delete any duplicate fields before I merge the two. Thanks for any help you can offer. Adam I'm not sure I follow 100% but something like this should get you on your way. You may need to switch around which field list you loop through and which fc you are deleting from. fc_target = #fc1
fc_merge = #fc2
fc_target_fields = [field.name for field in arcpy.ListFields(fc_target)]
fc_merge_fields = [field.name for field in arcpy.ListFields(fc_merge)]
dropFields = list()
for field in fc_target_fields:
if field in fc_merge_fields:
print "Adding field to drop list %s" % field
dropFields.append(field)
arcpy.DeleteField_management(fc_target, dropFields)
... View more
12-20-2012
07:03 AM
|
0
|
0
|
1237
|
|
POST
|
Thanks for the response, that works. Well it did until our IT group decided to change somethings. Now the feature classes in the staging database are all prefixed. So an example is in staging MGISSP.GISONEAST.PERM_ABA_Roads and the same feature class in Prod is MGISP.GISONEAST.PERM_ABA_Roads. Notice the difference at the beginning, staging is MGISSP and prod is MGISP. As a result your solution doesnt work any longer. Any other ideas? Again thanks for the help! The solution for such an issue is very simple using python and string replacement. If you are going to be using python scripts and tools in a production setting I'd recommend you learn the basics of python so you understand what your tools are doing. Here's a good place to start. http://docs.python.org/release/2.6.5/library/stdtypes.html?highlight=.replace#str.replace
... View more
12-20-2012
04:16 AM
|
0
|
0
|
2095
|
|
POST
|
1. I'm using ArcGIS 10.0 SP0 The first thing you'll want to do is install the latest service pack. There are a host of issues that have been resolved and this could very possibly be one. http://support.esri.com/en/downloads/patches-servicepacks/view/productid/160/metaid/1876
... View more
12-19-2012
04:33 AM
|
0
|
0
|
1881
|
|
POST
|
The page size property of mxds are read only in arcpy. You would have to set these manually, or use ArcObjects.
... View more
12-18-2012
09:31 AM
|
0
|
0
|
1425
|
|
POST
|
Ah yes you'll need to manipulate the types a little. You are trying to do both string and math operations on the same data. def lat( dms ): deg = float(str(dms)[0:2]) min = float(str(dms)[2:4]) sec = float(str(dms)[4:6]) dd = deg + (min / 60) + (sec / 3600) return dd
... View more
12-18-2012
06:20 AM
|
0
|
0
|
1465
|
|
POST
|
Looks like just minor errors. 1. Need a colon after your function statement. 2. Reference the variable you pass containing the field value. def lat(dms): # need to add colon
deg = dms[0:2]
min = dms[2:4]
sec = dms[4:6]
returnVal = deg + (min / 60) + (sec / 3600)
return returnVal
... View more
12-17-2012
12:36 PM
|
0
|
0
|
1465
|
|
POST
|
arcpy.env.workspace will pull this for you from your python window in ArcGIS. Edit: Nevermind, doesn't work when you specify your default gdb.
... View more
12-17-2012
09:46 AM
|
0
|
0
|
544
|
|
POST
|
Your smtp error is most likely due to your server listening on a different port than default. To correct for this you will have to specify which port you want to connect to. Have you tried installing Python using the default settings? Your paths indicate you had a previous version of python installed prior to installing ArcGIS or used some other customization for your python install. Are you sure you are on version 2.6.5?
... View more
12-17-2012
06:28 AM
|
0
|
0
|
1396
|
|
POST
|
I am brand new to Python as of today. I cannot believe that ESRI is replacing VBA with full intellisense for this silly DOS window thing. Anyway, if I run this code in the Python window in ArcMap:
def happyBirthday(person):
print("Happy Birthday " + person + ".")
happyBirthday('emily')
It runs fine. But then when I run this code:
import arcpy, os
def prinnames(sPath);
import arcpy, os
folderPath = sPath
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
if os.path.isfile(fullpath):
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mxd = arcpy.mapping.MapDocument(fullpath)
print(mxd.title)
prinnames("C:\Gareth\mystuff")
I get this error: Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 2) But then, when I try to go back and paste the exact same code back into the window that ran before (The "Happy Birthday" test code), it won't run, instead it gives me the exact same error it had before (Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 2)) So why is it doing this? Looks like you are using a semi-colon instead of a colon in your first line. Not sure why it won't run the previous code afterwards. def prinnames(sPath);
... View more
12-13-2012
11:54 AM
|
0
|
0
|
1699
|
|
POST
|
Is Category another field? If so you will need to pass it to the function.
... View more
12-13-2012
11:34 AM
|
0
|
0
|
1047
|
| 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
|