[Qgis-developer] Field Calculator "permanence"

Zoltan Szecsei zoltans at geograph.co.za
Fri Nov 7 09:19:19 PST 2014


Hi Andreas,
I was hoping the QGIS project would keep the definition of the virtual 
fields - at least until I exited QGIS - and then by re-opening the same 
SHP file, I hoped for a reconnection of virtual fields. Yes, I know it's 
not that simple, but exploring QGISes abilities is what I am playing 
with now.

Thanks for the pointer to 'Save Layer Definition file' - I've never 
noticed that, so I'll play with that for a bit.

Thanks to Matthias too for his comments.
Yes, it is a bummer that you can only generate virtual content 
_dynamically_ with the FC (and SHP files).

Hopefully not to open a can of worms, but I can't see any reason why 
QGIS cannot create some sort of information/status/whatever file by 
using a '.Qstuff' type file extension stored with the SHP file name. 
This would not interfere with other SW using SHP files, and would 
greatly enhance QGIS's ability in processing this (really hateful) file 
format.
I abhor SHP file format, but it has unfortunately become the de facto 
request from clients, so it would be nice to have more advanced 
processing capabilities for this format.

Regards & have a good weekend.
Zoltan


On 2014/11/07 18:59, Andreas Neumann wrote:
> Hi Zoltan,
>
> If you remove and re-add the shapefile you will of course loose the 
> virtual fields, as they are stored with the project and not with the data.
>
> However, if you save a layer definition file along with the shapefile 
> and re-add that, they are preserved. So you can just store the layer 
> definition file along with the shape and you are fine to share the 
> data with your colleagues, preserving virtual fields ;-)
>
> Andreas
>
> On 07.11.2014 17:32, Zoltan Szecsei wrote:
>> Hi Andreas,
>> I'll fiddle with the Postgis idea - thanks.
>> The orange part below:
>> I closed the shapefile, deleted from legend and re-opened it - but 
>> could not see my virtual field, nor the expression I used to create it.
>> Have I missed a trick somewhere?
>>
>> Regards,
>> Z
>>
>> On 2014/11/07 18:25, Andreas Neumann wrote:
>>> Hi,
>>>
>>> What you probably ask for are database triggers combined with 
>>> storage. This is not what virtual fields are for. If they were 
>>> stored - they wouldn't be called virtual ;-)
>>>
>>> You can do that f.e. with Postgis. With shapefiles not. However, if 
>>> you share the project with the other PC, the virtual fields work fine.
>>>
>>> Andreas
>>>
>>> On 07.11.2014 17:21, Zoltan Szecsei wrote:
>>>> Hi Matthias,
>>>> Thanks for the quick answer.
>>>> The virtual field acts just like I want it to, except that it does 
>>>> not permanently store the column in the attribute table.
>>>> I tried getting clever by then adding a second 'Field Calculation' 
>>>> to update the existing 'Sheet' field from the virtual field, but 
>>>> that won't do it either.
>>>>
>>>> So, for me there are two shortcomings:
>>>>
>>>>  1. To be able to store and recall the 'Expression' and not lose it
>>>>     after closing the Field Calculator
>>>>  2. To be able to add the virtual fields that you create, into the
>>>>     attribute table.
>>>>  3. (And then of course to re-open the Shape file on another PC and
>>>>     have these Field Calculations still functional)
>>>>
>>>> Any further possibilities I can try?
>>>>
>>>> Regards & thanks again,
>>>> Zoltan
>>>>
>>>>
>>>> On 2014/11/07 18:01, Matthias Kuhn wrote:
>>>>> Hi Zoltan,
>>>>>
>>>>> Since QGIS 2.6 this possibility exists. It is called "Virtual Field".
>>>>> You must not create the attribute when creating the shapefile. Just open
>>>>> the field calculator, create a new field in there and check the "virtual
>>>>> field" checkbox.
>>>>>
>>>>> Regards,
>>>>> Matthias
>>>>>
>>>>> On 07.11.2014 16:54, Zoltan Szecsei wrote:
>>>>>> Hi,
>>>>>> I'm using QGIS 2.6.0 on Win 7 x64 - installed via OSGEO4w
>>>>>>
>>>>>> Is there a way to store your field calculator expression to always
>>>>>> process and update that specific field, should geometry be edited or
>>>>>> created for that Layer?
>>>>>>
>>>>>> Let's say I want to create a blank POINT shape file, with a text
>>>>>> attribute called "Sheet".
>>>>>> Whenever a POINT is created or moved, I want this field to be
>>>>>> dynamically updated with:
>>>>>>
>>>>>>       tostring(abs(toint($y)))+tostring(abs(toint($x)))
>>>>>>
>>>>>> For testing thus far have:
>>>>>>
>>>>>>    * created 2 points
>>>>>>    * Opened the field calculator, clicked 'Update Existing Field' and
>>>>>>      put in the expression.
>>>>>>    * The two existing points now have the correct TEXT values in the
>>>>>>      Sheet field
>>>>>>    * I close the Field calculator
>>>>>>    * Create a new point in my layer
>>>>>>    * open the attribute table to find that the 'Sheet' field for this
>>>>>>      new point is blank
>>>>>>    * I open the Field Calculator and I cannot even find a way to call
>>>>>>      back the previous expression I used.
>>>>>>
>>>>>>
>>>>>> Am I using the correct QGIS functionality to achieve what I need to,
>>>>>> and if so, where am I going wrong?
>>>>>>
>>>>>> Thanks & regards,
>>>>>> Zoltan
>>>>>>
>>>>>>
>>>>>> -- 
>>>>>>
>>>>>> ===========================================
>>>>>> Zoltan Szecsei PrGISc [PGP0031]
>>>>>> Geograph (Pty) Ltd.
>>>>>> GIS and Photogrammetric Services
>>>>>>
>>>>>> P.O. Box 7, Muizenberg 7950, South Africa.
>>>>>>
>>>>>> Mobile: +27-83-6004028
>>>>>> Fax:    +27-86-6115323www.geograph.co.za
>>>>>> ===========================================
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Qgis-developer mailing list
>>>>>> Qgis-developer at lists.osgeo.org
>>>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>>
>>>>
>>>> -- 
>>>>
>>>> ===========================================
>>>> Zoltan Szecsei PrGISc [PGP0031]
>>>> Geograph (Pty) Ltd.
>>>> GIS and Photogrammetric Services
>>>>
>>>> P.O. Box 7, Muizenberg 7950, South Africa.
>>>>
>>>> Mobile: +27-83-6004028
>>>> Fax:    +27-86-6115323www.geograph.co.za
>>>> ===========================================
>>>>
>>>>
>>>> _______________________________________________
>>>> Qgis-developer mailing list
>>>> Qgis-developer at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>
>>>
>>>
>>> _______________________________________________
>>> Qgis-developer mailing list
>>> Qgis-developer at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>> -- 
>>
>> ===========================================
>> Zoltan Szecsei PrGISc [PGP0031]
>> Geograph (Pty) Ltd.
>> GIS and Photogrammetric Services
>>
>> P.O. Box 7, Muizenberg 7950, South Africa.
>>
>> Mobile: +27-83-6004028
>> Fax:    +27-86-6115323www.geograph.co.za
>> ===========================================
>>
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer


-- 

===========================================
Zoltan Szecsei PrGISc [PGP0031]
Geograph (Pty) Ltd.
GIS and Photogrammetric Services

P.O. Box 7, Muizenberg 7950, South Africa.

Mobile: +27-83-6004028
Fax:    +27-86-6115323     www.geograph.co.za
===========================================

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20141107/5ba1975e/attachment.html>


More information about the Qgis-developer mailing list