Skip to content

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

Notifications You must be signed in to change notification settings

rohitsinghsalyan/polygeohasher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages