POST
|
Hello Xander, Thank you very much for the time, effort and input, I greatly appreciate it. It is working now. The issue I was having was it was running through the loop without doing the copying data from one feature to the other. When I fixed that it worked like a dream. Again, thanks for all your help and the help of the others. Regards, Warren
... View more
04-03-2018
05:19 PM
|
1
|
1
|
698
|
POST
|
In this case, it would be updateFieldsList = ["BSB_Text", “Value”] as per the example data I sent through. Warren
... View more
03-28-2018
04:25 PM
|
0
|
0
|
698
|
POST
|
Hello Richard, What I am trying to do with the script below is take the DemandWeight column in the Facilities layer to the Value column in the ABN layer, using the BSB as the primary key. Regards, Warren
... View more
03-28-2018
04:19 PM
|
0
|
4
|
698
|
POST
|
I will send through some of the data. I know it is not working as the end result are null values (every row), not 0. Also most of the data are zero’s as to get this Model working I have decreased the number of rows drastically. The first part of the script is a network analysis location-allocation model. Regards, Warren
... View more
03-28-2018
04:10 PM
|
0
|
2
|
698
|
POST
|
Hello Richard, Thanks for that. I have done a join in arcmap to make sure they match up, and they do. Not sure if this is anything, but when I do a print of the dictionary and of the KeyValue This is what I get: Dictionary: {u'3923': 0.0, u'3920': 0.0, u'5259': 0.0, u'4023': 0.0, u'6725': 0.0,…. KeyValue: 2003 2006 2010 2013 So the four digit numbers are in both, but maybe it is the format of the dictionary? I am hesitant to add data, but if it will make it easy for you to help, I will clean it up and attach some. Regards, Warren
... View more
03-28-2018
03:49 PM
|
0
|
9
|
698
|
POST
|
Thanks for the Reply Richard, I am in training all day today but will get back to you tomorrow. Appreciate the response. Warren
... View more
03-27-2018
02:00 PM
|
0
|
1
|
1526
|
POST
|
Not sure that is the problem actually. Even when I hard code the attribute, to test if the data is carried from DemandWeight to the Proposed Attribute, it does not work. So my issue might be somewhere else. Will have a look. I get no errors, just no data passes through to the new attributes. The dictionary data definitely has the desired attribute. Warren
... View more
03-26-2018
05:43 PM
|
0
|
13
|
1526
|
POST
|
Hello Xander, Appreciate the help. This is my issue and it is the last step! Below I am adding a variable weightfldval which is the attribute for the new table. This changes as per a loop earlier, and works fine. The issue is where I create the updateFieldsList = ["BSB_Text", ?????] If I use weightfldval, then nothing happens, the data is not transferred . So I have the scenario where the columns have been create, just like I want, but nothing is transferred over from the DemandWeight of the FacilitiesOutput. Let me know if this does not make sense. Appreciate any help. Again. Regards, Warren #with the sublayer names as the keys subLayers = dict((lyr.datasetName, lyr) for lyr in arcpy.mapping.ListLayers(outNALayer)[1:]) FacilitiesSubLayer = subLayers["Facilities"] Process: Add Field (2) arcpy.AddField_management(ABN, weightfldval, "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") print("Added field to ABN_Opp_Metrics_Homeloan") #Create new Facilities FC arcpy.management.CopyFeatures(FacilitiesSubLayer,FacilitiesOutput) print("Facility Class Created") Transfer of a Single Field Value between Feature Classes sourceFC = r"C:\xxx\xxx\Scratch_Workspce.gdb\FacilitiesOutput" sourceFieldsList = ["Name", "DemandWeight"] Use list comprehension to build a dictionary from a da SearchCursor valueDict = {r[0]:(r[1:]) for r in arcpy.da.SearchCursor(sourceFC, sourceFieldsList)} updateFC = r"C:\xxx\xxx\Scratch_Workspce.gdb\ABN " updateFieldsList = ["BSB_Text", ?????] with arcpy.da.UpdateCursor(updateFC, updateFieldsList) as updateRows: for updateRow in updateRows: store the Join value of the row being updated in a keyValue variable keyValue = updateRow[0] verify that the keyValue is in the Dictionary if keyValue in valueDict: transfer the value stored under the keyValue from the dictionary to the updated field. updateRow[1] = valueDict[keyValue][0] updateRows.updateRow(updateRow) del valueDict print "Finished script: " + strftime("%Y-%m-%d %H:%M:%S")
... View more
03-26-2018
04:05 PM
|
0
|
0
|
1526
|
POST
|
Brilliant, thanks for that. Have been looking for a while.
... View more
03-25-2018
08:50 PM
|
0
|
0
|
1526
|
POST
|
Thanks very much for this. Both useful, especially the Turbo charging one. I have been racking my brains to get this sorted, and it looks like you have provided it. Thanks again. Regards, Warren
... View more
03-25-2018
08:19 PM
|
0
|
16
|
1526
|
POST
|
Hello All, I have a python script which creates a join between two layers. I am then trying to use calculate field to take the data from one column (DemandWeight) and adding it to another column. However, the other column is made up from a variable so cannot be hard coded. For example, I have a variable called weightedvalue made up from attributes from another table. So after the join I have NetworkLocations.weightedvalue. But the message I get is that is not an actual column name. it is looking for the actual enbedded coIumn name. I also tried NetworkLocations.%weightedvalue% but does not work either. The weighedvalue changes as per a loop. Any ideas would be appreciated
... View more
03-25-2018
07:06 PM
|
0
|
20
|
3489
|
Title | Kudos | Posted |
---|---|---|
1 | 04-03-2018 05:19 PM |
Online Status |
Offline
|
Date Last Visited |
01-29-2024
05:16 AM
|