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

learn more… | top users | synonyms

0
votes
1answer
35 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
40 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
53 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: ...
0
votes
2answers
103 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 ...
-1
votes
1answer
38 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 ...
4
votes
1answer
155 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
3answers
80 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 ...
2
votes
1answer
37 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 ...
2
votes
2answers
67 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 ...
2
votes
1answer
89 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 ...
0
votes
2answers
65 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?
2
votes
2answers
187 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 ...
1
vote
1answer
44 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 ...
1
vote
1answer
114 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
2answers
57 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
158 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
33 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
61 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
30 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
119 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
42 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
74 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
344 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
58 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
1answer
432 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
53 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
253 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
51 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
112 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
68 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
105 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
208 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
137 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
160 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
1answer
125 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 ...
5
votes
2answers
444 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
13 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
316 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
147 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
1k 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
319 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
239 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
480 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
112 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
949 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
693 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
299 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 ...
3
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
289 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 ...