1

The columns containing X and Y strings look like

-1234,56

So far i tried:

geom_from_wkt(concat('POINT(',replace("wbr_komplett.X",',','.'),',', replace("wbr_komplett.Y" ,',','.'),' )'))

and also:

geom_from_wkt('POINT( '|| replace("wbr_komplett.X",',','.') ||','||replace("wbr_komplett.Y" ,',','.') || ' )')

Both to no avail. After saving the edits and closing the session the desired features still don't have a valid geometry. The layer in question is a Geopackage. As far as i can tell both queries are correct - also they wouldn't be executable if they were not.

  • 1
    it should be geom_from_wkt('POINT(X Y)') (i.e. remove the coma between X and Y) – JGH Sep 12 at 12:45
  • 1
    I've tested your query - maybe the problem is that you missed whitespace? I mean when I print geom_from_wkt (concat('POINT(',replace('-1234,56',',','.'),',',replace('-1234,56' ,',','.'),' )')) in QGIS field calculator, I get NULL otherwise I print geom_from_wkt (concat('POINT(',replace('-1234,56',',','.'),',',' ', replace('-1234,56' ,',','.'),' )')) I get <geometry: Point> in preview! – Jane Sep 12 at 12:47
  • @JGH is correct, WKT format without comma between x y coordinates – Jane Sep 12 at 12:52
  • Actually space ' ' did the trick. Sloppy me, I should've looked closer to the example shown on the right panel of field calculator. However without the space it did not work with either query. I can only guess it might be due to the dash prefix in the coordinates. So feel free to post your comment as answer I'll mark it then. An additional thought from my side on that comma orgy: It would be nice to have a more pythonic synthax avaliable like '{}'.format(). – maxwhere Sep 12 at 13:31
  • Can you write this in an answer? – vinh Sep 12 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.