[Qgis-user] Help opening a Spatialite view in QGIS

Brent Wood Brent.Wood at niwa.co.nz
Thu Dec 5 13:52:34 PST 2024


Hi,

I have created a view in a spatialite database, but am unable to open it in QGIS.

I can't find any documentation on how this works.

I have a table "stations" which contains a station_no column (integer) and a point geometry column (startp, EPSG 4326).

The view is created by:
create view v_stat as select station_no, startp from station;


I add an entry to the Spatialite views_geometry_columns table to populate the metadata describing the view.
insert into views_geometry_columns
        (view_name, view_geometry, view_rowid, f_table_name, f_geometry_column, read_only)
      values
        ('v_stat', 'startp', 'station_no', 'station', 'startp', 1)

QGIS now lists the view correctly as a table with a geometry & lists startp as the geometry, but when I try to open it, I just get an "invalid layer" error message.

 dbname='/home/baw/tan2413/tan2413.spdb' table="v_stat" (startp) is an invalid layer - not loaded


Can anyone tell me how to set up a Spatialite view so it can be successfully opened in QGIS?


Thanks

Brent Wood

Principal Technician, Fisheries
NIWA
DDI:  +64 (4) 3860529
[https://www.niwa.co.nz/static/niwa-2018-horizontal-180.png] <https://www.niwa.co.nz>
Brent Wood
Principal Technician - GIS and Spatial Data Management
Programme Leader - Environmental Information Delivery
+64-4-386-0529

National Institute of Water & Atmospheric Research Ltd (NIWA)
301 Evans Bay Parade Hataitai Wellington New Zealand
Connect with NIWA: niwa.co.nz<https://www.niwa.co.nz> Facebook<https://www.facebook.com/nzniwa> LinkedIn<https://www.linkedin.com/company/niwa> Twitter<https://twitter.com/niwa_nz> Instagram<https://www.instagram.com/niwa_science> YouTube<https://www.youtube.com/channel/UCJ-j3MLMg1H59Ak2UaNLL3A>
To ensure compliance with legal requirements and to maintain cyber security standards, NIWA's IT systems are subject to ongoing monitoring, activity logging and auditing. This monitoring and auditing service may be provided by third parties. Such third parties can access information transmitted to, processed by and stored on NIWA's IT systems.
Note: This email is intended solely for the use of the addressee and may contain information that is confidential or subject to legal professional privilege. If you receive this email in error please immediately notify the sender and delete the email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20241205/db4ebf05/attachment.htm>


More information about the QGIS-User mailing list