Monday, 16 April 2018

qgis - Why don't all the attributes in the SQL query appear in table?


I have an SQL query that works fine in the DB Manager but when I load the table as a layer one column does not get loaded. The different thing about this column is that it is static -- text generated with the query and the same for each row.


It is actually a template for data entry that I want to print on the reverse side of the map. Effectively a check list for each item. The only way I could see to get it printed was to add it as an attribute to each row.


eg.


  Vistited ( ), count1 (  ), count2 (  )....

so volunteers can check fill in the details and the photo



Answer




I experienced the same problem. After fooling around with the issue, I found out that all you need to do is add ::text to the static value and make sure that you name the column with as my_check_boxes. You will have to change the cast if text is not the actual data type.


select row_number() over () as rid,
'Visited ( ), count1 ( ), count2 ( ).'::text as xx,
ST_AsText( (gv).geom ) as geom
from (
select ( ST_PixelAsPolygons( rast, 1 ) ) as gv
from my_new_raster
where rid = 5
) geoms

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...