Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects.

learn more… | top users | synonyms

1
vote
0answers
19 views

Point in Polygon using Rtree and Shapely

This is a repeat of my question over on StackOverflow. All, I am wondering what the correct syntax is for doing a point in polygon search using Shapely and RTree. I'm really interested in speeding ...
4
votes
2answers
291 views

Understanding the Use of Spatial Indexes

I'm having trouble understanding the use of spatial indexes with RTree. Example: I have 300 buffered points, and I need to know each buffer's intersection area with a polygon shapefile. The polygon ...
2
votes
2answers
359 views

create polygon adjacency matrix using python

I am trying to create an adjacency matrix from a set of polygons. That is, I have a bunch of polygons and I want to identify which polygons have a common edge or "touch" each other. Once I find this ...
1
vote
1answer
74 views

Plot points on map using Fiona and/or Shapely

I have written a parser in Python that extracts the coordinates out of a GPX file and I would like to view those points on a map. I have done a little research and it seems like either Fiona or ...
1
vote
1answer
88 views

differences in distance between shapely and geopy

I am getting totally different distances from shapely and geopy. On one hand - it makes total sense, shapely measures on a plane and geopy measures on a spheroid. But the differences are so dramatic, ...
2
votes
1answer
76 views

Why is Shapely and contains_point not detecting point being on land?

I'm using the world shape file that can be found at https://trac.openstreetmap.org/browser/applications/editors/merkaartor-branches/merkaartor-0.14-fixes/share/world_shp/world_adm0.shp?rev=17052. ...
1
vote
0answers
36 views

Reading/writing utf-8 encoded data using Fiona?

So I have a 'cpg' file with my 'in_file' shapefile data (definitely set to 'utf-8'). I was using 'meta' to create the same schema/crs as 'in_file'...though it runs, my text fields are borked on ...
0
votes
1answer
63 views

Problems with Geometry collections. (Fiona: write output of Multipoints and Points)

Updated: I am getting the following error on this function: ValueError: Record's geometry type does not match collection schema's geometry type: 'Point' != 'MultiPoint' The problem is that I have ...
0
votes
2answers
70 views

How to measure distance using shapely

Reading the documentation...it looks like I should have this right, but I don't. The example is: Point(0,0).distance(Point(1,1)) 1.4142135623730951 Based on this example I wrote this block ...
1
vote
1answer
51 views

How to call 'shapely' .coords on a fiona filtered list?

