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

learn more… | top users | synonyms

5
votes
2answers
73 views

intersecting two shapefiles from Python or command line

I'm new to working with geo data and trying to address a similar question to the one posted here. Using command line and/or shapely/fiona, in the most efficient and elegant way. I created two ...
1
vote
0answers
24 views

How do I create a raster file from a geopandas dataframe storing lats, longs, values, and geometries

From a text file with time, lat, long, and cf values, I create a pandas dataframe (cf_df). Then I use the lat, long values to create a geoseries and create a geopandas dataframe from the original ...
0
votes
0answers
5 views

Converting branched multiline into series of single lines in shapely

If I have a multiline string representing a branched network with a common starting point (red network in pic below): Does anyone know how to convert this to a set of individual single linestrings ...
1
vote
0answers
25 views

Interpolating every X distance along line in shapely

If I have a shapely multiline object that contains many lines whose total length each is 50km (when traced from the origin), and I want to interpolate along the multiline every X meters (let's say ...
1
vote
1answer
36 views

fiona ValueError: invalid literal for int() with base 10: 'str'

Why below code does not work- import fiona from fiona.crs import from_epsg my_schema = {'geometry': 'Point', 'properties': {'mean_in': 'str', 'total_h1': 'str', 'total_h2': 'str', 'LOS': 'str', ...
0
votes
0answers
21 views

Using shapely and geopandas in pyspark

I'm new to geospatial analysis and trying to start the analysis using python. Since the data is too huge we are trying to make use of hadoop and spark to get the analysis done. I would like to use ...
0
votes
2answers
30 views

Shapely Not Determining Point in State

I am pulling State geometry data from a database (populated from Shapefiles) to find what state a coordinate pair is in. I was originally using GeoAlchemy, but tens of thousands of queries to ...
8
votes
3answers
165 views

“Greedy” clipping lines with polygon

I am wishing to clip a set of polylines (black lines in image below) to the outer boundary of a polygon. Any voids within the polygon should be ignored. My ideal output are the dashed yellow lines. ...
1
vote
0answers
33 views

Projecting GeoJSON polygon object in python to calculate area

I have a script, written in python, that does many calculations - but one set of calculations hinges on determining the area of a polygon that I read in, in GeoJSON format. I can convert this object ...
0
votes
2answers
102 views

Point in Polygon - geojson - using Shapely / Python returning incorrect results

I'm trying to test if a point is inside a polygon using this example: http://stackoverflow.com/questions/20776205/point-in-polygon-with-geojson-in-python However, my output says that none of the ...
0
votes
0answers
39 views

Intersect using Open Source GIS [duplicate]

I have a CSV containing user locations (has lat, long, userid, timestamp). I have a countries shapefile (has country name, geometry - got this from thematicmapping.org). I am trying to append a ...
4
votes
0answers
21 views

“Merging” 2 layers of LineString with splits at intersections

I would like to "merge" 2 networks of lines and these lines need to be split when they intersect. With pictures it should be clearer : What to do: if a black line intersects a red line, they ...
0
votes
0answers
50 views

Calculating distances with lat/long in decimals and WGS 84

I need to calculate the distance between points of two different datasets, once with locations of towns, the other with locations of dams. Both are located in different countries in Africa. The more ...
3
votes
1answer
47 views

When validating geometries, what are “Nested shells”?

I am validating shapefiles polygon geometry using shapely, and have also attempted it using FME. Some polygons return the error "Nested Shells". I cannot find a definition of what the problem is, ...
1
vote
0answers
37 views

Error and kernel dies with shapely/geos inside Jupyter notebook

I have a Python 2.7 script (code below) that scrapes data from a table on the web and draws a map. It runs fine from the command line using $ python bears.py When I run the identical script from ...
1
vote
1answer
43 views

How to split epsg 4326 linestring in parts consisting of given length in meters in python?

I want to know linestrings (epsg:4326) length in meters instead of degrees. I know that I can use proj4 for that. Here is my code, if you interested. project = partial( pyproj.transform, ...
1
vote
0answers
40 views

Creating spatial layer from MS SQL Server table?

I have a table in MSSQL that I am trying to use to create a spatial layer from using the QgsVectorLayer function to load the table as a layer, and then using Fiona to create a shapefile but I am ...
-1
votes
1answer
63 views

fiona writing geometry into shapefile problem [closed]

Context: I use lxml library that generates some dictionary (infact it is xml attribute dictionary) from xml and i am trying to write these into a shapefile-i.e. get one element-attribute from xml ...
3
votes
1answer
117 views

What is Shapely library alternative in R?

I want to manipulate 2D geospatial geometries in R. I am used to using Shapely in Python but I am a newbie in R. Can you suggest Shapely alternatives for R?
1
vote
1answer
164 views

GeoPandas: return lat and long of a centroid point

I would like to return the lat and lon or x and y from the point object in the following series as I plan to link them with an API I built that links OSM and NetworkX. The centroids will be added as ...
4
votes
2answers
195 views

geopandas/shapely: what units it uses/calculates for area and distance functions?

it looks like a silly question, yet I can't find clear answer on that: what units geopandas/shapely use calculating distance/area between objects?
0
votes
2answers
144 views

Python buffer points and clip with line-segment (OS Open Roads in BNG) [duplicate]

I have an array of points (in latitude, longitude coordinates) which I would like to buffer and dissolve (into a polygon) and then intersect the Ordnance Survey Open Roads (projected in BNG) with that ...
4
votes
0answers
102 views

Counting features into intersections of Shapely Polygons

I have a geopandas GeoDataFrame containing hundreds of shapely Polygon and MultiPolygon geometries. The polygons overlap in lots of places. I'd like to make a new geometry that contains a count of how ...
1
vote
1answer
52 views

Points to irregular grid

I have a huge dataset (millions of points) and a irregular grid (quadtree) in shapefile format and I need to convert the points in countes over the grid provided. I managed to make it work, using ...
2
votes
2answers
53 views

How to successfully do “nested” looping over a Fiona collection

I wrote some code that basically loops over all features in a shapefile with Fiona in Python, doing some things, calculating some things, etc. I found that it would exit the for loop prematurely, ...
2
votes
1answer
117 views

QGIS Contour Plugin Says No Shapely; can import shapely in QGIS console

I'm keen to create some contours (isochrones for a pedestrian 'ped-shed' catchment) from a point dataset in QGIS, using the contour plugin from the Plugins repository. I installed the plugin, but ...
1
vote
0answers
25 views

Shapely's object.project method dealing with overlapping polyline

So I am interested in knowing how far along a polyline a given point sits. Python's shapely package has a method to do such a thing, see the below code: from shapely.geometry import LineString ip = ...
0
votes
0answers
35 views

Understanding output point in polygon solution?

My question refers to an old solution which is provided in How do I find out if a given lat lon is in a KML Linear ring using shapely? Using python3 I needed to update the code somewhat to get this ...
0
votes
0answers
26 views

Finding common segments in Shapely LineStrings

I have two identically-sized collections of Shapely LineStrings, representing two sets of routes from a common origin to a set of common destinations. For each "pair" of routes (i.e. set_a[0], ...
1
vote
1answer
58 views

Valid shapely dumps WKT becomes None when used as input to QgsGeometry

I'm trying to produce a multipolygon feature in QGIS. I am producing filled contours with Matplotlib, taking the multipolygons representing each contour level, using shapely to produce WKT, and then ...
1
vote
1answer
124 views

how install shapely on windows so it can be imported from matlab?

i'm on windows 7/64. shapely doesn't offer windows installers on their pypi page, even though they seem to have recently (github issues 104 and 109 -- i don't have the rep to post links. their pypi ...
6
votes
2answers
1k views

Dissolve polygons based on attributes with Python (shapely - fiona)

I have been trying to create a function that does basically the same thing that the QGIS "dissolve" function. I thought it would be super easy but well apparently not. So from what I have gathered ...
1
vote
1answer
92 views

Country border between two points

I am trying to extract country borders between two points, using Python. The border is a Shapely Polygon.exterior or LinearRing, the start and end points are Shapely Points. My idea is the following: ...
1
vote
0answers
230 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 ...
1
vote
1answer
522 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
245 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, ...
1
vote
0answers
96 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 ...
1
vote
1answer
278 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
440 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
96 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 ...
2
votes
1answer
84 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. ...
1
vote
2answers
131 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
136 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 ...
0
votes
1answer
259 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. ...
2
votes
1answer
122 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
1answer
475 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
251 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 ...
6
votes
1answer
1k 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 ...
3
votes
2answers
305 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)) ...
1
vote
2answers
727 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 ...