thampiman / reverse-geocoder Goto Github PK
View Code? Open in Web Editor NEWA fast, offline reverse geocoder in Python
License: GNU Lesser General Public License v2.1
A fast, offline reverse geocoder in Python
License: GNU Lesser General Public License v2.1
mode=1 works ok.
mode=2
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
if there is a situation when the script could not geolocate some coordinates and return invalid place or any place, because the situation is so many coordinates in my dataset is geolocated to "Port-aux-Francais" .
I have tried to use a list of tuples for coordinates when i use a list with more than 55k example, I am facing this problem then I try to take the rest of the list but only takes a thousand then I am facing the same issue.
When I try to run the module in python 3.0 and up version, it will return an error:OverflowError: Python int too large to convert to C long. However, it should be fine when I run in python 2.0 and up 2.7 version.
Form any usage needs to filter output (for example just get country name) instead closest city. if there be this feature then the package maybe run even faster than find closest position in dataset.
And I must say thanks for your great package.
I recently started working with a fresh install of reverse-geocoder, but every time I attempt to run a simple search of coordinates, it generates a massive traceback in console. It seems the error repeats several times before 'finishing' - by which I mean, the console spits out the location at the top of the location data file.
I'm utilizing Python 3.10 in Spyder 5.2.2, all within Anaconda Navigator 2.2.0.
My versions of scipy and numpy are 1.9.0 and 1.2.3.1, respectively.
I appreciate any and all help or advice. Thank you in advance!
[Loading formatted geocoded file...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 116, in spawn_main
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
exitcode = _main(fd, parent_sentinel)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 125, in _main
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
prepare(preparation_data)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 236, in prepare
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
main_content = runpy.run_path(main_path,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 269, in run_path
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
return _run_module_code(code, init_globals, run_name,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 96, in _run_module_code
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
_run_code(code, mod_globals, init_globals,
File "C:\Users\USER1\anaconda3\envs\bravo\lib\runpy.py", line 86, in _run_code
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
exec(code, run_globals)
File "C:\Users\USER1\Documents\Python Scripts\apis\tracker.py", line 102, in <module>
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
x = rg.search((lon, lat))
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 293, in search
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
return _rg.query(geo_coords)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\__init__.py", line 127, in query
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
for p in pool: p.start()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\process.py", line 121, in start
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
self._popen = self._Popen(self)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 224, in _Popen
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\context.py", line 327, in _Popen
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
return Popen(process_obj)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\USER1\anaconda3\envs\bravo\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
Figure(1520x820)
Loading formatted geocoded file...
[{'lat': '42.57952', 'lon': '1.65362', 'name': 'El Tarter', 'admin1': 'Canillo', 'admin2': '', 'cc': 'AD'}]]
Hello,
Thank you for the great work in publishing this package. I just came across the package and was trying it out when I ran into the following error, was hoping you could shed some light on this.
import reverse_geocoder as rg
coordinates = (33, -115)
results = rg.search(coordinates) # default mode = 2
print results
The result looks something like this:
If I am not wrong, this is indicating that this location is in Mexico. However, when you actually these coordinates in Google Maps, these coordinates are within USA.
The geodetic coordinates (lat,lon,alt) are used in the K-D tree and the nearest neighbour is found using the Euclidean distance function. See https://news.ycombinator.com/item?id=9281998 on why this is a bad idea for nearest neighbour search.
Hi,
stream=io.StringIO() encod="" option seems like doesnt work very well. Instead of "รฉ", "รก" and so on get back:
Gรฉmesi Rรฉvhรกz = Gฤล mesi Rฤล vhฤฤz
Fehรฉr-Kรถrรถs = Fekete-Kฤลrฤลs
utf-8-sig encoding normally works for the hungarian dataset, but not now.
import reverse_geocoder as rg
import numpy as np
rg.search(np.nan)
Loading formatted geocoded file...
Traceback (most recent call last):
...
TypeError: Expecting a tuple or a tuple/list of tuples
I think it would be a good idea to gracefully return np.nan when encountering missing values. This has some good use cases for things like the pandas library, where you may want to apply the search to a series of data but cannot guarantee that all records exist.
Happy to submit a PR if you'd like to include
hi, I am the author of the original library, which uses the LGPL license. My reason for using LGPL was so people would be obligated to share their modifications, so I would expect this is not compatible with MIT.
I got the following error when running reverse-geocoder. Also, the machine got really hit for a while and I could not even move the mouse.
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 105, in spawn_main
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="mp_main")
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\runpy.py", line 263, in run_path
exitcode = _main(fd)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="mp_main")
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\runpy.py", line 96, in _run_module_code
pkg_name=pkg_name, script_name=fname)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\runpy.py", line 85, in run_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Me\Documents\Google Location Services Analyzer\main.py", line 19, in
exec(code, run_globals)
File "C:\Users\Me\Documents\Google Location Services Analyzer\main.py", line 19, in
result = rg.search(coordinates)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\site-packages\reverse_geocoder_init.py", line 293, in search
result = rg.search(coordinates)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\site-packages\reverse_geocoder_init.py", line 293, in search
return rg.query(geo_coords)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\site-packages\reverse_geocoder_init.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
return rg.query(geo_coords)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\site-packages\reverse_geocoder_init.py", line 127, in query
_, indices = self.tree.pquery(coordinates, k=1)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\site-packages\reverse_geocoder\cKDTree_MP.py", line 97, in pquery
for p in pool: p.start()
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\process.py", line 112, in start
for p in pool: p.start()
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\process.py", line 112, in start
self._popen = self._Popen(self)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\context.py", line 223, in _Popen
self._popen = self._Popen(self)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\popen_spawn_win32.py", line 46, in init
return _default_context.get_context().Process._Popen(process_obj)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\popen_spawn_win32.py", line 46, in init
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
_check_not_importing_main()
File "C:\Users\Me\AppData\Local\Continuum\anaconda3\envs\Google Location Services Analyzer\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
is not going to be frozen to produce an executable.''')
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
prep_data = spawn.get_preparation_data(process_obj._name)
Hello, I have a problem with the function rel_path when i create a exe with cx_freeze. The path return by the function include the .exe : c:/...../.exe/reverse_geocoder/rg_cities1000.csv
The only solution I have found is to modify this function.
before:
def rel_path(filename):
return os.path.join(os.getcwd(),filename,os.path.dirname(file), filename)
after:
def rel_path(filename):
return os.path.join(os.getcwd(),filename)
This solution works fine when I run .exe and .py
For example the real distance between (0N, 0E) (0N, 1E) is 112Km, and the real distance between (80N, 0E) (80N, 1E) is 19Km (https://www.movable-type.co.uk/scripts/latlong.html). But they are the same in Minkowski distance. BTW, the latitude range is -90 to 90, but the longitude range is -180 to 180, different scale.
Hello, this might be in the hands of the CSV file, but it may also be a bug.
I looked in the CSV file and found San Ramon,California and San Francisco,California.
I also have my coordinates that come up as San Ramon, even though they are in San Francisco.
37.78674,-122.39222,ME
37.77493,-122.41942,San Francisco,California,San Francisco County,US
37.77993,-121.97802,San Ramon,California,Contra Costa County,US
The "ME" point is closer to San Francisco, it shows up as San Ramon. See this image:
ME is blue. San Francisco is green. San Ramon is red.
I understand that coordinates are not in a 2d space, but is there something about the math that is making ME show up as San Ramon?
>>> reverse_geocoder.search([(37.78674,-122.39222)])
[{'name': 'San Ramon', 'cc': 'US', 'lon': '-121.97802', 'admin1': 'California', 'admin2': 'Contra Costa County', 'lat': '37.77993'}]
Thank you.
Hi! This library is AWESOME thanks a lot!!
I don't even need the precision of getting cities, I am already okay with getting countries!
Does this library work with EVERY country?
thanks a lot!!! (because then I won't have to build stuff myself, thanks a lot!!!! https://www.reddit.com/r/webdev/comments/tlfq17/comment/i1vamqc/?utm_source=share&utm_medium=web2x&context=3 )
BTW: just out of interest: how good is the city coverage actually? Will cities in asia or africa with over 1000 population get shown too?
Is it possible to return place names with diacritics, when appropriate? For example, I have data where a place name is Concepcion, Chile with a diacritic on the second o (ó in HTML, https://en.wikipedia.org/wiki/Concepci%C3%B3n,_Chile). When providing lat/long from there, reverse_geocoder returns Conception without diacritics. It does this for several cities in Chile and so presumably in other countries. Is it possible to return diacritics?
After performing a "pip install"
Open the python REPL and copy paste in the example in the README.md
import reverse_geocoder as rg
coords = (32.774185,-96.800618)
results = rg.search(coords)
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/reverse_geocoder/init.py", line 194, in search
return rg.query(geodetic_in_ecef(geo_coords))
File "/Library/Python/2.7/site-packages/reverse_geocoder/init.py", line 174, in geodetic_in_ecef
lat = geo_coords[:,0]
IndexError: too many indices
I just tried to run test.py
, and I get the following error:
> python test.py
Loading coordinates...
Traceback (most recent call last):
File "test.py", line 9, in <module>
t = timeit(stmt="rg.search(cities,mode=1)",setup=setup,number=num)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/timeit.py", line 213, in timeit
return Timer(stmt, setup, timer, globals).timeit(number)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/timeit.py", line 178, in timeit
timing = self.inner(it, self.timer)
File "<timeit-src>", line 3, in inner
FileNotFoundError: [Errno 2] No such file or directory: '../test/coordinates_10000000.csv'
test.py
is looking for a file that explicitly lives outside of this project's directory structure. A simple fix would be to include coordinates_10000000.csv
in this project and change the filepath in test.py
to reflect this.
Hi,
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.24.0'
In [3]: np.float(3)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 np.float(3)
File ~/.pyenv/versions/3.10.6/lib/python3.10/site-packages/numpy/__init__.py:284, in __getattr__(attr)
281 from .testing import Tester
282 return Tester
--> 284 raise AttributeError("module {!r} has no attribute "
285 "{!r}".format(__name__, attr))
AttributeError: module 'numpy' has no attribute 'float'
When we install the reverse-geocoder, we install the latest version of numpy. And unfortunately, we get an error. A simple solution to this is to change the requirements file pip install "numpy>=1.11.0, <1.24"
In [2]: import numpy as np
In [3]: np.__version__
Out[3]: '1.23.5'
In [4]: np.float(3)
<ipython-input-4-8262e04d58e1>:1: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
np.float(3)
Out[4]: 3.0
I'm trying to run the reverse-geocoder into a multiprocessing pool and I get this error.
AssertionError: daemonic processes are not allowed to have children
So I guess your implementation doesn't allow to run the search from subprocesses ?
Hi, I'm trying to deploy this package to the conda-forge repository channel, but they do require a license file to be packed with the source code. I see that the license file exist in the github repo but not within the distribution tarball itself. Would you consider adding the existing license file into the distribution tarball? Thanks@
Definitely a useful project.
Could you add a performance plot for the two modes with the time axis being on log scale?
Hi, thanks for developing this library, I consider using it for pyaerocom, a climate model evaluation software for automatically assigning countries to observation site location coordinates.
Reading through your README I have one question: the last updates here are more than 4 years ago, thus, I wonder if there is plans to maintain (and possibly further develop) this project into the future? Asking also because, the library reverse_geocode on which you base your work, as I understand from the README, has been updated in 2018.
I wonder if you are coordinating your efforts together with R. Penman or whether these can be considered 2 independent libraries?
In the latter case, I wonder which one to use. Also a release via conda-forge would be appreciated. As I can see here, the version from R. Penman is available via conda.
I would appreciate any comments. Would be good maybe also to clarify in the README? Thanks!
If eventlet is used (like if you do something with flask_socketio), the library display lot of Exception during the loading of geocoded file:
>>> import eventlet
>>> eventlet.monkey_patch()
>>> import reverse_geocoder as rg
>>> coordinates = (51.5214588,-0.1729636),(9.936033, 76.259952),(37.38605,-122.08385)
>>> results = rg.search(coordinates) # default mode = 2
Loading formatted geocoded file...
Exception ignored in: <function _after_fork at 0x7f57a9dfba60>
Traceback (most recent call last):
File "/home/tito/.conda/envs/cozyconnect/lib/python3.7/threading.py", line 1343, in _after_fork
assert len(_active) == 1
AssertionError:
Exception ignored in: <function _after_fork at 0x7f57a9dfba60>
Traceback (most recent call last):
File "/home/tito/.conda/envs/cozyconnect/lib/python3.7/threading.py", line 1343, in _after_fork
assert len(_active) == 1
AssertionError:
Exception ignored in: <function _after_fork at 0x7f57a9dfba60>
...
>>> results
[OrderedDict([('lat', '51.51116'), ('lon', '-0.18426'), ('name', 'Bayswater'), ('admin1', 'England'), ('admin2', 'Greater London'), ('cc', 'GB')]), OrderedDict([('lat', '9.93988'), ('lon', '76.26022'), ('name', 'Cochin'), ('admin1', 'Kerala'), ('admin2', 'Ernakulam'), ('cc', 'IN')]), OrderedDict([('lat', '37.38605'), ('lon', '-122.08385'), ('name', 'Mountain View'), ('admin1', 'California'), ('admin2', 'Santa Clara County'), ('cc', 'US')])]
Hi,
I've made this fork that publishes Wheels for Linux and Mac.
Will accept a PR that adds support for Windows.
Please add a requirements.txt file containing the depencies used otherwise we have to manually add them in our requirements file and it becomes tedious.
scipy==0.17.1
numpy==1.11.0
Now I haz go to wait for 30 minutes for docker-compose to build my images again ๐
Thanks for the lib anways its really great and better than most revese geocoders I've seen
I sometimes get segfault using the included c++ lib:
0x0000fffff7b7fa08 in PyUnicode_AsUTF8AndSize () from /lib/aarch64-linux-gnu/libpython3.8.so.1.0
(gdb) bt
#0 0x0000fffff7b7fa08 in PyUnicode_AsUTF8AndSize () from /lib/aarch64-linux-gnu/libpython3.8.so.1.0
#1 0x0000aaaaaab0ed8c in ReverseGeocode::search[abi:cxx11](double, double) (this=0xfffffffff1b8, _lat=55.715805000000003, _lon=12.436966) at ReverseGeocode.cpp:73
#2 0x0000aaaaaaaaf540 in main () at tesla_cron.cpp:605
(gdb)
(gdb) up
#1 0x0000aaaaaab0ed8c in ReverseGeocode::search[abi:cxx11](double, double) (this=0xfffffffff1b8, _lat=55.715805000000003, _lon=12.436966) at ReverseGeocode.cpp:73
73 const char* s1 = PyUnicode_AsUTF8(value);
(gdb) p value
$1 = (PyObject *) 0xffffde03d600
(gdb) p *value
$2 = {ob_refcnt = 281474406537808, ob_type = 0x0}
(gdb)
I'm trying to get started and I can't even get past the first usage example. Any ideas?
C:\Python3\python.exe C:\Users\jeremy\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\191.7141.48\helpers\pydev\pydevconsole.py --mode=client --port=4382
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['C:\\Users\\jeremy\\PycharmProjects\\publisher', 'C:/Users/jeremy/PycharmProjects/publisher'])
PyDev console: starting.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
import reverse_geocoder as rg
coordinates = [(41.85, -87.65)]
rg.search(coordinates)
Loading formatted geocoded file...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
Traceback (most recent call last):
File "<string>", line 1, in <module>
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
Traceback (most recent call last):
File "<string>", line 1, in <module>
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python3\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python3\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python3\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="__mp_main__")
File "C:\Python3\lib\runpy.py", line 261, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Python3\lib\runpy.py", line 231, in _get_code_from_file
with open(fname, "rb") as f:
OSError: [Errno 22] Invalid argument: 'C:\\Users\\jeremy\\PycharmProjects\\publisher\\<input>'
[OrderedDict([('lat', '42.57952'), ('lon', '1.65362'), ('name', 'El Tarter'), ('admin1', 'Canillo'), ('admin2', ''), ('cc', 'AD')])]
from scipy.spatial import cKDTree as KDTree
ImportError: No module named scipy.spatial
But even after installing scypi with pip, I still get the error.
pip install scipy
--Edit--
The pip install is failing on my vagrant. Investigating.
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
In either case, it would be useful for the need for scipy to be documented in the README or included in the setup.py.
Line 263 in __init__.py
z = normal * (1 - E2) * np.sin(lat)
Shouldn't lat
be lat_r
instead?
Hi. I am using reverse_geocoder inside an Apache Spark job on a couple of million entries.
Due to the nature of map reduce jobs, it will be a lot easier to call rg.search() on a single coordinate a million times, rather than calling it once with a list of million coordinates.
However, due to the nature of how the Geocoder is initialised, the overhead from re-initialising makes it much slower (infeasibly so).
While there are tricks to get around that, it is creating a lot of headaches, so my question is, it it possible to initialise and instance of the geocoder once and have it run N times on one entry with roughly the same performance it would if ran one time on N entries.
If not, are there any plans for including that? Thanks!
It does not work for Python 3, maybe only because of superficial syntax changes (e.g. brackets for print
).
E.g.
import reverse_geocoder as rg
raises
File "/usr/local/lib/python3.4/site-packages/reverse_geocoder/__init__.py", line 88
print 'Unable to parse coordinates:', coordinates
^
SyntaxError: invalid syntax
Consider the following coordinate:
46.601255, 10.422899
https://goo.gl/maps/jEzFrvcGmMQ2
The "reverse-geocoder" library report this coordinates is located in Italy (IT) when the actual location is Switzerland (CH).
Hi, Thampiman,
I'm trying to use the library to get the district of hundreds coordinates pairs. My file has only latitudes and longitude. What shoul I have to do?
Thank you for your attention.
On version 1.5:
geo = rg.RGeocoder(mode=2,verbose=True,stream=io.StringIO(open('rg_cities_mod.csv', encoding='utf-8').read()))
TypeError: getinstance() got an unexpected keyword argument 'verbose'
When installing in a virtual environment with Python 2, the setup fails with
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-lwlGz6/reverse-geocoder/setup.py", line 32, in <module>
long_description=read('README.txt'))
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/dist.py", line 717, in fetch_build_eggs
replace_conflicting=True,
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 774, in resolve
replace_conflicting=replace_conflicting
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1057, in best_match
return self.obtain(req, installer)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1069, in obtain
return installer(requirement)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/dist.py", line 784, in fetch_build_egg
return cmd.easy_install(req)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 679, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 705, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 890, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1144, in run_setup
run_setup(setup_script, args)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/home/laski/.virtualenvs/prueba/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-wdY3Ym/numpy-1.17.0rc1/setup.py", line 31, in <module>
license='lgpl',
RuntimeError: Python version >= 3.5 required.
It seems to be trying to install numpy-1.17.0rc1, which needs Python 3.
This happens even if trying to pip install -r
from a file where a minor version of numpy
is pinned (perhaps related with having numpy
listed as a setup_requires
apart from install_requires
?)
Steps to reproduce:
mkvirtualenv test # python 2
pip install --no-cache-dir reverse-geocoder
This is a good library, but I think the country for Taiwan and Hong Kong should be China.
ok this is really strange for me, this is my requirements.txt
file
numpy
scipy
reverse_geocoder
pip install -r
throws this error
Collecting numpy (from -r a.txt (line 1))
Using cached numpy-1.11.1-cp27-cp27mu-manylinux1_x86_64.whl
Collecting scipy (from -r a.txt (line 2))
Using cached scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl
Collecting reverse_geocoder (from -r a.txt (line 3))
Using cached reverse_geocoder-1.4.tar.gz
Complete output from command python setup.py egg_info:
/tmp/easy_install-0Izs8j/scipy-0.18.0rc2/setup.py:322: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
warnings.warn("Unrecognized setuptools command, proceeding with "
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-CKf1DC/reverse-geocoder/setup.py", line 26, in <module>
long_description=read('README.txt')
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/dist.py", line 348, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/dist.py", line 394, in fetch_build_eggs
replace_conflicting=True,
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 826, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1092, in best_match
return self.obtain(req, installer)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1104, in obtain
return installer(requirement)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/dist.py", line 461, in fetch_build_egg
return cmd.easy_install(req)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 664, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 694, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 875, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1114, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1100, in run_setup
run_setup(setup_script, args)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 249, in run_setup
raise
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
yield
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 168, in save_modules
saved_exc.resume()
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 143, in resume
six.reraise(type, exc, self._tb)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 156, in save_modules
yield saved
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 197, in setup_context
yield
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 246, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 276, in run
return func()
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 245, in runner
_execfile(setup_script, ns)
File "~/.virtualenvs/tmp-bc4c49e1bc2ee018/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 47, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-0Izs8j/scipy-0.18.0rc2/setup.py", line 415, in <module>
File "/tmp/easy_install-0Izs8j/scipy-0.18.0rc2/setup.py", line 395, in setup_package
ImportError: No module named numpy.distutils.core
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-CKf1DC/reverse-geocoder/
but when I install reverse-geocoder manually it works just fine :-|
$ pip install numpy
Collecting numpy
Using cached numpy-1.11.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.11.1
$ pip install scipy
Collecting scipy
Using cached scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: scipy
Successfully installed scipy-0.17.1
$ pip install reverse_geocoder
Collecting reverse_geocoder
Using cached reverse_geocoder-1.4.tar.gz
Requirement already satisfied (use --upgrade to upgrade): numpy in ./lib/python2.7/site-packages (from reverse_geocoder)
Requirement already satisfied (use --upgrade to upgrade): scipy in ./lib/python2.7/site-packages (from reverse_geocoder)
Building wheels for collected packages: reverse-geocoder
Running setup.py bdist_wheel for reverse-geocoder ... done
Stored in directory: ~/.cache/pip/wheels/c8/57/b0/2fdff550c3ffa9f023792bd891b206e47c6d3b094a7562a122
Successfully built reverse-geocoder
Installing collected packages: reverse-geocoder
Successfully installed reverse-geocoder-1.4
extra info:
Python 2.7.11+
pip 8.1.2
ubuntu 16.04
Python 2.7.6
pip 8.1.2
ubuntu 14.04
Hi, thanks for this library. Is the script to create the data file from a GeoNames dump available? The one committed seems to be missing some United States cities e.g. this lookup for a point in NYC:
>>> reverse_geocoder.search([(40.729177554196376,-73.99343490600586)])
[{'name': 'Byram', 'cc': 'US', 'lon': '-73.65374', 'admin1': 'Connecticut', 'admin2': 'Fairfield County', 'lat': '41.00426'}]
I'm trying to convert a set of coordinates but I get the following error:
Can't cast from structure to non-structure, except if the structure only has a single field.
Here's an example of my code:
test = ((29.976858, -90.410561), (29.971119, -90.407745), (29.950888, -90.076546), (47.252495, -122.439644), (47.272591, -122.47448), (47.646713, -122.347435), (47.657841, -122.350327), (47.615028, -122.319855), (47.650452, -122.35051), (47.651093, -122.347435))
results = rg.search(test)
When using rg.get
like so:
import reverse_geocoder as rg
rg.get((40, -80.5))
the following error is raised:
TypeError: Expecting a tuple
You can see here that this error is raised because the first element of geo_coord
is not a float. This is very confusing behavior (especially considering rg.get((40.5, -80))
works perfectly fine) and the error message is not helpful.
I think this function should be able to handle all real numerical types (or at least float
and int
), and the error message should be improved.
I'll submit a PR for this soon unless anyone has any reasoning against this.
Hello,
It seems that this package is not available on conda-forge. Packages are only available through it in my company, and I really need this package for my current project.
Thanks for answering.
reverse_gecoder is returning wrong results. For latitude and longitude of Los Angeles below code is returning a place in France.
import reverse_geocoder as rg
coordinates = (34.024375,-119),(34.024375,-119)
results = rg.search(coordinates) # default mode = 2
results
results:
[OrderedDict([('lat', '49.50881'),
('lon', '-1.4704700000000002'),
('name', 'Valognes'),
('admin1', 'Lower Normandy'),
('admin2', 'Departement de la Manche'),
('cc', 'FR')]),
OrderedDict([('lat', '49.50881'),
('lon', '-1.4704700000000002'),
('name', 'Valognes'),
('admin1', 'Lower Normandy'),
('admin2', 'Departement de la Manche'),
('cc', 'FR')])]
I am using:
Hi,
I'm trying to use the reverse-geocode library to do zip code level look up for certain areas, and this is what I did to make it work using a custom header (that includes more information than what the library provided)
import reverse_geocoder as rg
COLUMNS = [
'lat',
'lon',
'code',
'cc',
'place',
'admin_name1',
'admin_code1',
'admin_name2',
'admin_code2',
'admin_name3',
'admin_code3',
]
rg.RG_COLUMNS = COLUMNS
my_rg = rg.RGeocoder(
mode=1,
verbose=True,
stream=open(
'my_data.txt',
'rb',
),
)
As far as I can tell, this is the only way I can work around the header column check. Also it seems like as long as lot, lon are the first 2 columns, rest of the columns are not as relevant by comparison, therefore it would be nice to add that as a custom param in the init function to pass the header in.
Thank you.
I saw the video from your London Pydata talk. Great thing.
Would it be possible to include the timezone of the location?
Maybe by updating
https://github.com/thampiman/reverse-geocoder/blob/master/reverse_geocoder/rg_cities1000.csv
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.