# centroid

return type | Object ( GeoJSON Point )
syntax | $.geo.centroid( Object shape ( GeoJSON object ) )

usage

    var centroid = $.geo.centroid( {
          type: "Polygon",
          coordinates: [[
            [-75, 39.7],
            [-74.8, 39.3],
            [-75.2, 39.3],
            [-75, 39.7]
          ]]
    } )

The centroid method calculates the center of mass for the passed-in basic GeoJSON geometry object. The basic geometry types are Point, LineString and Polygon.

Technically, only Polygons can be considered to have mass. However, a centroid can be calculated for other geometry types. This method operates on LineStrings as if they were closed polygons and the centroid will likely not lie along the line. The centroid of a Point is a clone of the Point.

If the argument is not a basic GeoJSON geometry object, this function returns undefined.

This function is similar to Geometry.getCentroid in JTS.