[GRASS-user] GeoPackage and multiple tables

Markus Metz markus.metz.giswork at gmail.com
Sat Mar 16 10:25:04 PDT 2019


On Sat, Mar 16, 2019 at 5:20 PM Ken Mankoff <mankoff at gmail.com> wrote:
>
> Hi Moritz [and Markus]
>
> On 2019-03-16 at 08:24 -0700, Moritz Lennert <mlennert at club.worldonline.be>
wrote...
> > Try running v.out.ogr three times, changing layer each time and using
> > the -u flag for updating the existing gpkg file:
> >
> > v.out.ogr -c input=pal output_layer=pal1 output=pal.gpkg layer=1
> > v.out.ogr -c input=pal output_layer=pal2 output=pal.gpkg layer=2 -u --o
> > v.out.ogr -c input=pal output_layer=pal3 output=pal.gpkg layer=3 -u --o
>
> That seems to work. When I then read in the GeoPackage and diff, things
look better.
>
> v.in.ogr input=pal.gpkg output=pal2 --o
> diff <(v.db.connect -g pal) <(v.db.connect -g pal2)
> # no major diff, but table name is not preserved.
>
> But the vector data is also included 3x now.

Why do you think the vector data are included 3x in the output? Did you
check with ogrinfo on the different layers in the output GPKG?

> This may be due to v.patch? I'm adding Markus because he suggested the
method to patch different layers. After I patch the three layers:
>
> rm -fR ./nc_spm_08_grass7/gpkg
> grass ./nc_spm_08_grass7/PERMANENT
> g.mapset -c gpgk
> g.copy vector=poi_names_wake at PERMANENT,points
> g.copy vector=lakes at PERMANENT,areas
> g.copy vector=railroads at PERMANENT,lines
> v.category in=areas out=areas_2 op=chlayer layer=1,2 --o
> v.category in=lines out=lines_3 op=chlayer layer=1,3 --o
> v.patch in=points,areas_2,lines_3 output=pal --o
>
> I would expect that v.info reports different information if I use the
"layer" option. But all three layers report IDENTICAL info. This diff
command is silent:
>
> diff3 -A <(v.info pal layer=1) <(v.info pal layer=2) <(v.info pal layer=3)

The layer option of v.info has only effect if used together with the -c
flag (list columns for given layer). By default v.info reports info on the
whole vector. You might want to check instead with v.category option=report
to see how many features are assigned to each layer.

>
> Also, the final export commands suggested by Moritz:
>
> v.out.ogr -c input=pal output_layer=tbl_pts output=pal.gpkg layer=1 --o
> v.out.ogr -c input=pal output_layer=tbl_areas output=pal.gpkg layer=2 -u
--o
> v.out.ogr -c input=pal output_layer=tbl_lines output=pal.gpkg layer=3 -u
--o
>
> seem to export everything 3x. This is based on 1) the message "Exporting
15279 areas (may take some time)..." repeated each time 2) the file size
increasing by 12 MB each time, and 3) reading in, displaying, and clicking
brings up everything 3x in the "Query Results" window.

I suggest to check first with v.category input=pal option=report for the
assignment of features to layers, then with ogrinfo on the output pal.gpkg.

Markus M
>
> Should I just keep my vectors and databases each as a separate vector and
not use layers?
>
>   -k.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190316/e9b13d60/attachment.html>


More information about the grass-user mailing list