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

polygeohasher's People

Contributors

khadkakrishna avatar rohitsinghsalyan avatar snadorp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

polygeohasher's Issues

Question on optimization

Hi hi,

Thank you for this great library.

I'm curious if you have thought of using a "fill" method over the reduce method being used for the creattion of optimized list of geohashes?

I ask because the current approach can be very time consuming and I wonder if the other-way-around would speed things up.

All the best,

  • Stefán

Various spelling mistakes in code....

Just tried this repo. Works well, except for the following:

When trying the example, was getting a key error when attempting to create the geohash geometry dataframe (geo_df = ...).

Error was traced to misspelling of "opitimized_geohash_list", which should be "optimized_geohash_list"

Also, for consistency's sake, would stick with "optimize..." throughout the codebase rather than intermingle "optimize..." and "optimise.."

Best,

Mike

Tests are missing

The readme mentions to make sure to include tests for proposed changes, sadly the project does not come with any as of right now. It seems the test directory is excluded in the .gitignore file. Can those be added to the project?

Geohash column name

Hi,

May I know what would be the appropriate data type for the geohash column name in my geojson file? Currently using string as the data type for my column, I am receiving the error in the photo attached.

Thank you.
Screenshot 2023-07-06 at 5 38 55 PM

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.