[gdal-dev] ogr2ogr and RFC41

Even Rouault even.rouault at spatialys.com
Sun Oct 26 09:58:59 PDT 2014


Le dimanche 26 octobre 2014 16:10:48, Martin Landa a écrit :
> Hi,
> 
> 2014-10-24 9:46 GMT+02:00 Martin Landa <landa.martin at gmail.com>:
> >> So perhaps something like ?
> >> --select *,!geom1,!attr1
> > 
> > yes, it would be nice to have it... Martin
> 
> the attached patch shows a way, I am sure that it's possible to
> simplily it. Anyway combination as (assuming that a source layer has
> three geometry columns) seems to work:
> 
> $ ogr2ogr -f PostgreSQL -select '*' PG:dbname=vfr_10 PG:dbname=vfr
> staty -overwrite
> 
> -> OK all attributes + geom1
> 
> $ ogr2ogr -f PostgreSQL -select '*,!geom1' PG:dbname=vfr_10
> PG:dbname=vfr staty -overwrite
> 
> -> OK, all atributes + geom2
> 
> $ ogr2ogr -f PostgreSQL -select '*,!geom1,!geom2' PG:dbname=vfr_10
> PG:dbname=vfr staty -overwrite
> 
> -> OK, all atributes + geom3

Martin,

The patch and above syntax look good to me at first sight. Provided you also 
document the new syntax in apps/ogr_utilities.dox and add new test cases in 
autotest/utilities/test_ogr2ogr.py (you can have a look at/extend 
test_ogr2ogr_51 that tests RFC41 with the CSV driver), I think that's good for 
commit.

> 
> BTW, I would assume that if the destination datasource supports RFC41
> than ogr2ogr transfers all geometry columns, but it doesn't seems to
> be true, eg.:
> 
> $ ogrinfo PG:dbname=vfr staty | grep Geometry
> Geometry (definicnibod): Point
> Geometry (originalnihranice): Multi Polygon
> Geometry (generalizovanehranice): Multi Polygon
> Geometry Column 1 = definicnibod
> Geometry Column 2 = originalnihranice
> Geometry Column 3 = generalizovanehranice
> 
> $ ogr2ogr -f PostgreSQL PG:dbname=vfr_10 PG:dbname=vfr staty -overwrite
> 
> $ ogrinfo PG:dbname=vfr_10 staty | grep Geometry
> Geometry: Unknown (any)
> Geometry Column = GEOMETRY

Strange, a similar test works for me...

$ ogrinfo pg:dbname=autotest mainfeature | grep Geometry
Geometry (geometryproperty): Unknown (any)
Geometry (secondgeometryproperty): Unknown (any)
Geometry Column 1 = geometryproperty
Geometry Column 2 = secondgeometryproperty

$ ogr2ogr -f postgresql pg:dbname=autotest pg:dbname=autotest mainfeature \
	-nln mainfeature_copy -overwrite

 ogrinfo pg:dbname=autotest mainfeature_copy  | grep Geometry
Geometry (geometryproperty): Unknown (any)
Geometry (secondgeometryproperty): Unknown (any)
Geometry Column 1 = geometryproperty
Geometry Column 2 = secondgeometryproperty


Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list