[gdal-dev] Export to Geopackage

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

[gdal-dev] Export to Geopackage

Randal Hale

If I export a postgis table to geopackage:

ogr2ogr -f GPKG  export.gpkg  PG:"host=gis1 user=rjhale dbname=dbname password=pass" -nln "addresspoints" -sql "select id, geom, addresses"

I check the geopackage:

rjhale@gis7:~/temp$ ogrinfo -so -al TCStransport.gpkg 
INFO: Open of `TCStransport.gpkg'
      using driver `GPKG' successful.
Layer name: addresspoints
Geometry: Unknown (any)
Feature Count: 23735

Any idea on what I'm doing wrong - the unknown geometry seems to be causing an issue in another process. If I export without the SQL statement everything is fine.

Randy


-- 
--
Randal Hale
[hidden email]
https://www.northrivergeographic.com
(423)653-3611

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

Re: Export to Geopackage

Dan Little-2
Set `-nlt` ?

On Thu, Mar 14, 2019 at 10:12 AM Dan Little <[hidden email]> wrote:

>
> Set `-nlt` ?
>
> On Thu, Mar 14, 2019 at 10:12 AM Randal Hale
> <[hidden email]> wrote:
> >
> > If I export a postgis table to geopackage:
> >
> > ogr2ogr -f GPKG  export.gpkg  PG:"host=gis1 user=rjhale dbname=dbname password=pass" -nln "addresspoints" -sql "select id, geom, addresses"
> >
> > I check the geopackage:
> >
> > rjhale@gis7:~/temp$ ogrinfo -so -al TCStransport.gpkg
> >
> > INFO: Open of `TCStransport.gpkg'
> >
> >       using driver `GPKG' successful.
> >
> > Layer name: addresspoints
> >
> > Geometry: Unknown (any)
> >
> > Feature Count: 23735
> >
> > Any idea on what I'm doing wrong - the unknown geometry seems to be causing an issue in another process. If I export without the SQL statement everything is fine.
> >
> > Randy
> >
> >
> > --
> > --
> > Randal Hale
> > [hidden email]
> > https://www.northrivergeographic.com
> > (423)653-3611
> >
> > _______________________________________________
> > gdal-dev mailing list
> > [hidden email]
> > https://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Export to Geopackage

Even Rouault-2
In reply to this post by Randal Hale
On jeudi 14 mars 2019 11:11:42 CET Randal Hale wrote:

> If I export a postgis table to geopackage:
>
> ogr2ogr -f GPKG  export.gpkg  PG:"host=gis1 user=rjhale dbname=dbname
> password=pass" -nln "addresspoints" -sql "select id, geom, addresses"
>
> I check the geopackage:
>
> rjhale@gis7:~/temp$ ogrinfo -so -al TCStransport.gpkg
>
> INFO: Open of `TCStransport.gpkg'
>
>        using driver `GPKG' successful.
>
> Layer name: addresspoints
>
> *Geometry: Unknown (any)*
>
> Feature Count: 23735
>
> Any idea on what I'm doing wrong - the unknown geometry seems to be
> causing an issue in another process. If I export without the SQL
> statement everything is fine.

Randy,

You aren't doing something wrong. This is just that the PostGIS driver cannot
retrieve the layer geometry type if using a SQL statement (could perhaps be
improved in simple situations where selecting from a single table without join
or transformation on the geometry). You can force the output layer geometry
type by adding -nlt POINT|LINESTRING|POLYGON|etc.

See doc of -nlt in https://gdal.org/ogr2ogr.html

Even


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

Re: Export to Geopackage

Randal Hale
Much thanks to you and Dan again - this ogr statement keeps growing in
complexity and I completely forgot about the nlt option.

Thanks!

Randy

On 3/14/19 11:16 AM, Even Rouault wrote:

> On jeudi 14 mars 2019 11:11:42 CET Randal Hale wrote:
>> If I export a postgis table to geopackage:
>>
>> ogr2ogr -f GPKG  export.gpkg  PG:"host=gis1 user=rjhale dbname=dbname
>> password=pass" -nln "addresspoints" -sql "select id, geom, addresses"
>>
>> I check the geopackage:
>>
>> rjhale@gis7:~/temp$ ogrinfo -so -al TCStransport.gpkg
>>
>> INFO: Open of `TCStransport.gpkg'
>>
>>         using driver `GPKG' successful.
>>
>> Layer name: addresspoints
>>
>> *Geometry: Unknown (any)*
>>
>> Feature Count: 23735
>>
>> Any idea on what I'm doing wrong - the unknown geometry seems to be
>> causing an issue in another process. If I export without the SQL
>> statement everything is fine.
> Randy,
>
> You aren't doing something wrong. This is just that the PostGIS driver cannot
> retrieve the layer geometry type if using a SQL statement (could perhaps be
> improved in simple situations where selecting from a single table without join
> or transformation on the geometry). You can force the output layer geometry
> type by adding -nlt POINT|LINESTRING|POLYGON|etc.
>
> See doc of -nlt in https://gdal.org/ogr2ogr.html
>
> Even
>
>
--
--
Randal Hale
[hidden email]
https://www.northrivergeographic.com
(423)653-3611

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