AFAIK xmin, ymin is not available in QGIS 2.2, you must upgrade to 2.4.

Zoltan

On Thu, 28 Aug 2014, Alexandre Neto wrote:

Ups, my bad...

You can get your features centroid using the function centroid(). It will
return a point geometry, then you can get the x and y by using either x_min
or x_max and y_min or y_max. Like this:

 xmin( centroid( $geometry )) || ' , ' || ymin( centroid( $geometry ))

Alexandre Neto


On Thu, Aug 28, 2014 at 10:29 AM, Leo Kris Palao <[email protected]> wrote:

Hi Alexander,

Thanks for your reply. In my understanding, this only applies if I have
point coordinates, right? If I have polygons I think I need another syntax?

I can create centroids in Vector > Geometry > Polygon Centroids tool then
apply $x and $y to extract lat lon coordinates, but in some cases I want to
skip this process if I am dealing with more than 300 thousand features in
my polygon layer.

Thanks,
-Leo


On Thu, Aug 28, 2014 at 3:01 PM, Alexandre Neto <[email protected]>
wrote:

Hello Leo,

That's quite straightforward actually. In the field calculator (or in any
other instance of expression builder) there are 2 geometry functions to
achieve what you need,  $x and $y.

You can either put them in separate fields or create a string to populate
a single one. Something like this,

$x || ' , ' || $y

Would produce something like this:

'1234.56 , 9876.43'

Notice that the double pipe character || works as a string concatenator.
And that the result is a string therefore not useful for any arithmetic
operations after.

Hope this helped.

Best regards,

Alexandre Neto
Em 27/08/2014 22:37, "Leo Kris Palao" <[email protected]> escreveu:

Hi QGIS users,

I don't know if this question has been asked before.

Can you help me create a syntax in field calculator to add in the
attribute table the centroids coordinates for each or selected polygon
features?

I am using Qgis 2.2 "Valmiera" version in Windows.

Thanks in advance for help,
-Leo

_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user




_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to