1

I have a layer from a PostGIS database which has a FLOAT[] data type (list of floats), and I would like to draw a bar chart with vertical bars for each element in the list, sequentially. Kind of like this, but the data would be a time series rather than a qualitative binning.

The only two resources I can find for this are:

I can see that you can make a histogram under Layer Properties > Diagrams, but I need a bar chart drawing sequential values from a list attribute, and I have no idea how to begin.

Does anybody know how this can be done?

Here is some sample data that you can insert into a PostGIS database that looks like what I have on-hand. It contains 10 random points with 10 values in each list.

CREATE TABLE barchart_test_data (id TEXT, "data" FLOAT[], geom GEOMETRY);
INSERT INTO barchart_test_data (id,"data",geom) VALUES 
('205','{0.4245885,0.36127677517499995,0.3081234165981712,0.2634985144049946,0.3656251777687132,0.3117741179957232,0.4061549607633094,0.3458008973088364,0.2951306433356336,0.3921819316124312}','POINT (1.0493663176894188 1.0493663176894188)')
,('329','{0.56418,0.618062319,0.66329921991645,0.7012778600808557,0.7331628274308825,0.7599318517695974,0.7824057861531655,0.8012737777648901,0.8171144001225135,0.8304133946228562}','POINT (1.0612912280485034 1.0612912280485034)')
,('256','{0.4245885,0.500868275175,0.4253174604231712,0.5014802738982733,0.5654227639512954,0.6191056814753101,0.6641751748825966,0.702013268072684,0.7337802392104219,0.7604501998291097}','POINT (1.1211415464058518 1.1211415464058518)')
,('120','{0.4245885,0.36127677517499995,0.3081234165981712,0.40309001440499465,0.3432277215937133,0.432561833664002,0.3679707874526129,0.3137433746058412,0.26821675015033397,0.22999487258871287}','POINT (1.1356072491034865 1.1356072491034865)')
,('251','{0.56418,0.478470819,0.54610517609145,0.602887600587577,0.5109677850733003,0.5733880039582893,0.6257928987231818,0.5301979281230472,0.5895326705557044,0.6393471535650416}','POINT (1.334024685434997 1.334024685434997)')
,('24','{0.4245885,0.36127677517499995,0.3081234165981712,0.2634985144049946,0.22603367776871322,0.19458007417072318,0.16817320127003063,0.1460033111262542,0.1273905798560467,0.11176426131814401}','POINT (1.3527626814320683 1.3527626814320683)')
,('38','{0.4245885,0.36127677517499995,0.3081234165981712,0.2634985144049946,0.22603367776871322,0.3341715741707232,0.28536724509503064,0.24439357061953298,0.20999412221362893,0.18111406530445218}','POINT (1.3899430576711893 1.3899430576711893)')
,('263','{0.56418,0.618062319,0.66329921991645,0.7012778600808557,0.7331628274308825,0.6203403517695975,0.6652117423281655,0.5632920182716113,0.47772531393993134,0.40588778731826936}','POINT (1.3972668061032891 1.3972668061032891)')
,('326','{0.56418,0.618062319,0.66329921991645,0.7012778600808557,0.7331628274308825,0.7599318517695974,0.7824057861531655,0.8012737777648901,0.8171144001225135,0.8304133946228562}','POINT (1.4661570535972714 1.4661570535972714)')
,('8','{0.4245885,0.36127677517499995,0.3081234165981712,0.2634985144049946,0.22603367776871322,0.19458007417072318,0.16817320127003063,0.1460033111262542,0.1273905798560467,0.11176426131814401}','POINT (1.47384490724653 1.47384490724653)')
;
2
  • 2
    Does this answer your question? How to create histogram to visualize feature's value in QGIS 3?
    – Erik
    Commented Mar 6, 2020 at 9:19
  • @Erik - no, when you have a list attribute, it doesn't even appear in the attribute input parameter. Also, I think this only makes histograms, whereas I want to make a time series, with each element in the list being the next time step.
    – wfgeo
    Commented Mar 6, 2020 at 9:30

1 Answer 1

2

It's not an elegant solution, but I'm sharing it with you anyway because it works.

The idea is to create a bar for each value so in your case 10 bars. To do this, you add an expression and you use the array_get("field",index) function. To retrieve the first value, you write array_get("data",0). Do this for each value.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.