[gdal-dev] ogr2ogr and RFC41

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] ogr2ogr and RFC41

Martin Landa
Hi,

does `ogr2ogr` support RFC41 [1] (Support for multiple geometry fields
in OGR)? I didn't find appropriate option which enables to select
geometry column (`--geomfield` seems to operate only on spatial
filter) to be transfered to destination data source.

Thanks, Martin

[1] http://trac.osgeo.org/gdal/wiki/rfc41_multiple_geometry_fields

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Even Rouault
Le mercredi 11 juin 2014 23:41:39, Martin Landa a écrit :
> Hi,
>
> does `ogr2ogr` support RFC41 [1] (Support for multiple geometry fields
> in OGR)? I didn't find appropriate option which enables to select
> geometry column (`--geomfield` seems to operate only on spatial
> filter) to be transfered to destination data source.

Martin,

Yes, by default it will transfer all source geometry fields into the target
layer, if it supports multiple geometry fields. If you want only a subset of
source geometry fields, you can write a SQL clause " SELECT geomfield1,
geomfield2, other_attr FROM your_layer"

Even

--
Geospatial professional services
http://even.rouault.free.fr/services.html
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Martin Landa
2014-06-11 23:45 GMT+02:00 Even Rouault <[hidden email]>:
> source geometry fields, you can write a SQL clause " SELECT geomfield1,
> geomfield2, other_attr FROM your_layer"

yes, but it's not really user-friendly (when more attributes are
listed). Probably `--geomfield` could be also used to select geometry
column when destination data source doesn't support RFC-41, what do
you think?

Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Even Rouault
Le mercredi 11 juin 2014 23:49:55, Martin Landa a écrit :
> 2014-06-11 23:45 GMT+02:00 Even Rouault <[hidden email]>:
> > source geometry fields, you can write a SQL clause " SELECT geomfield1,
> > geomfield2, other_attr FROM your_layer"
>
> yes, but it's not really user-friendly (when more attributes are
> listed). Probably `--geomfield` could be also used to select geometry
> column when destination data source doesn't support RFC-41, what do
> you think?

Actually, I see that I had upgraded the logic of the -select option to be able
to specify geomtry field(s) also.

>
> Martin

--
Geospatial professional services
http://even.rouault.free.fr/services.html
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Rahkonen Jukka (Tike)
In reply to this post by Martin Landa
Martin Landa <landa.martin <at> gmail.com> writes:

>
> 2014-06-11 23:45 GMT+02:00 Even Rouault <even.rouault <at> mines-paris.org>:
> > source geometry fields, you can write a SQL clause " SELECT geomfield1,
> > geomfield2, other_attr FROM your_layer"
>
> yes, but it's not really user-friendly (when more attributes are
> listed). Probably `--geomfield` could be also used to select geometry
> column when destination data source doesn't support RFC-41, what do
> you think?

As a workaround I would try what happens with
-sql "SELECT geometry2, * FROM your_layer"

It may lead to desired result (especially selected geometry written into
target, second occasion of the same and other geometries skipped) with
minimal writing but I have not tried it myself.

-Jukka Rahkonen-

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Martin Landa
In reply to this post by Even Rouault
Hi,

2014-06-11 23:45 GMT+02:00 Even Rouault <[hidden email]>:

> Yes, by default it will transfer all source geometry fields into the target
> layer, if it supports multiple geometry fields. If you want only a subset of
> source geometry fields, you can write a SQL clause " SELECT geomfield1,
> geomfield2, other_attr FROM your_layer"

it's not work for me, eg.

$ ogr2ogr -f GPKG -sql "select originalnihranice from staty"
staty.gpkg PG:dbname=vfr_uksh_10_cr  -overwrite

gives

$ ogrinfo staty.gpkg sql_statement | grep Geometry

Geometry: Unknown (any)
Geometry Column = geom

I found `-select` option which seems to work:

$ ogr2ogr -f GPKG -select originalnihranice staty.gpkg
PG:dbname=vfr_uksh_10_cr staty -overwrite

$ ogrinfo staty.gpkg staty | grep Geometry

Geometry: Multi Polygon <-- OK
Geometry Column = geom

But it's still no usable, having attribute table with 10+ attributes I
need to write something like

--select geom2,attr1,attr2,...attr10

Would make sense to you to add a new option

--except geom1

or

--select !geom1

?

Thanks, Martin


--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Even Rouault-2
Le jeudi 23 octobre 2014 22:49:17, Martin Landa a écrit :

> Hi,
>
> 2014-06-11 23:45 GMT+02:00 Even Rouault <[hidden email]>:
> > Yes, by default it will transfer all source geometry fields into the
> > target layer, if it supports multiple geometry fields. If you want only
> > a subset of source geometry fields, you can write a SQL clause " SELECT
> > geomfield1, geomfield2, other_attr FROM your_layer"
>
> it's not work for me, eg.
>
> $ ogr2ogr -f GPKG -sql "select originalnihranice from staty"
> staty.gpkg PG:dbname=vfr_uksh_10_cr  -overwrite
>
> gives
>
> $ ogrinfo staty.gpkg sql_statement | grep Geometry
>
> Geometry: Unknown (any)
> Geometry Column = geom

It works. It is just that it cannot guess the geometry type from a SQL that
could potentially return arbitrary geometries (well we could perhaps add
heuristics to detect that the column is indeed a column of a spatial table,
similarly to what exists in the spatialite&gpkg driver) . You can however
specify -nlt multipolygon if you want stronger typing

>
> I found `-select` option which seems to work:
>
> $ ogr2ogr -f GPKG -select originalnihranice staty.gpkg
> PG:dbname=vfr_uksh_10_cr staty -overwrite
>
> $ ogrinfo staty.gpkg staty | grep Geometry
>
> Geometry: Multi Polygon <-- OK
> Geometry Column = geom

Yes because here we know that we are directly extracting information from the
source layer.

>
> But it's still no usable, having attribute table with 10+ attributes I
> need to write something like
>
> --select geom2,attr1,attr2,...attr10
>
> Would make sense to you to add a new option
>
> --except geom1
>
> or
>
> --select !geom1

The later kind of reminds me of MapServer syntax :
"wms_enable_request" "* !GetFeatureInfo"

So perhaps something like ?
--select *,!geom1,!attr1

I can be wrong but there's no SQL syntax for "* but X and Y", is there ?

>
> ?
>
> Thanks, Martin

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Martin Landa
Hi,

2014-10-24 1:16 GMT+02:00 Even Rouault <[hidden email]>:

> The later kind of reminds me of MapServer syntax :
> "wms_enable_request" "* !GetFeatureInfo"
>
> So perhaps something like ?
> --select *,!geom1,!attr1

yes, it would be nice to have it... Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Martin Landa
Hi,

2014-10-24 9:46 GMT+02:00 Martin Landa <[hidden email]>:
>> 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

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

Martin

--
Martin Landa * http://geo.fsv.cvut.cz/gwiki/Landa *
http://www.gismentors.eu/mentors/landa

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

apps.diff (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ogr2ogr and RFC41

Even Rouault-2
Le dimanche 26 octobre 2014 16:10:48, Martin Landa a écrit :

> Hi,
>
> 2014-10-24 9:46 GMT+02:00 Martin Landa <[hidden email]>:
> >> 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
_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev