shapely / shapely

Manipulation and analysis of geometric objects
https://shapely.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
3.84k stars 564 forks source link

Can't import voronoi_diagram #954

Closed aydal closed 4 years ago

aydal commented 4 years ago

I am using shapely 1.7.0 installed using pip3 for python 3.6.9

>>> from shapely.ops import unary_union,voronoi_diagram
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'voronoi_diagram'

On using inspect on shapely.ops, I get the following

>>> inspect.getmembers(shapely.ops)
[('BaseGeometry', <class 'shapely.geometry.base.BaseGeometry'>), ('BaseMultipartGeometry', <class 'shapely.geometry.base.BaseMultipartGeometry'>), ('CollectionOperator', <class 'shapely.ops.CollectionOperator'>), ('GeometryCollection', <class 'shapely.geometry.collection.GeometryCollection'>), ('LineString', <class 'shapely.geometry.linestring.LineString'>), ('MultiLineString', <class 'shapely.geometry.multilinestring.MultiLineString'>), ('MultiPoint', <class 'shapely.geometry.multipoint.MultiPoint'>), ('Point', <class 'shapely.geometry.point.Point'>), ('Polygon', <class 'shapely.geometry.polygon.Polygon'>), ('SplitOp', <class 'shapely.ops.SplitOp'>), ('ValidateOp', <class 'shapely.ops.ValidateOp'>), ('__all__', ['cascaded_union', 'linemerge', 'operator', 'polygonize', 'polygonize_full', 'transform', 'unary_union', 'triangulate', 'split', 'section']), ('__builtins__', {'__name__': 'builtins', '__doc__': "Built-in functions, exceptions, and other objects.\n\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.", '__package__': '', '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>), '__build_class__': <built-in function __build_class__>, '__import__': <built-in function __import__>, 'abs': <built-in function abs>, 'all': <built-in function all>, 'any': <built-in function any>, 'ascii': <built-in function ascii>, 'bin': <built-in function bin>, 'callable': <built-in function callable>, 'chr': <built-in function chr>, 'compile': <built-in function compile>, 'delattr': <built-in function delattr>, 'dir': <built-in function dir>, 'divmod': <built-in function divmod>, 'eval': <built-in function eval>, 'exec': <built-in function exec>, 'format': <built-in function format>, 'getattr': <built-in function getattr>, 'globals': <built-in function globals>, 'hasattr': <built-in function hasattr>, 'hash': <built-in function hash>, 'hex': <built-in function hex>, 'id': <built-in function id>, 'input': <built-in function input>, 'isinstance': <built-in function isinstance>, 'issubclass': <built-in function issubclass>, 'iter': <built-in function iter>, 'len': <built-in function len>, 'locals': <built-in function locals>, 'max': <built-in function max>, 'min': <built-in function min>, 'next': <built-in function next>, 'oct': <built-in function oct>, 'ord': <built-in function ord>, 'pow': <built-in function pow>, 'print': <built-in function print>, 'repr': <built-in function repr>, 'round': <built-in function round>, 'setattr': <built-in function setattr>, 'sorted': <built-in function sorted>, 'sum': <built-in function sum>, 'vars': <built-in function vars>, 'None': None, 'Ellipsis': Ellipsis, 'NotImplemented': NotImplemented, 'False': False, 'True': True, 'bool': <class 'bool'>, 'memoryview': <class 'memoryview'>, 'bytearray': <class 'bytearray'>, 'bytes': <class 'bytes'>, 'classmethod': <class 'classmethod'>, 'complex': <class 'complex'>, 'dict': <class 'dict'>, 'enumerate': <class 'enumerate'>, 'filter': <class 'filter'>, 'float': <class 'float'>, 'frozenset': <class 'frozenset'>, 'property': <class 'property'>, 'int': <class 'int'>, 'list': <class 'list'>, 'map': <class 'map'>, 'object': <class 'object'>, 'range': <class 'range'>, 'reversed': <class 'reversed'>, 'set': <class 'set'>, 'slice': <class 'slice'>, 'staticmethod': <class 'staticmethod'>, 'str': <class 'str'>, 'super': <class 'super'>, 'tuple': <class 'tuple'>, 'type': <class 'type'>, 'zip': <class 'zip'>, '__debug__': True, 'BaseException': <class 'BaseException'>, 'Exception': <class 'Exception'>, 'TypeError': <class 'TypeError'>, 'StopAsyncIteration': <class 'StopAsyncIteration'>, 'StopIteration': <class 'StopIteration'>, 'GeneratorExit': <class 'GeneratorExit'>, 'SystemExit': <class 'SystemExit'>, 'KeyboardInterrupt': <class 'KeyboardInterrupt'>, 'ImportError': <class 'ImportError'>, 'ModuleNotFoundError': <class 'ModuleNotFoundError'>, 'OSError': <class 'OSError'>, 'EnvironmentError': <class 'OSError'>, 'IOError': <class 'OSError'>, 'EOFError': <class 'EOFError'>, 'RuntimeError': <class 'RuntimeError'>, 'RecursionError': <class 'RecursionError'>, 'NotImplementedError': <class 'NotImplementedError'>, 'NameError': <class 'NameError'>, 'UnboundLocalError': <class 'UnboundLocalError'>, 'AttributeError': <class 'AttributeError'>, 'SyntaxError': <class 'SyntaxError'>, 'IndentationError': <class 'IndentationError'>, 'TabError': <class 'TabError'>, 'LookupError': <class 'LookupError'>, 'IndexError': <class 'IndexError'>, 'KeyError': <class 'KeyError'>, 'ValueError': <class 'ValueError'>, 'UnicodeError': <class 'UnicodeError'>, 'UnicodeEncodeError': <class 'UnicodeEncodeError'>, 'UnicodeDecodeError': <class 'UnicodeDecodeError'>, 'UnicodeTranslateError': <class 'UnicodeTranslateError'>, 'AssertionError': <class 'AssertionError'>, 'ArithmeticError': <class 'ArithmeticError'>, 'FloatingPointError': <class 'FloatingPointError'>, 'OverflowError': <class 'OverflowError'>, 'ZeroDivisionError': <class 'ZeroDivisionError'>, 'SystemError': <class 'SystemError'>, 'ReferenceError': <class 'ReferenceError'>, 'BufferError': <class 'BufferError'>, 'MemoryError': <class 'MemoryError'>, 'Warning': <class 'Warning'>, 'UserWarning': <class 'UserWarning'>, 'DeprecationWarning': <class 'DeprecationWarning'>, 'PendingDeprecationWarning': <class 'PendingDeprecationWarning'>, 'SyntaxWarning': <class 'SyntaxWarning'>, 'RuntimeWarning': <class 'RuntimeWarning'>, 'FutureWarning': <class 'FutureWarning'>, 'ImportWarning': <class 'ImportWarning'>, 'UnicodeWarning': <class 'UnicodeWarning'>, 'BytesWarning': <class 'BytesWarning'>, 'ResourceWarning': <class 'ResourceWarning'>, 'ConnectionError': <class 'ConnectionError'>, 'BlockingIOError': <class 'BlockingIOError'>, 'BrokenPipeError': <class 'BrokenPipeError'>, 'ChildProcessError': <class 'ChildProcessError'>, 'ConnectionAbortedError': <class 'ConnectionAbortedError'>, 'ConnectionRefusedError': <class 'ConnectionRefusedError'>, 'ConnectionResetError': <class 'ConnectionResetError'>, 'FileExistsError': <class 'FileExistsError'>, 'FileNotFoundError': <class 'FileNotFoundError'>, 'IsADirectoryError': <class 'IsADirectoryError'>, 'NotADirectoryError': <class 'NotADirectoryError'>, 'InterruptedError': <class 'InterruptedError'>, 'PermissionError': <class 'PermissionError'>, 'ProcessLookupError': <class 'ProcessLookupError'>, 'TimeoutError': <class 'TimeoutError'>, 'open': <built-in function open>, 'quit': Use quit() or Ctrl-D (i.e. EOF) to exit, 'exit': Use exit() or Ctrl-D (i.e. EOF) to exit, 'copyright': Copyright (c) 2001-2019 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved., 'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
    for supporting Python development.  See www.python.org for more information., 'license': Type license() to see the full license text, 'help': Type help() for interactive help, or help(object) for help about object., '_': None}), ('__cached__', '/home/vizzbee/.local/lib/python3.6/site-packages/shapely/__pycache__/ops.cpython-36.pyc'), ('__doc__', 'Support for various GEOS geometry operations\n'), ('__file__', '/home/vizzbee/.local/lib/python3.6/site-packages/shapely/ops.py'), ('__loader__', <_frozen_importlib_external.SourceFileLoader object at 0x7fbac2e520f0>), ('__name__', 'shapely.ops'), ('__package__', 'shapely'), ('__spec__', ModuleSpec(name='shapely.ops', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7fbac2e520f0>, origin='/home/vizzbee/.local/lib/python3.6/site-packages/shapely/ops.py')), ('asLineString', <function asLineString at 0x7fbaabef3510>), ('asMultiLineString', <function asMultiLineString at 0x7fbaabef3d08>), ('asShape', <function asShape at 0x7fbaabe88a60>), ('byref', <built-in function byref>), ('c_double', <class 'ctypes.c_double'>), ('c_void_p', <class 'ctypes.c_void_p'>), ('cascaded_union', <bound method CollectionOperator.cascaded_union of <shapely.ops.CollectionOperator object at 0x7fbac2ddf358>>), ('clip_by_rect', <function clip_by_rect at 0x7fbaabe91d08>), ('geom_factory', <function geom_factory at 0x7fbaabfa7268>), ('izip', <class 'zip'>), ('lgeos', <shapely.geos.LGEOS350 object at 0x7fbac2ba10a8>), ('linemerge', <bound method CollectionOperator.linemerge of <shapely.ops.CollectionOperator object at 0x7fbac2ddf358>>), ('nearest_points', <function nearest_points at 0x7fbaabe91840>), ('operator', <shapely.ops.CollectionOperator object at 0x7fbac2ddf358>), ('orient', <function orient at 0x7fbaabe91d90>), ('orient_', <function orient at 0x7fbaabe821e0>), ('polygonize', <bound method CollectionOperator.polygonize of <shapely.ops.CollectionOperator object at 0x7fbac2ddf358>>), ('polygonize_full', <bound method CollectionOperator.polygonize_full of <shapely.ops.CollectionOperator object at 0x7fbac2ddf358>>), ('polylabel', <function polylabel at 0x7fbaabe88ea0>), ('shared_paths', <function shared_paths at 0x7fbaabe91950>), ('snap', <function snap at 0x7fbaabe918c8>), ('split', <function SplitOp.split at 0x7fbaabe91c80>), ('substring', <function substring at 0x7fbaabe919d8>), ('sys', <module 'sys' (built-in)>), ('transform', <function transform at 0x7fbaabe91730>), ('triangulate', <function triangulate at 0x7fbac2e550d0>), ('unary_union', <bound method CollectionOperator.unary_union of <shapely.ops.CollectionOperator object at 0x7fbac2ddf358>>), ('validate', <shapely.ops.ValidateOp object at 0x7fbac2ddf390>)]

