Comments (6)
Nope. I am not sure what you want to achieve, but of course you could simply write yourself a little script that calls timezonefinder (s. readme for instructions on that) just with the bash arguments as input. See http://stackoverflow.com/questions/7521061/how-to-pass-a-bash-variable-to-python
from timezonefinder.
Thanks for tha answer; That's what I guessed. No way to directly call the timezonefinder.py directly.
I'm gonna see how to write my own little py script (I'm not familiar at all with python) using os.environ to get some parameters (here lat,lon) and call timezonefinder.py...
It would be great that timezonefinder.py could be called by command line directly (or thru another file). Even if timezonefinder.py is a python script, the clients are not always python-based... it would increase the number of possible clients ;-)
from timezonefinder.
I tried with this little wrapper:
#!/usr/bin/env python
import sys
import os
from timezonefinder import TimezoneFinder
if len(sys.argv) < 2:
print 'Usage: ' + sys.argv[0] + ' '
sys.exit(1)
def main():
tf = TimezoneFinder()
latitude = float(sys.argv[1])
longitude = float(sys.argv[2])
print 'Looking for TZ at lat=',latitude,' lon=',longitude
tz = tf.timezone_at(lng=longitude, lat=latitude)
print 'Timezone=',tz
if name == 'main':
main()
And call it with:
python callbyenv.py 45 -1
Get:
Looking for TZ at lat= 45.0 lon= -1.0
Traceback (most recent call last):
File "callbyenv.py", line 19, in
main()
File "callbyenv.py", line 15, in main
tz = tf.timezone_at(lng=longitude, lat=latitude)
File "/home/opt/timezonefinder/timezonefinder/functional.py", line 27, in wrapper
return func(*args, **kwargs)
File "/home/opt/timezonefinder/timezonefinder/timezonefinder.py", line 448, in timezone_at
possible_polygons = self.shortcuts_of(lng, lat)
File "/home/opt/timezonefinder/timezonefinder/timezonefinder.py", line 169, in shortcuts_of
return fromfile(self.binary_file, dtype='<u2', count=nr_of_polygons)
TypeError: data type not understood
Sorry for my inexperienced in python language; but I cant figure out what's wrong with this; looks very close to the example.
from timezonefinder.
I am looking into this right now, but it might take a little while.
from timezonefinder.
Ok, I called this script:
#!/usr/bin/env python
import sys
from timezonefinder import TimezoneFinder
if len(sys.argv) < 2:
print('Usage: ' + sys.argv[0])
sys.exit(1)
tf = TimezoneFinder()
latitude = float(sys.argv[1])
longitude = float(sys.argv[2])
print('Looking for TZ at lat=',latitude,' lon=',longitude)
tz = tf.timezone_at(lng=longitude, lat=latitude)
print('Timezone=',tz)
with:
python3 scrapyard.py -45 1
and that gives me:
Looking for TZ at lat= -45.0 lon= 1.0
Timezone= None
So I guess there is something wrong with your installation (maybe numpy is missing?!). Try installing with pip or conda. That should work.
I think about including a little script in the next release. Thanks for the suggestion.
from timezonefinder.
Argh, doesn't work on my CentOS 6.8 with Python 2.6.6-66.el6_8. Still get the same error.
I've downloaded Python 3.0.1 version from https://www.python.org/ftp/python/3.0.1/Python-3.0.1.tgz; and built it on my CentOS 6.8 OS. Here is the result with Python3:
$ /opt/Python-3.0.1/python scrapyard.py -45 1
Traceback (most recent call last):
File "scrapyard.py", line 3, in
from timezonefinder import TimezoneFinder
File "/home/opt/timezonefinder/timezonefinder/init.py", line 3, in
from .timezonefinder import TimezoneFinder
File "/home/opt/timezonefinder/timezonefinder/timezonefinder.py", line 8, in
from numpy import array, empty, fromfile
ImportError: No module named numpy
The numpy error is wired; I've installed it using pip install numpy:
$ pip install numpy
Requirement already satisfied: numpy in /usr/lib64/python2.6/site-packages
Is there a path to specify somewhere? An environment variable to set?
EDIT: Ok; I've found that Python 3 requires numpy 1.5.0; I've got numpy 1.4.1 with Python 2.6.6. I'm gonna compile the numpy 1.5.0 and try to link it with my new Python 3...
from timezonefinder.
Related Issues (20)
- Does the database also contains the country? HOT 1
- Decrease in time performance from version 6.0.2 to version 6.1.9 and bug with numpy 1.24.2 HOT 3
- Clarify resource usage and mention alternatives HOT 2
- Lock pytz or tzdata version in requirements? HOT 4
- Improve tests HOT 5
- parameterised functions for accessing binary file data
- improve class attribute documentation
- improve initialisation time HOT 5
- Data conversion: parallel shortcut computation
- CI/CD: `set-output` command is deprecated HOT 1
- CI/CD: use kebab-case for inputs
- CI/CD: Node.js 12 actions are deprecated HOT 1
- use poetry dependency group specification HOT 2
- RuntimeError: cannot cache function 'inside_polygon' HOT 2
- Bump h3 version HOT 5
- Python 3.12 compatibility HOT 5
- `not enough values to unpack (expected 4, got 0)` in outside_the_boundaries_of HOT 6
- Release 2023d HOT 1
- Cannot install timezonefinder HOT 9
- Building from source HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timezonefinder.