Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects.
19
votes
2answers
1k views
Python Efficiency — Need suggestions about how to use OGR and Shapely in more efficient way
I'm looking for some suggestions about how to make my python code more efficient. Normally efficiency doesn't matter for me but I am now working with a text file of US locations with over 1.5 million ...
9
votes
4answers
4k views
using shapely: translating between Polygons and MultiPolygons
[EDIT: the solution to this was simply to use OGR to read shapefiles. See geographika's example.]
In an ESRI shapefile, there is no distinction between Polygons and MultiPolygons. Furthermore, there ...
8
votes
1answer
766 views
Polygon overlay with Shapely
I'm trying to capture all the non-overlapping polygons indicated below using Shapely (given polygons A,B & C). Moreover, I'm hoping to do so without iteration, testing for intersect etc. The ...
7
votes
1answer
221 views
How to split two interscting polygons by the average linestring of the shared area (QGIS / python shapely)
I have two polygons,
POLYGON((-5 -5,-5 5,5 5,5 -5,-5 -5))
POLYGON((1 1, 1 7, 7 7, 7 1, 1 1))
and wish to split them evenly.
The result should be a split along the red marked line.
I'm using ...
7
votes
1answer
139 views
Is there a significantly faster way to buffer than arcmap?
I hope this question is appropriate here and I apologize if it is more of a discussion question than a specific technical problem.
I have to buffer 150,000 polygons for a real estate project. While ...
6
votes
2answers
221 views
Converting KML files for use with Python library Shapely
I am trying to get a KML-file (wijken.kml) into Shapely. The KML-file is validated against the proper XML schema, so I guess the input is correct.
Routes I have tried:
1) Converting to WKT or WKB ...
5
votes
2answers
512 views
Python: How to export Shapely objects to DXF file
Using shapely package for Python how to export the resulting shapely objects such as buffer to a DXF file?
5
votes
5answers
768 views
Python, shapely library: is it possible to do an affine operation on shape polygon?
I am trying to create a rotated rectangle in lat/lon coordinates.
Basically I have the coordinates of the center and rotation angle around the center.
Is it possible to do using, shapely or gdal, or ...
5
votes
1answer
118 views
How do you fix Overlapping Lines?
I have a line dataset that contains some lines where the "end points" are actually found in the middle of the line. In the image below, the nodes are shown in green and one of the end points in red. ...
4
votes
2answers
268 views
How to write Shapely geometries to shapefiles?
Can someone demonstrate a simple way to write geometry data-structures from shapely into shapefiles? I am particularly interested in polygons with holes and linestrings. It would also be beneficial to ...
4
votes
1answer
428 views
Find distance and heading from a point to a polygon in lat, lon coordinates
I have counties mapped using polygons in Shapely with latitude/longitude for coordinates. Given a complex polygon x and single point y, how would I find the shortest distance between x and y as well ...
4
votes
1answer
395 views
Wrap GEOS functionality into python
I've been looking on how to get GEOSExtractLine available in python.
I looked into Shapely source to if it was available for it, but it's not. I'm trying to wrap this funcionality into Django, much ...
4
votes
1answer
338 views
How to deal with direction (CW, CCW) of circles, in particular with shapely?
I am translating an input that describes zones by mixing segments and arcs. Arcs are given by a center, 2 points (beginning/end of arc) and a direction (CW or CCW). In a first prototypes using GDAL, I ...
3
votes
1answer
191 views
Does anyone have a shapely install for python “dummies” guide?
I have read both questions in regard to installing shapely on a Mac (OS Mountain Lion) and haven't been able to figure it out. I'm not familiar with python syntax and am just trying to get shapely ...
3
votes
2answers
63 views
How to computational efficiently check if there are any overlapping polygons in a group of polygons?
I need to do some processing with groups of polygons. If any of the polygons in the group overlaps other polygon the result is unpredictable and don't throw any error. So, I need to detect if there is ...
3
votes
0answers
131 views
Importing matplotlib basemap and shapely
I'm not sure if this is the right place to ask this, but here we go.
I have a python script that uses matplotlib's basemap and another part that uses shapely to do an intersection of 2 polygons. If ...
2
votes
3answers
393 views
Why is this polygon “self intersected” and invalid?
I have a polygon defined as follows:
segment from 43:29:02 N 003:50:39 E to 43:34:12 N 003:43:04 E
arc(CW): center (43:34:49 N 003:58:16 E) from 43:34:12 N 003:43:04 E to 43:45:45 N 003:59:56 E
...
2
votes
2answers
176 views
Checking if a point is in a circle
I'm using shapely to check if a point is in a polygon, but I also need to check if a point is in a circle. Checking the docs, I don't see how do that...
Maybe I could create a circle?
circle = ...
2
votes
1answer
433 views
GEOS and Shapely installation on Windows
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 ...
2
votes
1answer
273 views
How to install shapely for python 2.6 (Mac) NOT 2.7?
I'm trying to use Polygonizer plugin inside QGIS, but it needs Shapely to work. I've installed Shapely (pip install Shapely) but that's for python 2.7. QGIS works with python 2.6 (on Snow Leopard) and ...
1
vote
1answer
246 views
QGIS Python version
I have brewed python 2.7.3 onto my Mac (Lion), and installed shapely via pip install shapely. The Polygonizer plugin, however, does not find the shapely library. I see when QGIS loads a Python ...
1
vote
1answer
63 views
How to set the path to shapely?
I am using QGIS 1.8.0 on Mac OS 10.8.3 with python 2.7. Thanks to other threads in the forum, I have successfully installed shapely here:
...
1
vote
1answer
193 views
How do I find out if a given lat lon is in a KML Linear ring using shapely?
I'm a GIS n00b. I have some LinearRings in a KML file that give the areas for a bunch of different regions. And then I (will) have some lat lons that I want to test to see if they're in any of the ...
1
vote
0answers
26 views
Why does polygon.intersection(complex_linestring) split the linestring and mess up Z?
I have a complex (self crossing) line with Z values which I'd like to truncate to the area inside a box. The problem is Shapely splits the line into simple (non-crossing) sections and the Z value at ...
0
votes
2answers
245 views
Python module “shapely.wkb” missing
I am trying to follow a tutorial from here http://qgistips.spatialthoughts.com/2012/12/find-neighbor-polygons-in-layer-in-qgis.html#more
I have downloaded the relevant python script and edited it as ...
