POST
|
So effectively if there are 10 rows with same caseID in fc_in2, then the updated result of the 10th row should be written to dct4 for that caseID as key. And I simply want this final result to be also written to fc_in3 for the row with that same caseID by running a last update cursor on fc_in3.
... View more
06-24-2015
01:28 AM
|
0
|
0
|
1869
|
POST
|
Yes you are correct, dct4 for key caseID keeps getting updated as the update cursor moves on each row in fc_in2. But after that I need these updated values from dct4 to be written to fc_in3 in the result field. Thats why I first run update Cursor on fc_in2 - this updates dct4 and gives each caseID a result value (in dct4) and then Im trying to write this result to fc_in3 using caseID from dct4 in result field. So it should be same. Concerning what Im doing, I have multiple rows with same caseIDs in fc_in2 as you can see. For example the first two rows have caseID 1 5. So I want to calculate the result for the first row using value and workers (from another table). Then when the cursor moves to the second row which has the same caseID, it should take its value, add to it the value from the previous row (since previous row had the same caseID) and divide this sum with the workers value. So this second row will have a new value in the result field. This is the updated final value for caseID 1 5 and it will be written in dct4 with that caseID as key. If there are more rows with same caseID then this process should continue. Now I just want to write this same value in fc_in3 for the row with caseID 1 5. In fc_in3 there is just one row for each caseID. Thats the difference. Im outside now I can attach the dataset in the evening probably.
... View more
06-24-2015
01:18 AM
|
0
|
0
|
1869
|
POST
|
I just re-checked it once again. They are correctly assigned.
... View more
06-23-2015
10:48 AM
|
0
|
6
|
1869
|
POST
|
So I want to add 0.146561 with 2.072405 and write the summed up number in place of these two numbers in the Result field
... View more
06-23-2015
10:45 AM
|
0
|
1
|
1511
|
POST
|
No. There is a field called 'Result' right? I want to add the values in this field for row having case ID 1 5 and the row having case ID 5 1 and write this new value in the same Result field for both rows.
... View more
06-23-2015
10:43 AM
|
0
|
0
|
1511
|
POST
|
Oh no I think you did not understand the question completely. I don't want to modify the case ID field. I wanted to sum up the values in the result field for the rows with case IDs 1 5 and 5 1 and write that sum to the result field in both rows.
... View more
06-23-2015
10:24 AM
|
0
|
4
|
1511
|
POST
|
import arcpy arcpy.env.overwriteOutput = True fc_in = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRW_Gemeinde' fc_in2 = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRWCommuterData2' fc_in3 = 'E://SUT//Thesis//Geodata//Thesis.gdb//NRWGemeindeDissolveFinal_SpatialJoin' dct = {} #Dictionary for gemeinde-workers pair dct2 = {} #Dictionary for gemeinde-value pair dct3 = {} #Dictionary for gemeined-result pair dct4 = {} #Dictionary for caseID-result pair dct5 = {} #Dictionary for sub-region origin and destination pair dct6 = {} #Dictionary for case_ID and result pair lst = [] #List for case IDs fld_gemeinde = 'GEN' fld_workers = 'Workers' fld_result = 'Result' fld_o = 'GEN' fld_d = 'GEN_1' fld_caseID = 'Case_ID_Ne' fld_caseID2 = 'Case_ID' fld_value = 'Value' fld_sub_region_o = 'Sub_Region' fld_sub_region_d = 'Sub_Regi_1' with arcpy.da.SearchCursor(fc_in, (fld_gemeinde, fld_workers), sql_clause=(None, 'ORDER BY "GEN" ASC')) as cursor: for row in cursor: dct[row[0]] = row[1] arcpy.AddField_management(fc_in2, fld_result, 'DOUBLE') with arcpy.da.UpdateCursor(fc_in2, (fld_o, fld_d, fld_caseID, fld_result, fld_value), sql_clause=(None, 'ORDER BY "GEN" ASC')) as cursor2: for row2 in cursor2: if row2[2] in lst: row2[3] = (row2[4] + dct2[row2[2]])/dct[row2[0]] dct2[row2[2]] = row2[4] + dct2[row2[2]] dct4[row2[2]] = row2[3] else: row2[3] = row2[4]/dct[row2[0]] lst.extend([row2[2]]) dct2[row2[2]] = row2[4] dct4[row2[2]] = row2[3] cursor2.updateRow(row2) arcpy.AddField_management(fc_in3, fld_result, 'DOUBLE') with arcpy.da.UpdateCursor(fc_in3, (fld_caseID2, fld_result)) as cursor3: for row3 in cursor3: row3[1] = dct4[row3[0]] cursor3.updateRow(row3) Clearly the two lines in the code in bold means that the two circled values in the image should be same. But they are not ! I feel like my head will burst open trying to figure why. Please can some help me?
... View more
06-23-2015
10:19 AM
|
0
|
9
|
4675
|
POST
|
Hello, I want to add the values in the RESULT field from two rows which are similar but the numbers are inverted. For example I want to add the values from the row with SUB_REGION field having 1 and SUB_REGI_1 field having 5 to the row with SUB_REIGON field having 5 and SUB_REGI_1 field having 1. These are actually calculations from commuter data between sub-regions. So I want to have the RESULT value to contain the sum of values from people commuting from 1 to 5 and from 5 to 1. Any way I can do this with a script? It seems impossible to me at the moment. Thanks alot!
... View more
06-23-2015
05:38 AM
|
0
|
8
|
4300
|
POST
|
I think I know what the problem was. The newly created fields were created by opening the table from the table of contents. And I was running the tool on the original table in the database. So I think these new fields were not there in the table in the database. So I need to export this table first to the database to be able to see the new fields in the table. I stupidly assumed that any changes I make in the table by opening it from the table of contents will be transferred to the respective table of that shapefile in the database.
... View more
06-20-2015
02:54 AM
|
0
|
0
|
828
|
POST
|
Hello, I find myself in a situation needing to use this nice tool again. But I want to create case IDs based on two fields that have been joined to the base table. I know that for such fields this tool doesn't work. So I created two new fields and just transferred the values from those two joined fields into the new ones using field calculator. But still these newly created fields also don't show up in the tool dialogue box. Is there anyway to make this work with this tool?
... View more
06-19-2015
01:01 AM
|
0
|
3
|
828
|
POST
|
Yes I have advanced license and this method work well. Its amazing how each thing can be done in a thousand ways in ArcGIS. Thanks alot for all the help!
... View more
06-17-2015
03:41 AM
|
0
|
0
|
470
|
POST
|
06-16-2015
01:45 PM
|
0
|
2
|
470
|
POST
|
I just noticed that one another feature also is not listed. In the map its clearly again inside the big polygon but is not listed like Simmerath. There may be more. But why....
... View more
06-16-2015
01:03 PM
|
0
|
0
|
470
|
Title | Kudos | Posted |
---|---|---|
1 | 01-23-2015 12:44 PM | |
1 | 02-23-2015 02:32 PM | |
2 | 09-22-2014 05:01 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|