[OSGeo Africa] QGIS Field Calculator - attributes for 2 layers
Tim Sutton
tim at kartoza.com
Fri Jul 8 07:53:04 PDT 2016
Hi
> On 08 Jul 2016, at 4:07 PM, David Barkhuisen <dave at kirchhoffsurveyors.co.za> wrote:
>
> Hi Tim, Zoltan
>
> Just a quick one with the query below.
>
> Will it not be easier to move both tables into postgis db.
> Add empty lat and long columns to B then using SQL update the table to pull the data from A to B
> something like:
>
> UPDATE B
> SET B.long = A.long
> B.Lat = A.lat
>
> From A
> JOIN B
> ON ST_Intersects(A.geom, B.geom)
>
> Would that not be an easier method?
>
Yes absolutely - my answer was more intended to be academic ("how could one do this in QGIS"). Given a choice doing it in PostGIS is going to be far more efficient...
Regards
Tim
> Regards
> David
>
>
> On 08/07/2016 12:37, Tim Sutton wrote:
>> Hi
>>
>>> On 08 Jul 2016, at 11:30 AM, Zoltan Szecsei <zoltans at geograph.co.za <mailto:zoltans at geograph.co.za>> wrote:
>>>
>>> Hi again,
>>> OK - it's not an index thing. More than one 'a' polygon has received the 'b' attribute from the wrong 'b' polygon even though the coordinate is inside the correct 'b' polygon.
>>>
>>> So the next step is to suspect the index.intersects result.
>>
>> Could you share a small testable dataset that replicates it? I made a noddy test dataset here when playing with it last night which worked fine, but it only had 2 polygons in it...
>>
>>> Note the coords are in LatLong "small numeric values. I can see we are using a null-length box (ie: a point) to select from 'b'.
>>> What is the internal precision of the QgsPoint?
>>
>> the x and y properties of QgsPoint are both doubles...it depends on your platform what that means but typically
>>
>> http://qgis.org/api/2.6/classQgsPoint.html <http://qgis.org/api/2.6/classQgsPoint.html>
>>
>> According to wikipedia on a 64 bit machine it should be:
>>
>> Sign bit <https://en.wikipedia.org/wiki/Sign_bit>: 1 bit
>> Exponent <https://en.wikipedia.org/wiki/Exponent> width: 11 bits
>> Significand <https://en.wikipedia.org/wiki/Significand> precision <https://en.wikipedia.org/wiki/Precision_%28arithmetic%29>: 53 bits (52 explicitly stored)
>>
>>
>>
>>> My coord attributes are 'double Real 19,10'
>>>
>>> In a script, when you select with a point, what is the snapping tolerance?
>>
>> To use snapping you would need to use the QGIS snapping api - otherwise absolute geometry operations are being done.
>>
>>> My project CRS is epsg 4326 - so it should be OK.
>>
>> Yup. If you wanted to be fancy, you could extract a layer of the tie points (FptnLat. FptnLong) so that you can actually visualise the points in relation to the polygons. Maybe you have some that don't actually intersect a poly...
>>
>>>
>>> FWIW, b.name is string 60 which is copied into a.name string 32 - but the contents are shorter that 32 chars.
>>
>> I think QGIS will just truncate it if the name is longer than 32 chars.
>>
>> T
>>
>>>
>>> Any thoughts anyone?
>>>
>>> Regards,
>>> Zoltan
>>>
>>
>>
>>
>> _______________________________________________
>> Africa mailing list
>> Africa at lists.osgeo.org <mailto:Africa at lists.osgeo.org>
>> You can UNSUBSCRIBE at http://lists.osgeo.org/mailman/listinfo/africa <http://lists.osgeo.org/mailman/listinfo/africa>
> _______________________________________________
> Africa mailing list
> Africa at lists.osgeo.org
> You can UNSUBSCRIBE at http://lists.osgeo.org/mailman/listinfo/africa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/africa/attachments/20160708/30eef25c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.osgeo.org/pipermail/africa/attachments/20160708/30eef25c/attachment-0001.sig>
More information about the Africa
mailing list