Let's say I have the two following CSV files:
file1.csv:
Latitude,Longitude,name
-23.5592201171,-46.5417389180,one
-23.5666778463,-46.5500715205,two
file2.csv:
Latitude,Longitude,name
-23.5703366507,-46.5483625224,three
-23.5840397199,-46.5147095166,four
I know I can convert them individually to shapefiles using ogr2ogr
using the following command:
ogr2ogr -oo X_POSSIBLE_NAMES=Lon* -oo Y_POSSIBLE_NAMES=Lat* -f "ESRI Shapefile" output.shp file1.csv
However, if I try using this same command a second time with my second CSV file:
ogr2ogr -oo X_POSSIBLE_NAMES=Lon* -oo Y_POSSIBLE_NAMES=Lat* -f "ESRI Shapefile" output.shp file2.csv
My old shapefile will be overwritten by the contents of my second CSV. I'd like to continuously add more data inside this shapefile as new CSV files arrive. So the final result inside my CSV would be the concatenation of my CSV files:
Latitude,Longitude,name
-23.5592201171,-46.5417389180,one
-23.5666778463,-46.5500715205,two
-23.5703366507,-46.5483625224,three
-23.5840397199,-46.5147095166,four
I'd like to avoid merging these CSVs before converting them to Shapefile. Is there any way of adding new data to a Shapefile considering the new CSVs will all have the same columns of the first original csv that created the first Shapefile?
-update -append -nln output
should work for the next CSV files. Notice that "new layer name"-nln
is the name of the existing shapefile, without .shp extension.