Questions tagged [shapely]

PostGIS-ish operations outside a database context for Pythoneers and Pythonistas.

Shapely is a BSD-licensed Python package (see Shapely · PyPI) for manipulation and analysis of planar geometric objects. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported) libraries. This C dependency is traded for the ability to execute with blazing speed. Shapely is not concerned with data formats or coordinate systems, but can be readily integrated with packages that are. For more details, see the Shapely manual.

1113 questions
27
votes
6 answers

OSError geos_c could not be found when Installing Shapely

I'm a newbie to making/plotting on maps with python, been trying to follow this blogpost to generate a world map ( http://sciblogs.co.nz/seeing-data/2011/08/12/plotting-geographic-data-on-a-world-map-with-python/ ). Got stuck with a few things…
msunbot
  • 1,871
  • 4
  • 16
  • 16
26
votes
3 answers

How to extract Polygons from Multipolygons in Shapely?

I'm trying to extract the polygons from multipolygons in Shapely. I can transform a list of polygons into multipolygons using MultiPolygon from Shapely. >>> Multi = MultiPolygon([shape(pol['geometry']) for pol in fiona.open('data.shp')]) And, >>>…
Rahul
  • 3,208
  • 8
  • 38
  • 68
25
votes
5 answers

Install Shapely: OSError: [WinError 126] The specified module could not be found

I have to install Shapely package (http://toblerity.org/shapely/project.html#installation). But when I am using: pip install Shapely I am getting this error: Collecting Shapely Using cached Shapely-1.5.17.tar.gz Complete output from command…
Beginner
  • 1,202
  • 2
  • 20
  • 29
23
votes
3 answers

Cut a polygon with two lines in Shapely

I am trying to cut a shapely.geometry.Polygon instance in two parts with two lines. For example, in the code below, polygon is a ring and if we cut it with line1 and line2 we should get two partial rings, one w/ 270 degrees and one with 90 degrees.…
Yuxiang Wang
  • 8,095
  • 13
  • 64
  • 95
23
votes
6 answers

Python, GEOS and Shapely on Windows 64

When trying to install Shapely on my Windows 64bit computer, I cannot get the GEOS library to work. So far, I have run the OSGeo4W installer from which I installed GDAL (I believe the geos library is included in that package). After that, I checked…
Juan Carlos Coto
  • 11,900
  • 22
  • 62
  • 102
22
votes
1 answer

How to check if a polygon is empty in Shapely?

I'm pretty new to Python so the answer to this question is probably quite simple, but I've looked everywhere and tried a lot but couldn't find the answer. Simplifying a polygon using Shapely may result in an empty polygon. I want to replace the…
user2957487
  • 323
  • 1
  • 2
  • 4
20
votes
4 answers

From Voronoi tessellation to Shapely polygons

from a set of points I built the Voronoi tessellation using scipy: from scipy.spatial import Voronoi vor = Voronoi(points) Now I would like to build a Polygon in Shapely from the regions the Voronoi algorithm created. The problem is that the…
marcodena
  • 550
  • 2
  • 5
  • 15
17
votes
2 answers

Projection of a point to a line segment Python Shapely

I have a LineString defined by two points, so essentially a straight line segment, and I wanted to project a point on to it. I am aware of .project and .interpolate. However when the point is "outside" the segment, I don't want the closest point on…
sofaruntitled
  • 275
  • 1
  • 2
  • 6
17
votes
1 answer

How to make holes in a Polygon in shapely python, having Polygons

In python, I have a plain Polygon "outer" and a list of Polygons "inners". I want to make holes in my polygon using this list. from shapely.geometry import Polygon # polygon with 1 hole in the middle p = Polygon(((0,0),(10,0),(10,10),(0,10)),…
Eric H.
  • 2,152
  • 4
  • 22
  • 34
17
votes
4 answers

How do I get Python libraries in pyspark?

I want to use matplotlib.bblpath or shapely.geometry libraries in pyspark. When I try to import any of them I get the below error: >>> from shapely.geometry import polygon Traceback (most recent call last): File "", line 1, in…
thenakulchawla
  • 5,024
  • 7
  • 30
  • 42
17
votes
3 answers

Calculate Distance to Nearest Feature with Geopandas

I'm looking to do the equivalent of the ArcPy Generate Near Table using Geopandas / Shapely. I'm very new to Geopandas and Shapely and have developed a methodology that works, but I'm wondering if there is a more efficient way of doing it. I have…
AJG519
  • 3,249
  • 10
  • 36
  • 62
17
votes
2 answers

Draw an ellipse using Shapely

I'm integrating Shapely into my code, and I have to deal with several different kinds of geometric objects. Most of my needs are satisfied with Lines, Polygons and LineStrings, but I need to use ellipses. Is there a way to create an ellipse in…
Ivan
  • 19,560
  • 31
  • 97
  • 141
16
votes
2 answers

How to convert NumPy arrays obtained from cv2.findContours to Shapely polygons?

I am using CV2 to find contours from an image and then converting them into polygons using Shapely. I am currently stuck because when I try putting one of the contour arrays into Polygon() from Shapely it throws an unspecified error. I have…
Ops_Manager
  • 163
  • 1
  • 1
  • 4
16
votes
5 answers

OSError: Could not find geos_c.dll or load any of its variants

I'm trying to use shapley, and to use it for what I need it for, I have to import "from shapely import geometry" but I get the error OSError: Could not find lib geos_c.dll I've tried to install "geos" via "pip install geos", didn't do anything:…
user9740907
16
votes
3 answers

How to calculate the center of gravity with shapely in python?

I discovered shapely but I did not find how to calculated the center of gravity of a polygon! Does someone have the solution?
Vianney Bailleux
  • 373
  • 2
  • 7
  • 15
1
2
3
74 75