I got a line shapefile tc_line with 166 rows (line segments), and the figure below was its atttribute table:
and with Fiona and networkx, I also got some edges in this shapefile (How to get lines and nodes around the confluence point in a network system (line shapefile)?):
LINESTRING (260586.2596740723 2736302.815605165, 260586.2596740723 2736273.931404115)
LINESTRING (260586.2596740723 2736302.815605165, 260586.2596740723 2736331.699806215)
LINESTRING (260586.2596740723 2736302.815605165, 260615.1438751221 2736302.815605165)
I want to:
1. Add a column (type:float) containing 1 in the attribute table of tc_line
2. In the table, find out rows (line segments), which contain edges listed above
3. Update value in the new-added column of selected rows
I think that to copy the original shapefile in a newly-created one to do tasks above would be better for me, so I wrote the script to copy a existing shapefile tc_line to a new file tc_pi, and it ran fine:
But now I am stuck in stage 1 described above, asNow I want to copy the existing file and add a new column (type: float) containing "1" to the attribute table (I would like the new-added column to be attached to the right of the existing columns in the attribute talle), so I edited the code above to this:
I am newbie to use Fiona and networkx, and howHow to solve this and achieve my objectives? I am gladobjective of 'copy the existing file and add a new column (type: float) containing "1" to receive some tips.the attribute table of new file'?
I am working with python 2.7.12, Fiona 1.7.0 and networkx 1.11 under Win10 64bits.