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

learn more… | top users | synonyms

2
votes
2answers
47 views

Save Start/End Points in another shapefile using Shapely

I'm trying to get the start/End points of a Shapefile which geometry type is lines, using Shapely. Here's what I tried : import geopandas from shapely.geometry import * import fiona schema = { '...
4
votes
0answers
22 views

Why is Shapely's snapping (GEO snaps) not working as expected?

I'm trying to snap two lines to each other using Shapely/Geopandas but the result of the snapping is very odd. I tried : import geopandas as gpd from shapely.geometry import * from shapely.ops ...
1
vote
1answer
45 views

Split lines at points using Shapely

I'm trying to split a shapefile of geometry type 'line' at a shapefile of geometry type 'point. These points are snapped to the lines and are the start points/end points of other line shapefiles. ...
3
votes
1answer
61 views

Snapping two lines using Shapely

I'm trying to snap two Linestrings shapefiles using Shapely/Geopandas. I tried : import geopandas as gpd from shapely.geometry import * from shapely.ops import snap lines1 = gpd.GeoDataFrame....
0
votes
0answers
22 views

Finding intersections in multiple files and exporting to single shapefile using OGR

I saw this solution using Shapely, but unfortunately I can't get Fiona to work with my Python IDE nor with OsGeo4W. I have a single shapefile that has a 500m buffer on about 350 trail polylines. I ...
0
votes
1answer
19 views

Turn a GeoDataFrame of x,y coordinates into Linestrings using GROUPBY?

I have a dataframe of X,Y coordinates that represent points along the paths taken by several different entities. Pseudo-data here, but it is roughly of the form: entity_id lat lon time 1001 ...
2
votes
1answer
56 views

Shapely & RTree vs. PostGIS/PostgreSQL?

I would really like some insight to the pros and cons of one approach versus the other. I recently wrote some python code that inspects two layers of the same test ESRI GDB file using RTree (bounding ...
2
votes
0answers
28 views

Python Shapely - filling small gaps between multi polygons

I have a set of rectangular polygons, which currently form a directional path. The library I am using is Python Shapely / GeoPandas. The issue I am having is as the path changes direction, there are ...
0
votes
2answers
37 views

PySal and PostGIS (maybe via Shapely). How can these two interact?

I'm trying to learn the use of PySal and Python. As I'm already regular user of PostGIS, I would like to integrate the database as the storage medium for the data to be analysed. I'm using the test ...
1
vote
2answers
71 views

Angle at intersection point from two Lines

I would like to find the angle of two lines at their intersection point. In my opinion it is the azimuth I'm looking for, right? So I'm using Python with shapely for finding the intersection and ...
3
votes
2answers
48 views

Find common borders of features and get their attributes using fiona and shapely

I would like to find neighboured features in a shapefile using fiona and shapely. As shown in this answer http://gis.stackexchange.com/a/95595/62250 it's easy to get common borders between features. ...
0
votes
1answer
34 views

How to Convert 3D coordinates to 2D coordinates for R-Tree?

I am trying to implement a bounding box via a spatial index and get an error stating that I must either provide coordinates as either (minx, miny, maxx, maxy) or (x,y) for 2D indexes. I've tried ...
1
vote
0answers
68 views

Find Properties of Nearest Line Segments to Point in Python

I have been trying to find a workable Python approach to finding nearest line segments to one (or more) points, and came accross @gene's solution to @RustyMagoo's problem here: from shapely.geometry ...
1
vote
1answer
67 views

How To Properly Implement a Bounding Box for Shapely & Fiona?

I am trying to spatially analyze two layers within same GDB file using Python / Shapely. Another user was kind enough to give me a procedure to go by in trying to reduce the number of senseless ...
1
vote
0answers
37 views

Spatially Analyzing two layers within same File Geodatabase using Python / Shapely?

I'm using a nested for-loop to do Shapely analysis between two Python lists created via two pre-reads of the same GDB file. One list contains all the features of a particular layer while the other ...
3
votes
2answers
173 views

Can this Be Recoded to Be More Efficient with Respect to Processing Time?

I'm very new to GIS but have been asked to parse through any given ESRI GDB file-folder without using any ESRI product. I've been trying to focus on using Fiona and Shapely as these seem to be ...
0
votes
0answers
33 views

How to do a Python / Fiona / Shapely equivalen to an ESRI ArcPy SpatialJoin?

I'm a GIS noob, but I am trying to learn as quickly as I can. Please bear with me. How can I identify what structures from one layer are WITHIN in some body of water in another layer? My problem ...
1
vote
1answer
47 views

How to Parse Through a ESRI GDB File/Folder After Opened with Fiona?

I should point out that I'm a noob. I'm playing around with making a python gui app and believe I have opened an ESRI GDB file/folder using: with fiona.open(GDBPath, 'r') as sourceGeoData What I'd ...
0
votes
1answer
181 views

Check if point is within radius of another point with Shapely

I've successfully used Shapely with python to check if a point is within one of a set of polygons in a .shp file but now would like to check if a point is within a circle of radius x miles from ...
2
votes
1answer
42 views

How to create a Null shape in shapely

I want to create a valid Shape object in shapely which has properties but has no geometry. e.g. For creating features to be saved into a shapefile. All features have attributes/properties but some ...
1
vote
1answer
152 views

Assign a point to polygon using pandas and shapely

I have a series of Easting and Northing coordinates in pandas dataframe along with other columns of information. I know the coordinates fall within and administrative area and want to match the ...
2
votes
1answer
123 views

Get intersection of circles shapely

I have a List of Points which I transform to circles. Code from here circles = [Point(random.random(), random.random()).buffer(random.random() * 0.1) for i in range(3)] I want to know which circles ...
0
votes
2answers
51 views

Trouble getting shapely to run

I downloaded the GDAL complete Framework von Kyngchaos which also includes the GEOS Framework and shapely for python. I can import shapely without a problem, but when I try to perform some "geo ...
1
vote
2answers
99 views

Is it possible to round all coordinates in shapely?

Following on from How can I add points to a LineString in shapely?, I'm hitting a problem where floating point representations mean objects aren't precisely where I expect them be after they are moved ...
2
votes
1answer
63 views

Add SRID to Point

When inserting a point into a PostGIS database I do it using ST_GeomFromText('POINT(0 1 2)',26918). Note that this was done on a tutorial database where the SRID was set manually as explained ...
0
votes
1answer
83 views

How can I add points to a LineString in shapely?

I have two Polygons which intersect along one edge as shown below. I need to add the red vertices at each end of the intersection to the blue polygon. I thought I could do this with by calling ...
1
vote
1answer
85 views

How to simplify borders between polygons in shapely?

I have some fairly complex, and not completely accurate shapes stored as shapely Polygon objects. I'm trying to find the common borders, which should be as easy as finding the LineString returned from ...
1
vote
1answer
51 views

How to find the area with most intersection for buffer regions?

Find the area with the most intersection This question relates to previous question asked - How to find the intersection areas of overlapping buffer zones in single shapefile?. I tried to find ...
1
vote
2answers
187 views

How to polygonize raster to shapely polygons

I am seeking an open-source python solution to convert raster to polygon (no ArcPy). I did know the GDAL function to convert raster to polygon, and here is the manual: http://pcjericks.github.io/py-...
1
vote
0answers
74 views

cartopy: plotting shapefiles

I am new to gis and am trying to plot a shapefile containing land polygons. (From OSM.) Unfortunately my output image is always empty (i.e. white). Can somebody tell me what I am doing wrong? import ...
2
votes
1answer
226 views

How to find the intersection areas of overlapping buffer zones in single shapefile?

Find the intersections of the buffer zones I found an example where they tried finding the intersection of two different shapefiles -Intersect Shapefiles using Shapely. I've tried to adapt my code to ...
2
votes
2answers
289 views

Shapely Distance different from Geopy/Haversine

I am running a specific analysis where we use shapely to create buffers around points (store locations) and then check if other points (user locations) are present within that buffer value. When i ...
2
votes
3answers
116 views

I have an existing attribute table that I'd like to add values to the fields within it while preserving the geometry, how can I do this?

I've tried to use fiona and shapely and ogr, but the tutorials seem to be insufficient to describe how to do such a seemingly simple task. In arcpy this could be done simply with an update cursor. I'...
0
votes
1answer
98 views

How to access members of GeometryCollection - Python

I am using 'intersection' function from Shapely to find junctions of a road network. As i found, intersection returns GeometryCollection. In my case it could be Point, LineString or perhaps ...
1
vote
1answer
100 views

Difference between Crosses & Intersects - Shapely (Python)

I have two questions : I have some lines (eg: road network). I want to find coordinates of each junction. Should i use crosses or intersects function from python's Shapely module? They are giving ...
7
votes
2answers
145 views

Polygons across international dateline [-180..+180 longitude]

I'm trying to generate polygons for satellite orbital swaths. So far I have a method to generate two lines which represent the edge of each swath in [lat,long]. Some of the swath's cross the ...
0
votes
2answers
68 views

importing fiona before shapely raising geos-related OSError

I ran into an issue where the order of imports for fiona and shapely caused the following geos error below which happens when i import fiona before shapely. If I do the reverse all is fine. Must be ...
2
votes
1answer
132 views

Converting Shapely MultiPolygon to Polygon: Technique doesn't always work

In order to get the exterior coordinates I need to convert a shapely MultiPolygon to a Polygon. I do it like this: if poly.geometry.type == 'Polygon': x, y = poly.geometry.exterior.xy elif poly....
0
votes
1answer
69 views

Cut a linear feature according to the directions or azimuths

I have a shapefile linear that contains a single items as in the image and I want to divide it into several section respecting the azimuth and the line direction. i have this code : import os ...
5
votes
2answers
383 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
72 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
21 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 ...
2
votes
0answers
73 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
137 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', 'id':...
0
votes
0answers
99 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
39 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
197 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
101 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
383 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
59 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 ...