[GRASS-user] Import gpkg point map

I am trying to import some geopackage files. Some are polygons, and one is a points vector. The polygons import fine, but the point vector fails with:

ERROR: Detected different projections of input layers. Input layers must be
imported separately.

Then if I convert the gpkg to a shapefile, it works fine.

Any ideas what could be wrong? Here’s the procedure, showing the problem.

######################

# My Location/mapset info:

######################

micha@TP480:Ashalim$ g.version

GRASS 7.6.0 (2019)
micha@TP480:Ashalim$ g.proj -p
-PROJ_INFO-------------------------------------------------
name : Israel 1993 / Israeli TM Grid
ellps : grs80
proj : tmerc
lat_0 : 31.73439361111111
lon_0 : 35.20451694444445
k : 1.0000067
x_0 : 219529.584
y_0 : 626907.39
towgs84 : -48,55,52,0,0,0,0
no_defs : defined
-PROJ_EPSG-------------------------------------------------
epsg : 2039
-PROJ_UNITS------------------------------------------------
unit : meter
units : meters
meters : 1

######################

# The polygon gpkg vector:

######################

micha@TP480:Ashalim$ ogrinfo ashalim_analysis.gpkg analysis_region
INFO: Open of ashalim_analysis.gpkg’ using driver GPKG' successful.

