[gdal-dev] Field values are applied to incorrect fields in merging 2 or more Shapefiles
I am merging 2 or more Shapefiles pulled from OpenStreetMap. In the merging, the values of fields are getting applied to the wrong output fields in the merged shapefile. I have been looking at this code for a while and cannot figure out the error. As a note, my downloaded source files don't all seem to have the exact same list of fields; not sure why.
As an example, the name field value from the source is assigned to the maxspeed value of the target. This happens consistently for an entire source, so not random.
def copy_feature_attribute_values(inFeature, outLayerDefn, outFeature): for i in range(0, outLayerDefn.GetFieldCount()): fieldName = outLayerDefn.GetFieldDefn(i).GetNameRef() field = inFeature.GetField(i) outFeature.SetField(fieldName, field)
... There is some code here to create the layer from the first of the