[Qgis-user] Select data from a specific layer
Dario
dario955i at gmail.com
Tue May 18 09:41:30 PDT 2021
<image (1).png>
<image.png>
I try to answer without attached images (size limit)...
values are correct. I made first a virtual field in which I have "N" or "R" in the "Colore" filed through an expression and it works. My problem is the colour now.
I tried also with 'Colore' instead of "Colore", but nothing change.
Here the code:
CASE
When
get_feature('V_TB_ATTIVITA_PT_NR','Colore','N')='N' then color_rgb (0,0,0)
When
get_feature('V_TB_ATTIVITA_PT_NR','Colore','R')='R' then color_rgb (255,0,0)
END
I'm pretty sure that in expression.... 'V_TB_ATTIVITA_PT_NR','Colore','N'... 'N' does not have sense, but I don't know what to pu... sorry, but I'm a super beginner with code :(
Cheers
Il giorno mar 18 mag 2021 alle ore 08:39 Dario C <dario955i at gmail.com> ha scritto:
> <image.png>
> <image.png>
>
> values are correct. I made first a virtual field in which I have "N" or "R" in the "Colore" filed through an expression and it works. My problem is the colour now.
>
> I tried also with 'Colore' instead of "Colore", but nothing change.
>
> Here the code:
>
> CASE
> When
> get_feature('V_TB_ATTIVITA_PT_NR','Colore','N')='N' then color_rgb (0,0,0)
> When
> get_feature('V_TB_ATTIVITA_PT_NR','Colore','R')='R' then color_rgb (255,0,0)
> END
>
> I'm pretty sure that in expression.... 'V_TB_ATTIVITA_PT_NR','Colore','N'... 'N' does not have sense, but I don't know what to pu... sorry, but I'm a super beginner with code :(
>
> Cheers
>
> Il giorno mar 18 mag 2021 alle ore 08:32 Ujaval Gandhi <ujaval at spatialthoughts.com> ha scritto:
>> get_feature() will get you the feature.Your current expression will get you the first feature from 'V_TB_ATTIVITA_PT_NR' layer where the "Colore" value is 'N'. - I don't think that is what you want. You need to query for a feature from another layer that relates to the current feature, (using a common field value). Once you get the feature, you can use the attributes(feature)['Colore'] to read the "Colore' field from that feature.
>>
>>
>> Ujaval Gandhi
>> Spatial Thoughts
>> mobile: +91-8095684687
>> email: ujaval at spatialthoughts.com
>>
>>
>>
>>
>> On Tue, May 18, 2021 at 4:35 AM Delaz J <delazj at gmail.com> wrote:
>>> Hi Dario,
>>>
>>> Could you try with 'Colore' and not "Colore" (pay attention to the simple vs double quotes)?
>>>
>>> Regards,
>>>
>>> Harrissou
>>>
>>> Le 18/05/2021 à 00:41, Dario C a écrit :
>>>> Hi, thank you for your reply, but I still don't understand how to do... sorry
>>>>
>>>> i tried to write this code in colour expression, but I don't understand what "value" is in get_feature :
>>>>
>>>> CASE
>>>> When
>>>> get_feature('V_TB_ATTIVITA_PT_NR',"Colore",'N')='N' then color_rgb (0,0,0)
>>>> When
>>>> get_feature('V_TB_ATTIVITA_PT_NR',"Colore",'R')='R' then color_rgb (255,0,0)
>>>> END
>>>>
>>>> Consider that I have a virtual field called "Colore" where I have 'N' or 'R' in case it is black or red color.
>>>>
>>>> Thank you for your kind availability.
>>>>
>>>> cheers
>>>>
>>>> Il giorno lun 17 mag 2021 alle ore 09:09 Ujaval Gandhi <ujaval at spatialthoughts.com> ha scritto:
>>>>> You can select the layer under 'Plot Parameters' and its attributes will be available in the expression. (see attached screenshot).
>>>>>
>>>>> If you need to get the attribute from another layer, you can use the get_feature() function to get feature from another layer by specifying the layer name.
>>>>>
>>>>> Ujaval Gandhi
>>>>> Spatial Thoughts
>>>>> mobile: +91-8095684687
>>>>> email: ujaval at spatialthoughts.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, May 17, 2021 at 2:47 AM Dario <dario955i at gmail.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I should get some data from a specific field of a specific layer but I’m stuck.
>>>>>>
>>>>>> I’m using “Data Ploty” plug-in and I’d like to customise the colour of the chart using expression.
>>>>>> As I’m working on layout I can’t see any field into expression menu, so I need to call a specific layer and then the field.
>>>>>> I’d like to write something like that but, of course, selecting the correct layer:
>>>>>>
>>>>>> CASE
>>>>>> WHEN "Civici" = 'Neri' THEN color_rgb(0,0,0)
>>>>>> ELSE color_rgb (255,0,0)
>>>>>> END
>>>>>>
>>>>>>
>>>>>> Thank you in advance.
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>> _
>>>>>> _______________________________________________
>>>>>> Qgis-user mailing list
>>>>>> Qgis-user at lists.osgeo.org
>>>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>
>>>>
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at lists.osgeo.org
>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210518/ff9a8029/attachment-0001.html>
More information about the Qgis-user
mailing list