polygon

How to create a shapely Polygon from a list of shapely Points?

How to create a shapely Polygon from a list of shapely Points? Question: I want to create a polygon from shapely points. from shapely import geometry p1 = geometry.Point(0,0) p2 = geometry.Point(1,0) p3 = geometry.Point(1,1) p4 = geometry.Point(0,1) pointList = [p1, p2, p3, p4, p1] poly = geometry.Polygon(pointList) gives me an type error TypeError: object …

Total answers: 5

Calculate overlapped area between two rectangles

Calculate overlapped area between two rectangles Question: I want to calculate the overlapped area “THE GRAY REGION” between red and blue rectangles. Each rectangle is defined by its four corner coordinates. The resulted unit of the overlapped area is unit square. I could not imagine how can I do it? Any creative comments would be …

Total answers: 3

Calculate area of polygon given (x,y) coordinates

Calculate area of polygon given (x,y) coordinates Question: I have a set of points and would like to know if there is a function (for the sake of convenience and probably speed) that can calculate the area enclosed by a set of points. for example: x = np.arange(0,1,0.001) y = np.sqrt(1-x**2) points = zip(x,y) given …

Total answers: 12

Calculate Polygon area in planar units (e.g. square-meters) in Shapely

Calculate Polygon area in planar units (e.g. square-meters) in Shapely Question: I am using Python 3.4 and shapely 1.3.2 to create a Polygon object out of a list of long/lat coordinate pairs which I transform into a well-known-text string in order to parse them. Such a Polygon might look like: POLYGON ((-116.904 43.371, -116.823 43.389, …

Total answers: 3

Extract points/coordinates from a polygon in Shapely

Extract points/coordinates from a polygon in Shapely Question: How do you get/extract the points that define a shapely polygon? Thanks! Example of a shapely polygon from shapely.geometry import Polygon # Create polygon from lists of points x = [list of x vals] y = [list of y vals] polygon = Polygon(x,y) Asked By: ryanjdillon || …

Total answers: 9

Pygame draw antialiased filled polygon

Pygame draw antialiased filled polygon Question: The documentation says “For aapolygon, use aalines with the ‘closed’ parameter.”, but pygame.draw.aalines doesn’t let me specify the width (0 = filled), making it not fill the surface. This looks just terrible: These circles look much better: How can I do this? I generate the surface using quadratic beziers, …

Total answers: 3

SciPy Create 2D Polygon Mask

SciPy Create 2D Polygon Mask Question: I need to create a numpy 2D array which represents a binary mask of a polygon, using standard Python packages. input: polygon vertices, image dimensions output: binary mask of polygon (numpy 2D array) (Larger context: I want to get the distance transform of this polygon using scipy.ndimage.morphology.distance_transform_edt.) Can anyone …

Total answers: 6