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

learn more… | top users | synonyms

2
votes
2answers
18 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
1answer
23 views

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

The following piece of code is successfully returning a shp following the driver and crs of a model shp. But I cannot make it to hold the float values I am writing to it: import numpy as np #just to ...
1
vote
1answer
45 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
36 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 = ...
3
votes
1answer
119 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
13 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
53 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 ...
0
votes
1answer
22 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 ...
2
votes
1answer
76 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 ...
0
votes
1answer
32 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
68 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
216 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
42 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 ...
2
votes
1answer
293 views

Converting Matplotlib contour objects to Shapely objects

I would like to convert a Matplotlib contour collection to a Shapely geometry collection, in order to calculate the area contained within closed contour lines. it seems that all the information is ...
0
votes
1answer
43 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 : ...
0
votes
0answers
43 views

Shapely tolerance overlapping layers

Is it possible to define a tolerance by applying a overlapping layers function in Shapely?. I'm trying to make an intersection between lines but the results are different with other GIS. regards.
1
vote
2answers
175 views

How to create a Shapely LineString from two Points

If have two points, from which I want to create a straight LineString object: from shapely.geometry import Point, LineString A = Point(0,0) B = Point(1,1) The Shapely manual for LineString states: ...
1
vote
0answers
50 views

Point in Polygon operation for 100G of data

I have lat/lon point locations for over a billion points, all based in the US. For each point I would like to generate a dataset that links them to their county and to their MSA according to US Census ...
1
vote
1answer
92 views

Shapely WKT precision/rounding

I'm using Shapely's wkt.dumps function to get WKT from geometry objects. I can't seem to find a way to limit the precision of the coordinates. Any help is appreciated.
0
votes
0answers
60 views

need help creating layer with geom type wkbGeometryCollection with gdal python

I am having trouble creating a layer with geom type as geometry collection. Thus I am unable to output to a shapefile. I have attached code below. dstLayer is null. This does not happen if geom type ...
0
votes
0answers
90 views

aggregate counts on a grid and determine grid adjacency

So here is the problem I am working on. I have a bunch of lat, long coordinates for event occurrences. I want to create a grid and then count how many points fall into each grid pixel. Once I have ...
0
votes
1answer
168 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 ...
3
votes
2answers
119 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
vote
1answer
118 views

Equivalent function to shapely's envelope in ogr?

I wrote a very simple python function that gives me the envelope/bounding box/...based on two coordinate pairs (ower left and upper right corner): # ... def get_bounding_box(self, ll_corner, ...
1
vote
0answers
98 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 ...
4
votes
2answers
347 views

how would one get the end points of a polyline?

I am attempting to write a script to get the end points of a series polylines, and then use those end points to create a polygon. I'm not sure which tools to begin to use on this project. I would ...
0
votes
0answers
12 views

How to create a shapely multipolygon from GADM shapelife? [duplicate]

