Python shapely.geometry.polygon.orient() Examples
The following are 5
code examples of shapely.geometry.polygon.orient().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
shapely.geometry.polygon
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: encoder.py From mapbox-vector-tile with MIT License | 6 votes |
def enforce_polygon_winding_order(self, shape, y_coord_down, n_try): assert shape.type == 'Polygon' def fn(point): x, y = point return self._round(x), self._round(y) exterior = apply_map(fn, shape.exterior.coords) rings = None if len(shape.interiors) > 0: rings = [apply_map(fn, ring.coords) for ring in shape.interiors] sign = 1.0 if y_coord_down else -1.0 oriented_shape = orient(Polygon(exterior, rings), sign=sign) oriented_shape = self.handle_shape_validity( oriented_shape, y_coord_down, n_try) return oriented_shape
Example #2
Source File: encoder.py From go2mapillary with GNU General Public License v3.0 | 6 votes |
def enforce_polygon_winding_order(self, shape, y_coord_down, n_try): assert shape.type == 'Polygon' def fn(point): x, y = point return self._round(x), self._round(y) exterior = apply_map(fn, shape.exterior.coords) rings = None if len(shape.interiors) > 0: rings = [apply_map(fn, ring.coords) for ring in shape.interiors] sign = 1.0 if y_coord_down else -1.0 oriented_shape = orient(Polygon(exterior, rings), sign=sign) oriented_shape = self.handle_shape_validity( oriented_shape, y_coord_down, n_try) return oriented_shape
Example #3
Source File: rawr.py From tilequeue with MIT License | 6 votes |
def _orient(shape): """ The Shapely version of the orient function appears to only work on Polygons, and fails on MultiPolygons. This is a quick wrapper to allow orienting of either. """ assert shape.geom_type in ('Polygon', 'MultiPolygon') if shape.geom_type == 'Polygon': return orient(shape) else: polys = [] for geom in shape.geoms: polys.append(orient(geom)) return MultiPolygon(polys)
Example #4
Source File: polygons.py From geomeppy with MIT License | 5 votes |
def buffer(self, distance=None, join_style=2): # type: (Optional[float], Optional[int]) -> Polygon2D """Returns a representation of all points within a given distance of the polygon. :param join_style: The styles of joins between offset segments: 1 (round), 2 (mitre), and 3 (bevel). """ s_poly = SPoly(self.vertices) core = orient(s_poly.buffer(distance=distance, join_style=join_style), sign=1.0) return Polygon2D(core.boundary.coords)
Example #5
Source File: fiona_dataset.py From Processing with MIT License | 5 votes |
def _force_polygon_ccw(geometry): polygon = shape(geometry) return mapping(orient(polygon))