|
POST
|
Woops - yes the expression must be in a string format of course, so arcpy.CalculateField_management(inFeatures, 'COUNT', 'str(!F2011_TRAF!) + str(!FLAG!)', 'PYTHON') is correct.
... View more
05-01-2013
07:55 AM
|
0
|
0
|
3312
|
|
POST
|
Sorry - per your actual question: No, there's nothing wrong with the way you are adding the "COUNT" field that I can see.... Unless you already have a field called "COUNT"... Shapefiles do have a limit on the field name lenth (10 character max), but you are not exceeding that... Also, there are a handfull of "reserved" field names you cannot use since they mess with the underlying RDBMS stuff. Forget what those are off the top of my head, but I verified that "COUNT" was not one of them (at least for shapefiles).
... View more
04-30-2013
02:09 PM
|
0
|
0
|
3312
|
|
POST
|
Do you mean join (as in a tabular join) or string concatenattion (as in join the text strings 'A' and 'B' so that the new value is 'AB')? I think you mean the latter, so try something like: arcpy.CalculateField_management(inFeatures, 'NEWFIELD', str(!FIELD1!) + str(!FIELD2!), 'PYTHON') The Python .join method is for Python-specific strings, which is very different than the ArcGIS tabular concatenation I think you wanting to implement. For example: list = ["A","B","C"]
print "-".join(list)
>>> A-B-C BTW: You second to last line in your code: arcpy.CalculateField-management needs to be arcpy.CalculateField_management (underscore not a dash). Also, I see you have cleaned up your path names - that's looks way better! Although if I were you, I would get rid of the '4_MAPPING_DATA_SUPPORT' name (don't start a folder name with a number)! If you are interested, here's some aditional unsoliced 🙂 advice pertaining to GIS naming conventions: http://forums.arcgis.com/threads/21526-Trouble-with-Feature-Datasets-in-directories-with-spaces?p=139246&viewfull=1#post139246
... View more
04-30-2013
01:46 PM
|
0
|
0
|
3312
|
|
POST
|
I could be wrong, but I'm 99% sure you need to use the Project tool (using the xy event layer as input) to properly apply datum transformations for xy event layers. Note that for whatever reason you cannot use the in_memory workspace as an output workspace for the Project tool, but you can use the scratch workspace (arcpy.env.scratchGDB). Another option would be to apply the coordinate/datum transformation directly to the coordinates in your .csv file wth the Convert Coordinate Notation tool. See: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000tw000000 According to the help, this tool will pick the "correct" datum transformation for you.... Perhaps the Make XY Event Layer tool does this also, but I'm not sure...
... View more
04-29-2013
09:28 AM
|
0
|
0
|
2610
|
|
POST
|
schema locks Surefire way to clear schema locks: If you are or ever have looked at the contents of the scratch workspace with your current ArcMap session, close ArcMap and reopen it. If you are or ever have looked at the contents of the scratch workspace with your current ArcCatalog session, browse to another workspace/directory and hit F5. If you are or ever have looked at the contents of the scratch workspace with Python via arcpy, close your Python IDE, and reopen it.
... View more
04-29-2013
09:00 AM
|
0
|
0
|
1238
|
|
POST
|
BTW: You might find the "in_memory" workspace another (maybe better) option for what you need http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002w0000005s000000
... View more
04-29-2013
08:20 AM
|
0
|
0
|
1238
|
|
POST
|
Looks like you just need to include a path seperator (i.e. "\\") So instead of: lclImplsblRd = env.scratchGDB + "SAP_IMPLAUSIBLE_READS" use one of these: lclImplsblRd = env.scratchGDB + "\\SAP_IMPLAUSIBLE_READS"
lclImplsblRd = os.path.join(env.scratchGDB, "SAP_IMPLAUSIBLE_READS")
lclImplsblRd = env.scratchGDB + os.path.sep + "SAP_IMPLAUSIBLE_READS"
... View more
04-29-2013
08:18 AM
|
0
|
0
|
1238
|
|
POST
|
Any schema locks? From the help: "An exclusive lock is required to modify a geometric network's connectivity rules, add a feature class to the geometric network, or delete a geometric network. An exclusive lock can only be acquired for a geometric network if the feature classes that participate in the network can also be locked. Therefore, if a user has an exclusive or shared lock on any of the feature classes in a geometric network, then the properties of the geometric network can't be edited." I've never built/managed a Geometric Network via Python, but as a last resort you could probably drop the network, add your features, and then rebuild... or just use the "old" python cursors (assuming they work).
... View more
04-24-2013
04:05 PM
|
0
|
0
|
1482
|
|
POST
|
import arcpy flayer = "AADT" alayer = "AADTAnnoLabel" Seems like you need to better define the paths to your inputs. Also, are you sure the fields you are attempting to sort exist in the input tables? Are you sure these are the actual field names and not just aliases?
... View more
04-23-2013
12:16 PM
|
0
|
0
|
1573
|
|
POST
|
You are setting the workspace to your feature dataset 1st (in order to list the FCs there) right? If you have v10.1 SP1, I have found the new arcpy.da.walk function to be very handy: http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000
... View more
04-23-2013
10:35 AM
|
0
|
0
|
4042
|
|
POST
|
Cursor-based "queries" are quite a bit different than a SQL query where you can use wildcards and what not. Try this: Instead of: if assembly in requiredAssemblies: use if requiredAssemblies in assembly: However, this might not be a good idea since it is what they call "implicit" and not explicit. For example: "j" in ["j","k","l"] >>> True "j" in "sonja" >>> True I think what you really want to know is if there is a "J","K", or "U" as the 1st letter in the assembly code, correct? This would be a more explicit expectation than just wanting to know if, for example, the letter "J" occurs somewhere in the assembly code, which is what my 1st code example is doing. How about something like: for assembly in assemblies:
if assembly[0] in requiredAssemblies:
assemblyIssue = False The [0] indicates the 1st character (index 0) in the assembly text variable. An index of [-1] would then be the last character, and you can use "composite" indicies like this: print "Mickey"[1:-1] >>> icke
... View more
04-23-2013
10:13 AM
|
0
|
0
|
1235
|
|
POST
|
What specific part of your code are you having trouble with? It seems that the code you provided should work, or at least seems like a decent outline for what you are trying to do. Judging from the paths you are using in your code and the general nature of your question, I'm pretty sure this is homework of some kind, but since I know what a UM5 and C1 is (!), I'll try to help you out.
... View more
04-23-2013
08:48 AM
|
0
|
0
|
1235
|
|
POST
|
Use the "traditional cursor method" shown here: http://forums.arcgis.com/threads/82818-quot-Search-Cursor()-got-an-unexpected-keyword-argument-sort_fields?p=291755&viewfull=1#post291755 Since you are using v10.0, you cannot use the named parameter feature. Upgrade! v10.2 will be out in June...
... View more
04-23-2013
08:33 AM
|
0
|
0
|
2194
|
|
POST
|
If you are using the old cursor model (the non-data access kind), you will need to use the .getValue method if your field name is a variable. So for example: fieldName = "TEST"
valueList = []
searchRows = arcpy.SearchCursor(myFC)
for searchRow in searchRows:
valueList.append(searchRow.getValue(fieldName))
del searchRow, searchRows If you want to use the newer data access cursor model (only available in v10.1+): fieldName = "TEST"
valueList = []
searchRows = arcpy.da.SearchCursor(myFC,["*"])
for searchRow in searchRows:
valueList.append(searchRow[searchRows.fields.index(fieldName)])
del searchRow, searchRows
... View more
04-23-2013
08:28 AM
|
0
|
0
|
3195
|
|
POST
|
The Shape_Area and/or Shape_Length fields are not auto-populated when using the in_memory workspace. You have to populate then manually if you want to run a query against them, or you can of course use the row's shape object .area and/or .length properties in a cursor. If you want to stay away from cursors, do something like this: arcpy.CalculateField_management("in_memory\\test", "ACRES", "SHAPE.AREA@ACRES", "PYTHON")
... View more
04-22-2013
03:15 PM
|
0
|
0
|
3296
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-25-2014 12:57 PM | |
| 1 | 08-29-2024 08:23 AM | |
| 1 | 08-29-2024 08:21 AM | |
| 1 | 02-13-2012 09:06 AM | |
| 2 | 10-05-2010 07:50 PM |
| Online Status |
Offline
|
| Date Last Visited |
08-30-2024
12:25 AM
|