I have to filter a shapefile by attribute then compare it to another shapefile using .coords...however I am a bit perplexed how to do this as my filter is returning a list type...(and .coords requires ...
0
votes
2answers
48 views

Shapely (geos) crashes during unary_union

When attempting to union multiple polygons with Shapely 1.5.6 in Python 2.7.9, using GEOS 3.4.2, I get the following error in the underlying C++ code: Assertion failed: (!"should never be reached"), ...
2
votes
1answer
46 views

How to find the distance of a point from the begning of a StringLine with shapely?

I have a route (represented by StringLine) and a location (Point) and I need to find the progress of the location in the route. The progress is the distance in meters from the begning of the route. ...
2
votes
1answer
65 views

Error with Python Script using Shapely

My professor gave us a basic Python script that demonstrated how Shapely works with a shapefile, however it's not working for me. Here is the code: from shapely.geometry import mapping, shape from ...
4
votes
2answers
2k 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 ...
6
votes
5answers
1k 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, ...
0
votes
0answers
87 views

Why can't Basemap's readshapefile read the world_adm0 shapefile?

I'm using the world shape file that can be found at https://trac.openstreetmap.org/browser/applications/editors/merkaartor-branches/merkaartor-0.14-fixes/share/world_shp/world_adm0.shp?rev=17052. ...
1
vote
1answer
135 views

Writing a shapefile using OGR, from Shapely Geometry - No feature added Error

I am trying to write a shapefile from a Shapely geometry using PyQGIS in the QGIS 2.6.0 console. Lines of code before the OGR method to write shapefile: extnt = poly.extent() # gives a QtRectangle ...
1
vote
1answer
89 views

Multi-part Geometrical Intersection error

I am working with intersection of polygon and line segments (continued from a previous question). When a Line intersects with a Polygon, the result is a LineString; When a LineRing intersects with ...
3
votes
1answer
235 views

How to get the two nearest points between two polygons

I'm trying to draw the nearest line between the nearest polygons in a Polygon dataset (ESRI Shapefile). I know that for this purpose there is the Near Tool (ArcGIS), but it just return the point TO ...
2
votes
1answer
94 views

Area in KM from Polygon of coordinates

I have polygons from coordinates in (python shapely) that looks like this POLYGON ((24.8085317 46.8512821, 24.7986952 46.8574619, 24.8088238 46.8664741, 24.8155239 46.8576335, 24.8085317 46.8512821)) ...
4
votes
1answer
280 views

Line vs. Polygon Intersection Coordinates

I am working with Python, Shapely and Fiona... Is there any way where I can give in an input of a line shapefile and a polygon shapefile, and get a result of the intersection points and their ...
1
vote
2answers
141 views

Transforming Shapely Polygon and MultiPolygon objects

Is there an easy way of transforming Shapely objects (namely, Polygons and MultiPolygons) from one projection to another without having to dig around and extract coordinates by hand? In fact, I ...
1
vote
1answer
148 views

Fastest way to add shapely geometries to a PostGis database using geoalchemy2

I am looking for the absolute fastest approach to adding +10,000 shapely geometry objects to a PostGIS database using geoalchemy2. I'm having no speed issues when uploading to a localhost postgres ...
0
votes
1answer
146 views

Installing Shapely with libgeos_c on Linux?

The installation instructions for shapely suggest: "Windows users should use the executable installer, which contains the required GEOS DLL. Other users should acquire libgeos_c by any means, make ...
1
vote
0answers
148 views

Generate random points in polygon. Algorithm question

i created a Random Point Generator in python using the algorithm described here by @whuber. The algorithm is implemented using Shapely, PostGIS and psycopg2. To boost performance pythons ...
-1
votes
2answers
262 views

How do I import geos from shapely? [closed]

I clearly have geos installed under shapely, since I downloaded "Shapely-1.4.4.tar.gz". Also, the result can be seen in my directory in the correct path: ...
-1
votes
1answer
81 views

creating circle with radius in metres

I am using shapely and python. How should I go about creating a circle using shapely whose radius is in meters? If i use sampleCircle = Point(1,1).buffer(1) print sampleCircle.area This returns an ...
0
votes
2answers
536 views

Convert shapely polygon coordinates

I am trying to work with a shapefile using shapely, fiona and python. The original coordinate system is in latitude and longitude that I am trying to convert to state plane system. So I want an ...
2
votes
2answers
163 views

Maximizing Code Performance for Shapely

I've written this code in order to calculate the percent cover of grassland within a national park, within 20km^2 of points of recorded occurrences for a species. It is designed to only consider the ...
3
votes
3answers
189 views

Removing small polygons gaps in a Shapely polygon

I know this issue has been addressed before with different software, but I am looking for an approach with Shapely. I have a polygon with a very small gap on the interior of the shape: Here is a ...
0
votes
2answers
497 views

problems with py2exe, shapely and fiona

I have a short python script, called test: import fiona with fiona.open("C:\\Essai_compil", 'r') as l_Obs_shp: for shp in l_Obs_shp: print shp['geometry'] I want to compile with ...
2
votes
1answer
91 views

Shapely's simplify won't simplify any more

I have a multipolygon in shapely, and I want to simplify it until it has less than a certain number of points. When I use the preseve_topology=False argument to geom.simplify, I can get the number of ...
1
vote
1answer
61 views

Properly writing floats to feature properties of a new shapefile in Fiona

The following piece of code returns a shp following the driver and crs of a model .shp. import numpy as np #just to test I correctly handle data types import fiona from shapely.geometry import ...
3
votes
1answer
231 views

Reading postgis geometry with shapely

I am doing a small-scale workflow in ipython notebook with geopandas and shapely, pulling a bunch of geospatial data, sometimes from shapefiles, sometimes from postgis (where more expensive processing ...
3
votes
2answers
140 views

shapefile record has no attribute named bounds

This is the code that I am using to print the bounds of my shapefile. import fiona import shapely import shapely.geometry fc = fiona.open("filename.shp") shapefile_record = fc.next() shape = ...
2
votes
2answers
888 views

Intersect Shapefiles using Shapely

What I'd like to try and do is intersect some point buffers with census tracts, maintain their ID's and the tracts attributes. I found a sample from ...
0
votes
2answers
207 views

Count the number of points in a (multi)polygon in shapely?

I'm using Python, Shapely and Fiona to process some shapefiles. Is there an easy way to count the number of points in a polygon/multipolygon in Shapely and Fiona?
0
votes
1answer
797 views

Shapely LineString and Polygon intersect?

here is my python code, it does not intersect and when I plot this in google map , I see the intersection. shapely.geometry is in Cartesian plane, how you are solving this? l = "40.65:-114.07 ...
2
votes
1answer
331 views

Fiona + Shapely: Loading a set of LineStrings and writing their centroids to a shapefile, including original properties

I am using Fiona to load a set of links. Then I put every record in the rows of a pandas.DataFrame. Then I get the centroid of each LineString using Shapely. Afterwards I copy the schema of the ...
3
votes
1answer
231 views

Shapely/ Python looping through a number of polygons

I am trying to loop through a set of polygons in shapely so using python) to determine whether they overlap or not. I do not want to do it manually as later i want to generalise the procedure and do ...
0
votes
0answers
82 views

Adding a Property (attribute) to a geometry in Shapely/Fiona

Once you have line and polygon geometries, intersection using Shapely is very straight forward. What I did after that is to integrate all the looped 'intersected' geometries into a MultiLineString. ...
2
votes
0answers
68 views

Where is my Polygon?

I created this script to merge all of the polygons in a shapefile into a single polygon. I am using Python 2.7.5, Shapely 1.3.0, and Fiona 1.1.5. def merge(path_in, path_out): #Import Libraries ...
1
vote
1answer
55 views

ValueError when instantiating LineString from a mix of tuples and Point objects

I'm new to Shapely, and tried instantiating a LineString object from a mix of tuples and Point objects like this: >>> LineString([Point(1,2),(2,3),Point(3,4),(5,5)]) I get the following ...
0
votes
1answer
52 views

Adding a Vertex To Exisiting Feature(linear) Using OGR Python

I am working on a project that involves finding the intersection of linears in a shapefile, if that vertex(the found intersection) doesn't already exist for each(or one) of the features, then that ...
0
votes
0answers
92 views

how to remove a point or polygon in shapely python

I want to place minimum number of sensors(circles) to cover a maximum area(polygon). I am using "Shapely",python module. I want to know if a sensor i.e a point buffer inside the range of the other ...
0
votes
2answers
662 views

MultiLineString to separate individual lines using Python with GDAL/OGR, Fiona, Shapely

There are lots of MultiLineString features in a polyline shapefile. The problem is to split these lines into separate individual lines. There is a similar question with PostGIS, but I need to code in ...
0
votes
0answers
130 views

Correctly drawing wrapping circles using Basemap

I've been using the functions from here to draw circles on maps using Matplotlib Basemap. This works well, but breaks badly at the map edges: I'm wondering whether there's a general approach for ...
3
votes
2answers
181 views

Can I convert the sharp edges of a polygon easily to round edges?

I use the python module "shapely" to make Polygons (like below). Can I convert the sharp edges of a polygon easily to round edges? Such that when I have unified some polygons I could issue a command ...
-1
votes
1answer
370 views

Calculating intersection between points and polygon in shapefile

I want accomplish the following using command line python tools only (shapely + fiona) I was wondering if there was a straightforward way for me to do the following: Read in a shapefile (all ...
0
votes
1answer
77 views

Add attributes to an output shapefile schema (via meta)

I am trying to copy the schema of an existing shapefile and add to it in an output shapefile. Somehow I am not getting anywhere with this...though the docs seem very clear (and the download page : ...