There is no mention of voronoi. I have tried reinstalling but no use. Also tried

$ pip3 install geos
$ GEOS_CONFIG=/usr/local/bin/geos-config pip3 install shapely

Any help will be appreciated

jorisvandenbossche commented 4 years ago

voronoi_diagram was only added recently (https://github.com/Toblerity/Shapely/pull/881) and is not yet available in the released 1.7 release (it will be available in 1.8)

aydal commented 4 years ago

What is the timeline for 1.8 release?

tomplex commented 4 years ago

I don't have any information on release timeline, but you can install from master (the code which will be the 1.8 release) like so:

$ pip install git+https://github.com/Toblerity/Shapely.git
Collecting git+https://github.com/Toblerity/Shapely.git
  Cloning https://github.com/Toblerity/Shapely.git to /private/var/folders/2l/v2wjg8097bggqf8gkpkgjqtw0000gn/T/pip-req-build-bm15psqb
  Running command git clone -q https://github.com/Toblerity/Shapely.git /private/var/folders/2l/v2wjg8097bggqf8gkpkgjqtw0000gn/T/pip-req-build-bm15psqb
Installing collected packages: Shapely
  Running setup.py install for Shapely ... done
Successfully installed Shapely-1.8.dev0
WARNING: You are using pip version 19.2.3, however version 20.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ python
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from shapely.ops import voronoi_diagram
>>>
aydal commented 4 years ago

Thanks a lot