joyanujoy / geolib Goto Github PK
View Code? Open in Web Editor NEWPython geohash library
License: MIT License
Python geohash library
License: MIT License
_fixedpoint() has a side effect on decimal context.
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import geolib.geohash
>>> import decimal
>>> decimal.getcontext().prec
28
>>> geolib.geohash.decode('9q8')
Point(lat=Decimal('37.265625'), lon=Decimal('-123.046875'))
>>> decimal.getcontext().prec
1
>>> decimal.Decimal('17') % 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
decimal.InvalidOperation: [<class 'decimal.DivisionImpossible'>]
Expect decimal to be unchanged.
It seems that the sdist archive at pypi is missing some files which are all present when building the sdist (locally), for example the LICENSE file and the docs & tests directory.
I run into substring not found Error
when attempting to find neighbors for a geohash. I am passing geohash of type string, as per the documentation, however, I am still seeing this issue. Here's my code:
import pandas as pd
import pygeohash as gh
from geolib import geohash
geo_dict = {'9q5dx': 10, '9q9hv': 15, '9q5dv': 20}
df = pd.DataFrame({'geohash': ['9q5dx','9qh0g','9q9hv','9q5dv'],
'label': ['a', 'b', 'c', 'd']})
try:
df['value'] = df.apply(lambda x : geo_dict[x.geohash], axis=1)
except Exception as e:
g = str(e)
print(g, type(g))
neighbours = geohash.neighbours(g)
`9qh0g' <class 'str'>`
ValueError Traceback (most recent call last)
<ipython-input-488-e803623c09eb> in <module>
18 print(g, type(g))
19
---> 20 neighbours = geohash.neighbours(g)
21
~/opt/anaconda3/lib/python3.8/site-packages/geolib/geohash.py in neighbours(geohash)
254 >>> gcpuypm
255 """
--> 256 n = adjacent(geohash, 'n')
257 ne = adjacent(n, 'e')
258 e = adjacent(geohash, 'e')
~/opt/anaconda3/lib/python3.8/site-packages/geolib/geohash.py in adjacent(geohash, direction)
232 parent = adjacent(parent, direction)
233
--> 234 index = neighbour[direction][typ].index(last_char)
235 return parent + base32[index]
236
ValueError: substring not found
When I hard code it, I get the expect result:
geohash.neighbours('9qh0g')
Neighbours(n='9qh15', ne='9qh1h', e='9qh0u', se='9qh0s', s='9qh0e', sw='9qh0d', w='9qh0f', nw='9qh14')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.