I have a table that has a few polygons. I would like to extract the centroid of each polygon and fill up the columns named, Cent_X, and Cent_Y.

The syntax for getting the centroid is CentroidX(obj) and CentroidY(obj). A statement like this doesn't work:

    Update TableA
        Set Cent_X = CentroidX(Obj)

Can anyone please help?

  • What is the field type for Cent_X and Cent_Y? – Fezter Jan 12 '17 at 3:24
  • 1
    Can you clarify what you mean by "it doesn't work"? Are you getting an error? Are you getting different values in the field? Does nothing happen at all? – Fezter Jan 12 '17 at 5:30

Before Update statement set coordinate system first:

Set CoordSys <some coordinate system specification>

And field type for the column Cent_X should be Float.

Also, check if TableA has some records without object (if this is the case then your statement should throw an error, but you did not said what is exactly the problem):

select * from TableA where not Obj into Selection
browse * from Selection

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.