[GRASS-user] GeoPackage and multiple tables
Moritz Lennert
mlennert at club.worldonline.be
Sat Mar 16 09:37:28 PDT 2019
Le Sat, 16 Mar 2019 09:20:17 -0700,
Ken Mankoff <mankoff at gmail.com> a écrit :
> 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. 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)
By default v.info provides geometry information which is indeed the
same, as the map contains all these geometries. IIUC, the layer option
for v.info is meant for the v.info -c flag to decide which table's
columns to display.
>
> Also, the final export commands suggested by Moritz:
> Layers are
> 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.
>
> Should I just keep my vectors and databases each as a separate vector
> and not use layers?
>
That is my fault: I shouldn't have used the -c flag. Try without it.
You will see different feature counts in each layer when you run
ogrinfo pal.gpkg -so pal1
Moritz
More information about the grass-user
mailing list