My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
PolygonCentroid  
Using a simple algorithm to find the centroid of a polygon
Updated Oct 22, 2011 by tokland@gmail.com

Introduction

The algorithm:

http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon

Ruby code:

http://code.google.com/p/tokland/source/browse/trunk/centroid

Example: find the center of Catalonia

KML used: http://tokland.googlecode.com/files/catalunya.kml

(see it in Google maps: http://g.co/maps/qfa9e)

$ wget http://tokland.googlecode.com/svn/trunk/centroid/center.rb
$ ruby center.rb
Long: 1.5286424793097 Lat: 41.7982954227561
http://maps.google.es/maps?cx=w&q=1.5286424793097E+41.7982954227561N&z=13

Center: http://maps.google.es/maps?cx=w&q=1.5286424793097E+41.7982954227561N&z=13


Sign in to add a comment
Powered by Google Project Hosting