connor-makowski / geojson-centroid-calculator

A simple calculator for geojson centroids

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GeoJSON Centroid Calculator

Methods for Calculating GeoJSON object centroids.

Features

  • Allows users to calculate geoJSON centroids and output them to JSON file

Project Organization

This project is organized in the following manner:

Root directory: Contains all code needed to run the GeoJSON Centroid Calculator.
  • centroidcalculator.py: File containing functions for calculation of centroids.
  • run.py: Easy access edit point for quick use
  • zip3.json: Example json file of 3 digit zip codes in the US
  • zip3Centroid.json: Example output json file

Prerequisites

This project uses an extra package to work properly:

  • [json] - A lightweight data interchange inspired by java script

How to Use

Make sure you have Python 3.6.x installed on your system. You can download it here.

Linux

  1. Clone this repo in your preferred directory:
    $ git clone https://github.com/connor-makowski/geojson-centroid-calculator.git
  2. Go to the root directory of the project using the cd command.
    $ cd geojson-centroid-calculator

Getting Started

  1. Put your GeoJSON data in the root project folder.
  • Your data should follow the GeoJSON pattern
    • An example can be found at zip2.json
  1. Open up the run.py file with your favorite text editor.

  2. Edit infile= (line 3) to exactly match your input data. For example:

    infile='zip3.json'
  3. Edit outfile= (line 3) to exactly match your output data. For example:

    outfile='zip3Centroid.json'
  4. Edit propertiesId= (line 3) to exactly match an identifier in your GeoJSON properties object. For example:

    propertiesId='ZIP3'

Run Your Model

Use Python to execute the run.py file. This will import the centroidcalculator.py file and your data to process the results.

$ python run.py

Your output will be located in the same folder under the outfile you specified.

License

Copyright (c) 2018 Connor Makowski

About

A simple calculator for geojson centroids


Languages

Language:Python 100.0%