SQL Centroid(geometry)

31 views
Skip to first unread message

Kyle Felipe Vieira Roberto

unread,
Jan 15, 2018, 12:22:22 PM1/15/18
to SpatiaLite Users
Hi guys.....

I'm realy living use spatialite here, and i have a question,

The function Centroid(geometry) return the center from bounding box of geometry or returns the real centroid.


If is the bounding box, there is a way to get the real centroid?


Jukka Rahkonen

unread,
Jan 15, 2018, 12:50:38 PM1/15/18
to spatiali...@googlegroups.com, Kyle Felipe Vieira Roberto
Hi,

The OGC Simple feature standard
http://portal.opengeospatial.org/files/?artifact_id=25355 defines
centroid as

"Centroid ( ): Point — The mathematical centroid for this Surface as a
Point. The result is not guaranteed to
be on this Surface."

What ST_Centroid returns is the real centroid according to this
definition, the centre of gravity of the feature. Bounding box has
nothing to do with that. What you would like to call as "real centroid"
is closer to another method that is defined in the standard:
PointOnSurface ( ): Point — A Point guaranteed to be on this Surface.

However, PointOnSurface can be in any place on the surface.

-Jukka Rahkonen-

Kyle Felipe Vieira Roberto kirjoitti 2018-01-15 19:22:
> Hi guys.....
>
> I'm realy living use spatialite here, and i have a question,
>
> The function Centroid(geometry) return the center from bounding box of
> geometry or retur"ns the real centroid.
>
> [1]
>
> If is the bounding box, there is a way to get the real centroid?
>
> --
> You received this message because you are subscribed to the Google
> Groups "SpatiaLite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to spatialite-use...@googlegroups.com.
> To post to this group, send email to
> spatiali...@googlegroups.com.
> Visit this group at https://groups.google.com/group/spatialite-users.
> For more options, visit https://groups.google.com/d/optout.
>
>
> Links:
> ------
> [1]
> https://lh3.googleusercontent.com/-7PQ3TQrmBng/WlziV8ghinI/AAAAAAAATfI/l2iyPbCPXG0yW0hYTpwzIZM-FGDxEwlFgCLcBGAs/s1600/duvida.png

a.fu...@lqt.it

unread,
Jan 15, 2018, 12:55:35 PM1/15/18
to spatiali...@googlegroups.com
On Mon, 15 Jan 2018 09:22:22 -0800 (PST), Kyle Felipe Vieira Roberto
wrote:
> Hi guys.....
>
> I'm realy living use spatialite here, and i have a question,
>
> The function Centroid(geometry) return the center from bounding box
> of
> geometry or returns the real centroid.
>

Hi Kyle,

it obviously returns the real centroid.

note: depending on the specific shape of your geometry the centroid
can eventually fall outside the geometry itself, as you can see in
the attached figure.

SELECT ST_Union( g.geom, ST_Centroid( g.geom ))
FROM (SELECT ST_GeomFromText('POLYGON((0 0, 2 0, 2 8, 5 8, 5 6, 10 6,
10 10, 0 10, 0 0))') AS geom) AS g;

bye Sandro

centroid.png

Kyle Felipe Vieira Roberto

unread,
Jan 15, 2018, 1:34:32 PM1/15/18
to SpatiaLite Users
@All thx for helping...
PointOnSurface, as @Jukka says, works like a charm...

I was using QGIS, plugin REALCENTROID, to force the centroids inside a poligons... This function will work for mee...

I wish, later, send a contribution... where can i do this?
Its not a good one (for now) but, at least, will help pay a pizza or a beer... KKK

Thx very much....

a.fu...@lqt.it

unread,
Jan 15, 2018, 2:04:18 PM1/15/18
to spatiali...@googlegroups.com
On Mon, 15 Jan 2018 10:34:32 -0800 (PST), Kyle Felipe Vieira Roberto
wrote:
> I wish, later, send a contribution... where can i do this?
>

Kyle,

send your proposal to my personal mailbox:
<a.fu...@lqt.it>

bye Sandro


Reply all
Reply to author
Forward
0 new messages