Re: Re: [Qgis-user] Globally Unique Indentifier (GUID) in QGIS

2011-05-06 Thread Alexander Bruy
Hi,

here is script to fill vector layer fields with GUIDs. It can be
executed from QGIS Python console

import uuid

layer=qgis.utils.iface.activeLayer() # get active layer
fieldNum=layer.fieldNameIndex("UID") # get field that should be filled
with GUIDs

layer.startEditing() # start editing
feat = QgsFeature()
layer.select()
while layer.nextFeature(feat):  # iterate over features
layer.changeAttributeValue(feat.id(), fieldNum, str(uuid.uuid4())) #
fill field with GUID
layer.commitChanges() # save edits

Hope this helps

2011/5/6 Błażej Zamojski :
> Thanks,
> not really GUID solution but useful. Maybe GUID should be implemented in the
> future?
>
> Regards
> Blazej Zamojski
>
> -Original Message-
> From: Robert Szczepanek [mailto:rob...@szczepanek.pl]
> Sent: Thursday, May 05, 2011 12:44 PM
> To: Błażej Zamojski
> Cc: qgis-user@lists.osgeo.org
> Subject: [SPAM] Re: [Qgis-user] Globally Unique Indentifier (GUID) in QGIS
>
> Hi Blazej,
>
> Fast but not "true GUID" solution:
> - open attribute table
> - start editing
> - run 'field calculator' icon (kalkulator pól)
> - GUID as name for new field
> - $rownum in expressions area
>
> You are welcome to polish forum [1], as your QGIS interface is probably
> in polish.
>
> regards,
> Robert
>
> [1] http://forum.quantum-gis.pl/
>
> W dniu 05.05.2011 11:26, Błażej Zamojski pisze:
>> Hi
>> Is there a way to add a GUID type data field in attribute table for a
>> shapefile?
>>
>> Regards
>> Blazej Zamojski
>>
>> ___
>> Qgis-user mailing list
>> Qgis-user@lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>



-- 
Alexander Bruy
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


RE: Re: [Qgis-user] Globally Unique Indentifier (GUID) in QGIS

2011-05-05 Thread Błażej Zamojski
Thanks,
not really GUID solution but useful. Maybe GUID should be implemented in the
future?

Regards
Blazej Zamojski

-Original Message-
From: Robert Szczepanek [mailto:rob...@szczepanek.pl] 
Sent: Thursday, May 05, 2011 12:44 PM
To: Błażej Zamojski
Cc: qgis-user@lists.osgeo.org
Subject: [SPAM] Re: [Qgis-user] Globally Unique Indentifier (GUID) in QGIS

Hi Blazej,

Fast but not "true GUID" solution:
- open attribute table
- start editing
- run 'field calculator' icon (kalkulator pól)
- GUID as name for new field
- $rownum in expressions area

You are welcome to polish forum [1], as your QGIS interface is probably 
in polish.

regards,
Robert

[1] http://forum.quantum-gis.pl/

W dniu 05.05.2011 11:26, Błażej Zamojski pisze:
> Hi
> Is there a way to add a GUID type data field in attribute table for a
> shapefile?
>
> Regards
> Blazej Zamojski
>
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Globally Unique Indentifier (GUID) in QGIS

2011-05-05 Thread Robert Szczepanek

Hi Blazej,

Fast but not "true GUID" solution:
- open attribute table
- start editing
- run 'field calculator' icon (kalkulator pól)
- GUID as name for new field
- $rownum in expressions area

You are welcome to polish forum [1], as your QGIS interface is probably 
in polish.


regards,
Robert

[1] http://forum.quantum-gis.pl/

W dniu 05.05.2011 11:26, Błażej Zamojski pisze:

Hi
Is there a way to add a GUID type data field in attribute table for a
shapefile?

Regards
Blazej Zamojski

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user



___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Globally Unique Indentifier (GUID) in QGIS

2011-05-05 Thread Błażej Zamojski
Hi
Is there a way to add a GUID type data field in attribute table for a
shapefile?

Regards
Blazej Zamojski

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user