Bug report #20487
Geometry type not detected when loading query to canvas using MakePoint for geometry (DBManager)
|Affected QGIS version:||3.4.0||Regression?:||No|
|Operating System:||Windows 10||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||28307|
I have a GeoPackage with a table containing coordinates as separate columns (imported from an external application, originally CSV) - there are multiple sets of coordinates in each record and I am loading a series of layers from each record using a different subset of the fields within the record.
To define the geometry of the layer my query includes:
MakePoint( "A-Longitude" , "A-Latitude") as geometry
When the layer is loaded to the canvas the layer styling is set to a Line so nothing is displayed. By changing the Layer styling to "No Symbols" and then back to "Single symbol", the geometry type is detected and the points appear on the canvas. However, labels can be displayed at the correct location before the layer symbology is changed.
I am guessing that the either canvas is not detecting geometry type on load or DBManager is not providing that, and the default type is a line?
Issue also occurred in 2.18, 3.0 and 3.2
#2 Updated by Chris York over 1 year ago
Giovanni Manghi wrote:
Please attach a sample of your data.
A sample point from CSV (with the location 'rounded'!) - I loaded the CSV as a delimited text file as a layer and imported the layer into a GPKG database as a non-spatial table (MyTable). I have also imported directly into DBManager using a csvt file to ensure field types are correct
Table structure (copied from DB Manager)
\# Name Type Null
0 fid INTEGER N
1 Number MEDIUMINT Y
2 Reason TEXT Y
3 Start-Latitude REAL Y
4 Start-Longitude REAL Y
5 Start-Altitude MEDIUMINT Y
6 Start-Accuracy MEDIUMINT Y
7 Photo1 TEXT Y
8 P1_location-Latitude REAL Y
9 P1_location-Longitude REAL Y
10 P1_location-Altitude MEDIUMINT Y
11 P1_location-Accuracy MEDIUMINT Y
My query is:
Select "Number", "Reason", "Photo1" as Image,"P1_location-Accuracy" as GPS_Accuracy, MakePoint( "P1_location-Longitude" , "P1_location-Latitude") as geometry from MyTable
In DBManager I select 'load as new layer' and use "Geometry" as my Geometry column
This is a simplified version of my data - the actual table has many more columns... I also have a separate unique key which I add to the query, which is another column from MyTable.