Layer name: analysis_region
Geometry: Polygon
Feature Count: 1
Extent: (231234.000000, 551462.000000) - (232977.000000, 553925.000000)
Layer SRS WKT:
PROJCS["Israel 1993 / Israeli TM Grid",
GEOGCS["Israel 1993",
DATUM["Israel_1993",

.....

# and import to GRASS:

micha@TP480:Ashalim$ v.import ashalim_analysis.gpkg output=ashalim_region --o
Check if OGR layer <analysis_region> contains polygons...
100%
Creating attribute table for layer <analysis_region>...
Importing 1 features (OGR layer <analysis_region>)...
100%
-----------------------------------------------------
.....

Input <ashalim_analysis.gpkg> successfully imported without reprojection

######################

# Now The point gpkg vector:

######################

micha@TP480:Ashalim$ ogrinfo ashalim_train_pts.gpkg ashalim_train_pts
INFO: Open of ashalim_train_pts.gpkg’ using driver GPKG' successful.

Layer name: ashalim_train_pts
Geometry: Point
Feature Count: 33
Extent: (231388.000000, 551892.000000) - (232708.000000, 553510.000000)
Layer SRS WKT:
PROJCS["Israel 1993 / Israeli TM Grid",
GEOGCS["Israel 1993",
DATUM["Israel_1993",
.....

# Try import

micha@TP480:Ashalim$ v.import ashalim_train_pts.gpkg output=ashalim_pts --o
ERROR: Detected different projections of input layers. Input layers must be
imported separately.
ERROR: Detected different projections of input layers. Input layers must be
imported separately.
ERROR: Unable to create location from OGR datasource
<ashalim_train_pts.gpkg>
# Ooops

# Convert to shapefile (no reprojection)

micha@TP480:Ashalim$ ogr2ogr ashalim_train_pts ashalim_train_pts.gpkg

micha@TP480:Ashalim$ ll ashalim_train_pts/
total 32
drwxr-xr-x 2 micha micha 4096 Jun 26 17:41 .
drwxrwxrwx 3 micha micha 4096 Jun 26 17:41 ..
-rw-r--r-- 1 micha micha 1320 Jun 26 17:53 ashalim_train_pts.dbf
-rw-r--r-- 1 micha micha 442 Jun 26 17:41 ashalim_train_pts.prj
-rw-r--r-- 1 micha micha 1948 Jun 26 17:53 ashalim_train_pts.shp
-rw-r--r-- 1 micha micha 628 Jun 26 17:53 ashalim_train_pts.shx
-rw-r--r-- 1 micha micha 6292 Jun 26 17:53 layer_styles.dbf
# Now import the shape:

micha@TP480:Ashalim$ v.import input=ashalim_train_pts/ashalim_train_pts.shp output=ashalim_pts --o
Check if OGR layer <ashalim_train_pts> contains polygons...
100%
Creating attribute table for layer <ashalim_train_pts>...
Importing 66 features (OGR layer <ashalim_train_pts>)...
100%
-----------------------------------------------------
Building topology for vector map <ashalim_pts@OBIA>...
Registering primitives...
Input <ashalim_train_pts/ashalim_train_pts.shp> successfully imported
without reprojection

If anyone wants the point and polygon gpkg files to test, I can share it.

Thanks

···
-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

On Wed, Jun 26, 2019 at 4:58 PM Micha Silver <tsvibar@gmail.com> wrote:

I am trying to import some geopackage files. Some are polygons, and one is a points vector. The polygons import fine, but the point vector fails with:

ERROR: Detected different projections of input layers. Input layers must be
imported separately.

Then if I convert the gpkg to a shapefile, it works fine.

Any ideas what could be wrong? Here’s the procedure, showing the problem.

[…]

Now The point gpkg vector:

######################

micha@TP480:Ashalim$ ogrinfo ashalim_train_pts.gpkg ashalim_train_pts

are there any other layers in ashalim_train_pts.gpkg?
You can check with

ogrinfo -so ashalim_train_pts.gpkg

Try import

micha@TP480:Ashalim$ v.import ashalim_train_pts.gpkg output=ashalim_pts --o
ERROR: Detected different projections of input layers. Input layers must be
imported separately.
ERROR: Detected different projections of input layers. Input layers must be
imported separately.
ERROR: Unable to create location from OGR datasource
<ashalim_train_pts.gpkg>

There must be more than one layer in ashalim_train_pts.gpkg, maybe an empty layer?

If anyone wants the point and polygon gpkg files to test, I can share it.

For testing, I would only need the point gpkg file.

Markus M

···

On 26/06/2019 23:03, Markus Metz wrote:

On Wed, Jun 26, 2019 at 4:58 PM Micha Silver <tsvibar@gmail.com> wrote:

I am trying to import some geopackage files. Some are polygons, and one is a points vector. The polygons import fine, but the point vector fails with:

ERROR: Detected different projections of input layers. Input layers must be
imported separately.

Then if I convert the gpkg to a shapefile, it works fine.

Any ideas what could be wrong? Here’s the procedure, showing the problem.

[…]

Now The point gpkg vector:

######################

micha@TP480:Ashalim$ ogrinfo ashalim_train_pts.gpkg ashalim_train_pts

are there any other layers in ashalim_train_pts.gpkg?
You can check with

ogrinfo -so ashalim_train_pts.gpkg

micha@TP480:code$ ogrinfo -so …/GIS/Ashalim/ashalim_train_pts.gpkg
INFO: Open of ../GIS/Ashalim/ashalim_train_pts.gpkg' using driver GPKG’ successful.
1: ashalim_train_pts (Point)
2: layer_styles (None)

The style ??!!

I removed that “layer_styles” table from the gpkg db, and deleted the entry from gpkg_contents, and now the import works.

Who would have guessed ?

I suppose that I should have specified the layer in v.import to avoid this problem.

Thanks

Markus M

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

On Wed, Jun 26, 2019 at 10:16 PM Micha Silver <tsvibar@gmail.com> wrote:

On 26/06/2019 23:03, Markus Metz wrote:

On Wed, Jun 26, 2019 at 4:58 PM Micha Silver <tsvibar@gmail.com> wrote:

I am trying to import some geopackage files. Some are polygons, and one is a points vector. The polygons import fine, but the point vector fails with:

ERROR: Detected different projections of input layers. Input layers must be
imported separately.

Then if I convert the gpkg to a shapefile, it works fine.

Any ideas what could be wrong? Here’s the procedure, showing the problem.

[…]

Now The point gpkg vector:

######################

micha@TP480:Ashalim$ ogrinfo ashalim_train_pts.gpkg ashalim_train_pts

are there any other layers in ashalim_train_pts.gpkg?
You can check with
ogrinfo -so ashalim_train_pts.gpkg

micha@TP480:code$ ogrinfo -so …/GIS/Ashalim/ashalim_train_pts.gpkg
INFO: Open of ../GIS/Ashalim/ashalim_train_pts.gpkg' using driver GPKG’ successful.
1: ashalim_train_pts (Point)
2: layer_styles (None)

The style ??!!

I removed that “layer_styles” table from the gpkg db, and deleted the entry from gpkg_contents, and now the import works.

Who would have guessed ?

I suppose that I should have specified the layer in v.import to avoid this problem.

Yes, specifying the layer should work.

I have seen this layer_styles layer before in other GPKG files but don’t know what this is good for. GDAL documentation at
https://gdal.org/drivers/vector/gpkg.html
does not mention any style information.

AFAICT, layers in a GPKG should contain vector geometries.

Markus M

Hi

Markus Metz <markus.metz.giswork@gmail.com> schrieb am Mi., 26. Juni 2019, 22:45:

On Wed, Jun 26, 2019 at 10:16 PM Micha Silver <tsvibar@gmail.com> wrote:

On 26/06/2019 23:03, Markus Metz wrote:

On Wed, Jun 26, 2019 at 4:58 PM Micha Silver <tsvibar@gmail.com> wrote:

I am trying to import some geopackage files. Some are polygons, and one is a points vector. The polygons import fine, but the point vector fails with:

ERROR: Detected different projections of input layers. Input layers must be
imported separately.

Then if I convert the gpkg to a shapefile, it works fine.

Any ideas what could be wrong? Here’s the procedure, showing the problem.

[…]

Now The point gpkg vector:

######################

micha@TP480:Ashalim$ ogrinfo ashalim_train_pts.gpkg ashalim_train_pts

are there any other layers in ashalim_train_pts.gpkg?
You can check with
ogrinfo -so ashalim_train_pts.gpkg

micha@TP480:code$ ogrinfo -so …/GIS/Ashalim/ashalim_train_pts.gpkg
INFO: Open of ../GIS/Ashalim/ashalim_train_pts.gpkg' using driver GPKG’ successful.
1: ashalim_train_pts (Point)
2: layer_styles (None)

The style ??!!

I removed that “layer_styles” table from the gpkg db, and deleted the entry from gpkg_contents, and now the import works.

Who would have guessed ?

I suppose that I should have specified the layer in v.import to avoid this problem.

Yes, specifying the layer should work.

I have seen this layer_styles layer before in other GPKG files but don’t know what this is good for. GDAL documentation at
https://gdal.org/drivers/vector/gpkg.html
does not mention any style information.

AFAICT, layers in a GPKG should contain vector geometries.

There seems to be something upcoming:

https://gis.stackexchange.com/questions/268746/writing-style-information-into-geopackage-with-python-and-gdal

Perhaps the “(None)” info could be used to identify and ignore that style layer?

markusN


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

···

On 26/06/2019 23:44, Markus Metz wrote:

On Wed, Jun 26, 2019 at 10:16 PM Micha Silver <tsvibar@gmail.com> wrote:

micha@TP480:code$ ogrinfo -so …/GIS/Ashalim/ashalim_train_pts.gpkg
INFO: Open of ../GIS/Ashalim/ashalim_train_pts.gpkg' using driver GPKG’ successful.
1: ashalim_train_pts (Point)
2: layer_styles (None)

The style ??!!

I removed that “layer_styles” table from the gpkg db, and deleted the entry from gpkg_contents, and now the import works.

Who would have guessed ?

I suppose that I should have specified the layer in v.import to avoid this problem.

Yes, specifying the layer should work.

I have seen this layer_styles layer before in other GPKG files but don’t know what this is good for. GDAL documentation at
https://gdal.org/drivers/vector/gpkg.html
does not mention any style information.

It comes from QGIS, where you can save a default layer styling directly into the gpkg. Very convenient, but I never thought it would appear to GRASS as a second layer without geometry or CRS.

AFAICT, layers in a GPKG should contain vector geometries.

Markus M

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
+972-523-665918

On Thu, Jun 27, 2019 at 7:37 AM Micha Silver <tsvibar@gmail.com> wrote:

On 26/06/2019 23:44, Markus Metz wrote:

On Wed, Jun 26, 2019 at 10:16 PM Micha Silver <tsvibar@gmail.com> wrote:

micha@TP480:code$ ogrinfo -so …/GIS/Ashalim/ashalim_train_pts.gpkg
INFO: Open of ../GIS/Ashalim/ashalim_train_pts.gpkg' using driver GPKG’ successful.
1: ashalim_train_pts (Point)
2: layer_styles (None)

The style ??!!

I removed that “layer_styles” table from the gpkg db, and deleted the entry from gpkg_contents, and now the import works.

Who would have guessed ?

I suppose that I should have specified the layer in v.import to avoid this problem.

Yes, specifying the layer should work.

I have seen this layer_styles layer before in other GPKG files but don’t know what this is good for. GDAL documentation at
https://gdal.org/drivers/vector/gpkg.html
does not mention any style information.

It comes from QGIS, where you can save a default layer styling directly into the gpkg. Very convenient, but I never thought it would appear to GRASS as a second layer without geometry or CRS.

This is not GRASS, it is OGR that recognizes it as a separate layer without geometry or CRS. I guess ogr2ogr skips this layer because there are no geometries in it.

In theory, v.in.ogr could skip empty OGR layers, but in practice it is not always easy to get the feature count of a layer, it depends on the data format. Sometimes, e.g. for OSM pbf, you need to read the whole OGR datasource to figure out the number of features per layer.

In v.in.ogr, there are already a number of special cases for specific OGR-supported formats, and I would like to keep these format-specific treatments to a minimum, avoiding yet another special case for GPKG + empty layer. Ideally, the GPKG driver of OGR would not expose such empty or special layers.

Markus M