I'm merging some shapefiles and I had some problems doing so inside QGIS, so i'm using ogr2ogr directly.
I'm doing this (in a batch):
ogr2ogr -overwrite %destination% %n1%
ogr2ogr -update -append %destination% %n2% -nln all_new
ogr2ogr -update -append %destination% %n3% -nln all_new
ogr2ogr -update -append %destination% %n4% -nln all_new
It works fine, but now I need to have in the resulting shapefile, a field with the names of the original shapefiles I merged.
Doesn't sound very difficult, but I'm not managing to do it.
Can anyone help?
Thank you!
Best Answer
With small scripting it would be doable. With something like following you should be able to add column to a shapefile in all shapefiles in a folder, and merge them to merged.shp file
edit: The same as a Bash script, with some changes to make it working: