[GIS] Сalculate polygon centroids with ‘point on surface’ function

centroidsminidumpqgis

I want to calculate centroid coordinates X_center and Y_center for every polygon in layer so that in case polygon has not simple shape (e.g. with holes or like in the picture below) centroid will be in the polygon anyway:

enter image description here

I found 'point on surface' function in QGIS, that returns a point guaranteed to lie on the surface of a geometry. BUT When trying to calculate coordinates with the function, dump happens, although qgis shows output preview correctly –

enter image description here

I found similar question but the following answer implicates new point layer creation, that is useless for me – I want to get centroid coordinates in the same layer.

Interesting, when creating virtual field – it calculates, I can even pick the polygon and see coordinates, but when opening attribute table, qgis crushes.

enter image description here

What is wrong?

Best Answer

Sounds like something in your geometry is causing the issue. I'd check your geometry validity, and also open a bug report for qgis and attach your original dataset.