[GRASS-user] GeoPackage and multiple tables

Ken Mankoff mankoff at gmail.com
Sat Mar 16 09:20:17 PDT 2019


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)

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.

Should I just keep my vectors and databases each as a separate vector and not use layers?

  -k.




More information about the grass-user mailing list