Closed LoicGoulefert closed 3 years ago
Sometimes, linesimplify introduces ill formed LinearRings. Find a way to either:
linesimplify
GEOSException Traceback (most recent call last) <ipython-input-80-8f14df048e4b> in <module> 49 vsk.geometry(rh.intersection(bundle_lines)) 50 ---> 51 vsk.vpype("linesimplify occult crop 1cm 1cm 26.2cm 19cm reloop linemerge multipass linesort") 52 vsk.display(mode="matplotlib") ~/Documents/python/vsketch/vsketch/vsketch.py in vpype(self, pipeline) 1229 1230 args = "vsketchinput " + pipeline + " vsketchoutput" -> 1231 vpype_cli.cli.main(prog_name="vpype", args=shlex.split(args), standalone_mode=False) 1232 1233 def display( ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/vpype_cli/cli.py in main(self, args, **extra) 72 if args is None: 73 args = get_os_args() ---> 74 return super().main(args=preprocess_argument_list(args), **extra) 75 76 ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/click/core.py in main(self, args, prog_name, complete_var, standalone_mode, **extra) 780 try: 781 with self.make_context(prog_name, args, **extra) as ctx: --> 782 rv = self.invoke(ctx) 783 if not standalone_mode: 784 return rv ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/click/core.py in invoke(self, ctx) 1288 with sub_ctx: 1289 rv.append(sub_ctx.command.invoke(sub_ctx)) -> 1290 return _process_result(rv) 1291 1292 def resolve_command(self, ctx, args): ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/click/core.py in _process_result(value) 1222 def _process_result(value): 1223 if self.result_callback is not None: -> 1224 value = ctx.invoke(self.result_callback, value, **ctx.params) 1225 return value 1226 ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/click/core.py in invoke(*args, **kwargs) 608 with augment_usage_errors(self): 609 with ctx: --> 610 return callback(*args, **kwargs) 611 612 def forward(*args, **kwargs): # noqa: B902 ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/vpype_cli/cli.py in process_pipeline(processors, verbose, include, history, seed, config) 126 @cli.resultcallback() 127 def process_pipeline(processors, verbose, include, history, seed, config): --> 128 execute_processors(processors) 129 130 ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/vpype_cli/cli.py in execute_processors(processors) 210 state = vp.VpypeState() 211 for proc in outer_processors: --> 212 state = proc(state) 213 return state 214 ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/vpype/decorators.py in layer_processor(state) 83 start = datetime.datetime.now() 84 with state.current(): ---> 85 state.document[lid] = f(state.document[lid], *args, **kwargs) 86 stop = datetime.datetime.now() 87 ~/Documents/python/occult/occult/occult.py in occult(lines, tolerance) 44 if math.hypot(coords[-1, 0] - coords[0, 0], coords[-1, 1] - coords[0, 1]) < tolerance: 45 tree = pygeos.STRtree(line_arr[:i]) ---> 46 p = pygeos.polygons(coords) 47 geom_idx = tree.query(p, predicate="intersects") 48 line_arr[geom_idx] = pygeos.set_operations.difference(line_arr[geom_idx], p) ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/pygeos/creation.py in polygons(shells, holes) 85 shells = np.asarray(shells) 86 if not isinstance(shells, Geometry) and np.issubdtype(shells.dtype, np.number): ---> 87 shells = linearrings(shells) 88 89 if holes is None: ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/pygeos/creation.py in linearrings(coords, y, z) 69 z : array_like 70 """ ---> 71 return _wrap_construct_ufunc(lib.linearrings, coords, y, z) 72 73 ~/Documents/python/vsketch/venv/lib/python3.6/site-packages/pygeos/creation.py in _wrap_construct_ufunc(func, coords, y, z) 18 def _wrap_construct_ufunc(func, coords, y=None, z=None): 19 if y is None: ---> 20 return func(coords) 21 x = coords 22 if z is None: GEOSException: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4
Sometimes,
linesimplify
introduces ill formed LinearRings. Find a way to either: