Helper links from virtual fields for NSW layers

30 views
Skip to first unread message

bi...@williamson.fm

unread,
Oct 30, 2023, 3:40:03 AM10/30/23
to QGIS Australia User Group
A powerful feature in QGIS, is to be able to create virtual fields which can display a url and therefore a clickable link out of the map canvas. 

If you work with the NSW planning layers - from here 

have you tried to set up such a web link? My attempt is to take the pco_ref_key attribute and apply the following expression 


This successfully creates a web link in the "Identify Results" form which pops up after clicking on the relevant feature in the map canvas. 

However it does not successfully go to the web page. The web page requires two blocks of 4 digits. 

This fails if the form of the pco_ref_key string is not composed two blocks of 4 digits each. i.e. 

2013-0002
2022-0108

both of the above would work but the data in the layer comes as ;

2013-2
2022-108

(at least thats the case here in the centre of the universe. There are some epi keys which are naturally formed as 2 sets of 4 digits and they will work ok). 

Has anybody got a text parsing hack for the NSW Environmental Planning Instrument links that can be applied in QGIS expressions?

epi_url.png



John Bryant

unread,
Oct 30, 2023, 3:52:25 AM10/30/23
to australian-qg...@googlegroups.com
Hi Bill, you could try this expression:

concat('https://legislation.nsw.gov.au/view/whole/html/inforce/current/epi-', array_to_string(array_foreach(string_to_array("pco_ref_key", '-'), lpad(@element, 4, '0')), '-'))

It splits the string in the "pco_ref_key" attribute into an array using the '-' delimiter, pads each element of the array to a 4 digit number, and then converts the array back into a string.

Curious to know if it works. I haven't tested it on this layer, but it seems to work with a test string...

--
You received this message because you are subscribed to the Google Groups "QGIS Australia User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to australian-qgis-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/australian-qgis-user-group/2087f1d5-26f9-47ae-9b6d-1897182740f5n%40googlegroups.com.

bi...@williamson.fm

unread,
Oct 30, 2023, 3:59:45 AM10/30/23
to QGIS Australia User Group
That is great thank you John, yes it works, it successfully makes 


which opens the correct web page just fine! 

Great work!

bi...@williamson.fm

unread,
Oct 30, 2023, 4:06:51 AM10/30/23
to QGIS Australia User Group
how to use atttribute forms in QGIS is on this link https://docs.qgis.org/3.28/en/docs/training_manual/create_vector_data/forms.html#basic-fa-using-qgis-form-design-functionality 

to display a url, we need only specify that display text as the form field type. And we use the expression builder to form the url as noted already. Thats fine if we have the ingredients for the url. 

Another way to do a similar thing without the ingredients, is described in the docs here https://docs.qgis.org/3.28/en/docs/training_manual/create_vector_data/actions.html#hard-fa-open-a-webpage-directly-in-qgis

Reply all
Reply to author
Forward
0 new messages