I am using GADM (http://gadm.org/country) to get shapefiles from administrative areas anywhere in the world (trying with the US at the moment). To read the shapefile I am using Fiona in python. This ...
1
vote
2answers
222 views

Get the vertices on a LineString either side of a Point

I have a shapely LineString and defined a shapely Point which lies along the LineString. How can I find the vertices of the LineString which lie either side of the point? (split the line in two). ...
1
vote
1answer
130 views

create a pie shaped object in shapely and export to gis polygon object

I would like to create a pie chart-shaped polygon with concentric layers like so: I can create this simple object with: from math import sin, cos, radians from shapely.geometry import ...
4
votes
1answer
783 views

Shapely unable to tell if polygon contains point

For an application I want to determine under which constituency a given coordinate falls. After looking at the various options, I decided upon shapely and fiona as the easiest way to implement this. ...
2
votes
2answers
240 views

Shapely MultiPolygon Construction - Will not accept the entire set of Polygons

I am new to Shapely, so I am using a work request to learn a bit more about it. I need to execute a number of unions to build larger geometries from assessment neighborhoods in DC. I am curious ...
3
votes
1answer
202 views

Serialize python list containing geometry

In simple case if list doesn't contains geometry all works fine: result = [dict(f.fields, id=f.id, label=f.label) for f in features] json.dumps(result) But if result list contains geometry ...
0
votes
1answer
389 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 ...
0
votes
1answer
98 views

Shapely Python NameError when using cascaded_union

I am fairly new to Python and therefore my error-solving skills are not much yet developed. I am using Python within a geoprocessing script which is supposed to use ogr (reading/writing shp) and ...
7
votes
1answer
746 views

Find Nearest Line Segments to Point

Background From a known Point, I require to establish the nearest surrounding "visible perimeter" against a table of MultiLineStrings, as shown on the diagram. I've searched this site with a number ...
2
votes
2answers
554 views

What is the unit the shapely length attribute?

I'm doing a very simple calculation of the length of a polyline using shapely: from shapely.geometry import LineString ... xy_list = [map(float,e) for e in xy_intm] line = LineString(xy_list) s = ...
0
votes
1answer
265 views

Finding differences between two shapefiles in Python

I'm trying to find out whether there were any border changes between two yearly shapefiles. I've heard a lot of praise for Python's open source GIS tools like Shapely/Fiona, and thought I would try ...
2
votes
2answers
2k views

Determine if point is within an irregular polygon using Python

I would like to create a mask of a grid where points are evaluated as either 1's or 0's depending on if they lay outside of an irregular (i.e. not rectangular) polygon. I have a set of high-latitude ...
-1
votes
1answer
233 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 ...
3
votes
1answer
303 views

Fiona - Preffered method for defining a schema

I'm fairly new to the world of python and GIS - so this is definitely a beginner question. I am following Tom Macwrights small guide to Shapely and Fiona, and I noticed that even when opening the ...
0
votes
2answers
355 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
2answers
265 views

Does shapely within function identify inner holes?

I have a series of shapefiles that include both polygons and multipolygons. I am using ogr to extract them in wkb, and them I am using shapely to check if a point fall inside a polygon (or a ...
3
votes
2answers
1k views

Creating Shapely MultiPolygons from shape file MultiPolygons

I'm reading a shapefile using Fiona: with fiona.open('data/boroughs/boroughs_n.shp') as source: mpolys = [p for p in source] candidate = polys[0]['geometry'] this gives me a dict containing a ...
1
vote
0answers
129 views

How to shift vertices of shapes in shapefile using FOSS python library?

I need to shift each vertice of shape in a shapefile (of any type:point, line, polygon, multiline etc.) with Python. I need to loop in all shapes, get the vertices, get it's coordinates and for each ...
1
vote
2answers
340 views

Convert 3D WKT to 2D Shapely Geometry

I have the WKT of many linestrings which contains three dimensions, however my script only requires a two dimensional linestring and I therefore want to discard the third dimension. My current code, ...
4
votes
1answer
202 views

How to generate overlapping polygons from lines output from Table To Ellipse tool?

I have a feature class of line-based ellipses generated by the Table to Ellipse tool that looks like this: What I want is polygons of the individual ellipses, however tools like Feature to Polygon ...
2
votes
1answer
703 views

How to install shapely on Ubuntu 12.10

I have tried to install shapely on Ubuntu 12.10. Therefore I installed libgeos-c1, pip and shapely with $ pip install Shapely. The shapely files are now in /home/user/build/Shapely. When I try to ...
3
votes
1answer
249 views

Is there an online reference available for the Fiona and Shapely libraries?

Is there an online reference available for the Fiona and Shapely libraries? I'm thinking a real reference, beside the tutorial-style documentation: http://toblerity.github.io/shapely/manual.html ...
1
vote
0answers
288 views

Install shapely for QGIS on Mac

I know there are a number of similar questions, but none of them have answers that allow me to use shapely in QGIS. In particular I am trying to install the Contour plugin, but this fails with the ...
2
votes
1answer
63 views

how to differentiate between common parts of the triangle and extract linestring from it

Can you help me break down shape A to different linestrings: lines 2 & 3 AND line 1? The shape contains three different polygons (A, B, C). I wish to determine the start/end point of each part ...