Skip to content

Calculates the centroid of a polygon from a given KML file

License

Notifications You must be signed in to change notification settings

ov3qPI/polygon_centroid_computer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

polygon_centroid_computer

Calculates the centroid of a polygon from a given KML file

Requirements

  • Python 3
  • shapely library
  • fastkml library
  • pygeoif library

Install dependencies via pip:

pip install shapely fastkml pygeoif

Usage

To run the script, use the following command:

./polygon_centroid_computer.py <path_to_kml_file>

Output

The script prints the centroid coordinates (x, y) of the first polygon found in the KML file.

Example

./polygon_centroid_computer.py example.kml
Centroid: (longitude, latitude)

Error Handling

  • If no polygon is found, a ValueError is raised.
  • If an incorrect number of arguments is provided, usage instructions are printed.

Notes

  • The script examines KML files for Placemarks containing polygon geometry and computes the centroid of the first polygon found.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Calculates the centroid of a polygon from a given KML file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages