GithubHelp home page GithubHelp logo

rohitsinghsalyan / polygeohasher Goto Github PK

View Code? Open in Web Editor NEW
38.0 3.0 4.0 4.23 MB

A complete package to work with polygons and geohashes. Optimisation of Geohash levels to cover and area with % error controlled by user. Also allows to convert geohases to polygons.

License: Other

Python 100.00%
geohash gis

polygeohasher's Introduction

polygeohasher

polygeohasher is a python package to implement polygon to geohash and vice versa with optimisation of geohash levels as per the user requirement, with error rate being controlled by the user.

Installation

Use the package manager pip to install polygeohasher.

pip3 install polygeohasher

Poetry: Add package to lock file

poetry add polygeohasher

Usage

from polygeohasher import polygeohasher
import geopandas as gpd

# read geojson(geometry) file
gdf = gpd.read_file("your geospatial file format") # read your geometry file here

# initialize polygeohasher
pgh = polygeohasher.Polygeohasher(gdf)

# declare geohash levels
INPUT_GEOHASH_LEVEL = 6
MINIMUM_GEOHASH_LEVEL = 5
MAXIMUM_GEOHASH_LEVEL = 7

# create a dataframe with list of geohashes for each geometry
initial_df = pgh.create_geohash_list(INPUT_GEOHASH_LEVEL,inner=False)

# get a dataframe with optimized list of geohashes
final_df = pgh.geohash_optimizer(initial_df, MINIMUM_GEOHASH_LEVEL, MAXIMUM_GEOHASH_LEVEL, INPUT_GEOHASH_LEVEL) 

# prints optimization summary
pgh.optimization_summary(initial_df, final_df)

# convert geohash to geometry
geo_df = pgh.geohashes_to_geometry(final_df, "geohash_column_name")

# write file in desired spatial file format
geo_df.to_file("your write path.format",driver = "GeoJSON") 

Following is the optimization summary:

--------------------------------------------------
            OPTIMIZATION SUMMARY
--------------------------------------------------
Total Counts of Initial Geohashes :  2597
Total Counts of Final Geohashes   :  837
Percent of optimization           :  67.77 %
--------------------------------------------------

Some visualisations

study_area

Study are consist of division of City of Bengaluru in India.

primary_output

Primary Output of geohashes without any optimisation.

secondary_output

Final Output of geohashes with optimization of number of geohashes at different levels to cover an area.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Apache License, Version 2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.