[gdal-dev] Combining shape files

brian rush at winkey.org
Sat Oct 4 23:50:22 EDT 2008


Rainer,

that might be a bash issue
and shapefile is the default


#!/bin/bash
SP="Acacia_cyclops"

ogr2ogr "./comb/${SP}.shp" "./region_SPP_1__${SP}.shp"
ogr2ogr -update -append "./comb/${SP}.shp" "./region_SPP_2__${SP}.shp"
ogr2ogr -update -append "./comb/${SP}.shp" "./region_SPP_3__${SP}.shp"
ogr2ogr -update -append "./comb/${SP}.shp" "./region_SPP_4__${SP}.shp"
ogr2ogr -update -append "./comb/${SP}.shp" "./region_SPP_5__${SP}.shp"
ogr2ogr -update -append "./comb/${SP}.shp" "./region_SPP_6__${SP}.shp"



if you decide to use the -f switch

replace
-f \"ESRI Shapefile\" 
with
-f "ESRI Shapefile" 

i think gdal thinks Shapefile" is the output file

Brian


On Fri, 2008-10-03 at 15:56 +0200, Rainer M Krug wrote:
> Hi
> 
> I have 6 shape files, named
> region_SPP_1__Acacia_cyclops.shp to region_SPP_6__Acacia_cyclops.shp
> which I would like to combinr into a single shape file, called
> Acacia_cyclops.shp
> 
> For this I wrote the following script:
> 
> #!/bin/bash
> SP="Acacia_cyclops"
> ogr2ogr -f \"ESRI Shapefile\" "./comb/"$SP".shp" "./region_SPP_1__"$SP".shp"
> 
> ogr2ogr -update -append -f \"ESRI Shapefile\" "./comb/"$SP".shp"
> "./region_SPP_2__"$SP".shp"
> ogr2ogr -update -append -f \"ESRI Shapefile\" "./comb/"$SP".shp"
> "./region_SPP_3__"$SP".shp"
> ogr2ogr -update -append -f \"ESRI Shapefile\" "./comb/"$SP".shp"
> "./region_SPP_4__"$SP".shp"
> ogr2ogr -update -append -f \"ESRI Shapefile\" "./comb/"$SP".shp"
> "./region_SPP_5__"$SP".shp"
> ogr2ogr -update -append -f \"ESRI Shapefile\" "./comb/"$SP".shp"
> "./region_SPP_6__"$SP".shp"
> 
> but even at line 3 I have problems:
> 
> if I do the following
> 
> > SP="Acacia_cyclops"
> > ogr2ogr -f \"ESRI Shapefile\" "./comb/"$SP".shp" "./region_SPP_1__"$SP".shp"
> 
> I get the error message: "Unable to open datasource
> `./comb/Acacia_cyclops.shp' with the following drivers."
> 
> but when I say
> > echo ogr2ogr -f \"ESRI Shapefile\" "./comb/"$SP".shp" "./region_SPP_1__"$SP".shp"
> 
> and paste the output into the commandline, it works.
> 
> But with the remaining ogr2ogr, I have less luck: all result in the
> same error message "Unable to open datasource
> `./comb/Acacia_cyclops.shp' with the following drivers."
> 
> Any help appreciated,
> 
> Rainer
> 
> -- 
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
> 
> Centre of Excellence for Invasion Biology
> Faculty of Science
> Natural Sciences Building
> Private Bag X1
> University of Stellenbosch
> Matieland 7602
> South Africa
> 
> ""



More information about the gdal-dev mailing list