8

I have a table with the columns of id,tags(hstore data type) and geometry. I want to categorize the table based on selecting the specific key form tags: for example:

select * FROM table_name WHERE tags @> 'public_transport=>stop_position'

enter image description here

5

In QGIS 3.4, you can use the htsore_to_map expression to get a map (dictionary) of the hstore field. Then you can use one of the map expressions to manipulate it:

access htsore value

In QGIS 3.6, you can use the "explode hstore field" which will create one field for each keys in the hstore field:

explode hstore field

2

Solution with QGIS 2.18

You need the plugin 'Expressions plus'. Then you can perform queries on a hstore-column.

If you choose 'Categorized' and use an expression-based column you can categorize values within a certain key: hstore_get_value(other_tags, 'surface')

enter image description here

For QGIS 3 I haven't found a way to perform that

0

You can't use HSTORE operators in standard QGIS expression like that.

However if your back-end database is Postgres, and you have installed the HSTORE extension (to ensure your operators like => are defined) then you may be able to use them in Database Manager SQL queries.

Alternatively, if that doesn't work, then a Postgres query that uses a CASE statement to allocate these values to a new column in your table would work. (Or you could create a new MATERIALIZED VIEW using the same technique)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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