Wednesday, November 26, 2008

Calculating Polygon Centroids in GeoMedia

GeoMedia's Functional Attributes or Update Attributes commands can be used to calculate the centroid of polygon geometries. For instance, in the screen shot below, I have two polygon geometries that I want to calculate the centroid coordinates and I want to store the values as database attributes associated with the geometries.

At the moment, the polygon geometries' database attributes are blank as shown below.

The steps are as follows:
  1. In GeoMedia, select Edit > Attribute > Update Attributes.

    The Update Attributes dialog box appears.

  2. In the Update features in box, expand your read/write connection node and select the polygon feature you want to update e.g. BLDG_OUTLINE.

    The Update Attributes dialog box may look like this.

  3. Click the cursor on the attribute field you want to update with the polygon geometries' centroid X coordinate e.g. XCOORD.

  4. Click Expression.

    The Expression dialog box appears.

  5. In the Expression field, type in the following string:
    X(CENTERPOINT(Input.Geometry), Constant.ProjectedMeas, Constant.METER))

    Note: Replace Input.Geometry with the name of your geometry field. The RefSpace argument can be either Constant.ProjectedMeas or Constant.TrueMeas. The UnitOfMeasure argument can be angular units (if Constant.TrueMeas is used) or linear units like Constant.METER, Constant.INCH, etc.

    The Expression dialog box may look like this.

  6. Click OK.

  7. Repeat the steps 3 to 7 for the Y coord field. The expression string for the Y coord may look like this:

    Y(CENTERPOINT(Input.Geometry), Constant.ProjectedMeas, Constant.METER))

    At the end, the Update Attributes dialog box may look like this.

  8. Click Apply.

    The centroids of the polygon geometries are calculated and updated into the attribute fields.

  9. Click Close.

If you review the attributes of the polygon geometries, you may see the following. Note that the XCOORD and YCOORD fields have been updated with the calculated centroid coordinates.

No comments:

Related Posts with Thumbnails