Questions tagged [shapely]

Shapely is an open source Python package for construction and analysis of 2D planar geometric objects common to geographic information systems.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

Issue exporting GeoPandas dataframe

I am trying to export a GeoPandas Dataframe looking like this to an external file: id geometry 0 POLYGON ((39.92713 1.41394, 39.92703 1.41394, ... 1 POLYGON ((39.95126 1.41866, 39.95116 1....
0
votes
0answers
33 views

How to find the points of hausdorff_distance()?

The Shapely hausdorff_distance() function returns a single (scalar) value. Is there a way to get the/a pair of points on both geometries that fit this distance? Similar to how we have ...
1
vote
1answer
34 views

Updating Pyproj syntax results in other values

I want to know the length in meters of a LineString with coordinates in EPSG4326. Based on this post, this is code that works for me: from shapely.geometry import LineString from shapely.ops import ...
0
votes
0answers
25 views

Where can I find the source code of shapely.geometry.multilinestring.interpolate() function?

When I use shapely.geometry.multilinestring.interpolate() function, it creates points at every 50 m along the multiline. I try to create a points at a given interval (lets say the distance between ...
1
vote
0answers
24 views

More stable spatial sort using Shapely's within?

I was trying to use a modified version of the spatial sorting method illustrated in shapely's documentation, using only polygons exteriors (so that I can detect if a polygon lies inside another ...
2
votes
1answer
98 views

Accelerating GeoPandas for selecting points inside polygon

I have one dataset with about 10 million points (lat, long). I would like to select the points that fall within a map. I have this map as a shapely object (.shp). To do this, I transformed the ...
-1
votes
0answers
10 views

Add intersection coordinates to the Linestring using Shapely [duplicate]

I have two line strings as shown in the picture below. Blue and green. How to add the coordinates of the orange line(orange dots) to the green line and make it a single new line using Shapely ...
1
vote
2answers
41 views

Project large collection of shapely object to different CRS [closed]

What is the most efficient way of projecting several thousands of polygons and multipolygons to a different CRS in Python? I have found that looping over the polygons and reprojecting them one by one ...
1
vote
1answer
39 views

Adding points every X distance along a LineString [closed]

I have a list of LineString coords: list = [(90, 170), (99.0, 159.0), (321.0, 159.0), (300, 146), (296, 23)] which looks like this. How to interpolate a point at every X distance along the line ...
1
vote
0answers
21 views

Problem when trying to cut linestring at multiple points after conversion from Multi-linestring

This is my script: def cut_line_at_points(line, points): ''' line is gdf format points are series of points in gdf format ''' # union all geometries - convert the gdf to shpely (...
2
votes
2answers
74 views

Accelerating the code for random selection of polygons

I have a shapefile with thousands of features (polygons). I need to randomly sample one polygon at every 1 sq. km. area if at least one polygon is available. I wrote the following code which works. ...
1
vote
1answer
119 views

TypeError: cannot unpack non-iterable NoneType object on Spatial Join

I'm working with two spatial dataframes and am trying to do a spatial join on the two. parcels_sdf -- a frame with around ~370,000 real estate parcels. subdivisions_sdf -- a frame with all ...
4
votes
1answer
58 views

GeoPandas Intersect function gives different result to Shapely

Using this example dataset of country geometries, I seem to get a different result on whether or not the USA and Mexico intersect when I do the calculation with GeoPandas as opposed to directly with ...
0
votes
1answer
65 views

Extracting the least area image around a Shapely polygon, with rotation allowed

I have a Shapely polygon polygon_geom = shapely.wkt.loads(feat['wkt']) such as: I can map it onto an image polygon_pts = np.array(list(polygon_geom.exterior.coords)) plt.imshow(img_array_pre) ...
0
votes
0answers
27 views

Export geodataframe with shapely polygon to sql server table (geometry)

I'm pulling open street map data into a geodataframe and looking to write the results to a sql server database. The geometry types are polygon and they are in shapely format. When I attempt to write ...
0
votes
1answer
52 views

Finding coordinates of point on line joining two points at certain distance from one of points using shapely [closed]

I am new to GIS. The question I am going to ask has been asked before but it didn't solve my purpose. I am only using python and shapely. I need to find the coordinates of a point on a line joining ...
1
vote
1answer
33 views

Create LineString from lat/lon coords form CSV. with beginning and ending lat/lon?

I am iterating through a CSV file of tornadoes, and for each row getting the beginning lat, beginning long, ending lat, and ending long. and trying to plot their line geometry on a map. I got the ...
1
vote
1answer
33 views

Failing Unions due to Non-Noded Intersections

I'm trying to perform lots of unions in GeoPandas. I've got around fifty sets of between 7-12 GeoDataFrames of the same place at different times that I'm trying to union into one layer per set. Right ...
0
votes
0answers
29 views

How to count a radius of a polygon

I have a Polygon (shapely) and the centroid of this Polygon (with longitude and latitude). Is there any way to count radius of the Polygon?
3
votes
0answers
41 views

Multi-part geometries do not themselves provide the array interface

So initially I had multiple perpendicular lines along a coastline. Next I clipped these lines based on polygons along the coastline,such as the follwing. I am trying to use this resulting shapefile ...
1
vote
0answers
37 views

Shapely “parallel_offset” with distance in meters from Lat/Lon coordinates

I need to find a LineString at a distance in meters from a line with coordinates in Lat/Lon. I am trying this approach based on what i found in this question https://stackoverflow.com/questions/...
2
votes
0answers
37 views

ESRI Geometry Union slower than Built in dissolve which is slower than Shapely

I work with point datasets a lot. We try to keep a running layer of points and update the dataset with new points while removing the old points. So, we do a lot of checking the extents of the new ...
3
votes
1answer
60 views

Intersection tolerance error with Shapely

I am using Shapely to do a basic intersection operation. However, Shapely doesn't return the intersection line I am looking for. I though the reason might be Shapely's intersection doesn't have ArcGIS'...
0
votes
0answers
26 views

Deactivate INFO logging in shapely in Python

Is there any way of removing the prints from Shapely like this one INFO:shapely.geos:Ring Self-intersection at or near point 397577.99997770746 5902542 and keep just warnings and errors?
3
votes
1answer
69 views

Find the closest line to a polygon Python Rtree

I have a series of fields and roads I am trying to find the nearest road to each field. I want to add field to each of my polygons with the index/name/etc of the closest road. Would this be the ...
1
vote
1answer
48 views

How to write a multi geometries .geojson file with Shapely/Fiona?

I am very new to fiona and shapely, and trying to do something that doesn't seems to be designed : I have a list of points and a shapely.MultiPolygon (Voronoi polygons from the previous list of points)...
1
vote
0answers
45 views

Generating transects perpendicular to Shapely/Geopandas Line

I'm doing an analysis on transects going perpendicular to a 1000m topographical contour line and I'm struggling to find a good way to create evenly spaces transects perpendicular to that contour. As ...
1
vote
2answers
132 views

Creating Shapely Polygons with holes

I believe I understand the shapely methodology fairly well at this point. However, I'm struggling with getting my holes to populate to the polygons. I've tried a number of approaches. What I'm ...
3
votes
0answers
35 views

Split line at regular intervals in shapely

I have been trying to use Shapely to split a shapefile with multiple features at regular intervals. I have used the split function to do this. I can easily create the points at which the lines should ...
2
votes
1answer
86 views

How to create an hexagonal grid of regular hexagons of definite area anywhere on the globe, using shapely?

I have a geojson file describing a polygon. I want to create an hexagonal grid on top of this polygon, with regular hexagons of area 90000 square meters. Right now, I can either guarantee the area, ...
1
vote
1answer
191 views

Convert lines to polygons with shapely polygonize

I have a line shapefile that I am trying to convert to polygons with python using fiona and shapely. inFile = '/content/drive/My Drive/polyline.shp' outFile = '/content/drive/My Drive/polygon.shp' ...
0
votes
2answers
151 views

Python convert lines string to polygon if closed

I have a series of contour linestrings some are closed and some are not. The linestring values are between -1 and 1. I am trying to create polygons from the linestrings if they close and keep the ...
0
votes
0answers
26 views

Using Shapely polygons with GRASS GIS in Python

Would anyone be able to provide an example of how to work with Shapely objects in GRASS modules? Preferably how to convert Shapely polygon to GRASS format in order to use various tools within GRASS.
3
votes
0answers
97 views

Find a centerline of an intersection between two irregular shaped polygons

I have two irregular shaped polygons that overlap each other at least in at two points. I want to first find the intersection area between all of them, then for the polygon pair that intersects I want ...
3
votes
1answer
61 views

Find the vertices of the edge of the polygon where line intersects using Shapely

I have this function to get the intersection point of line and a polygon. How to find the vertices of the polygon(red dots marked in the image) edge where the line intersects using shapely? I have ...
0
votes
1answer
207 views

Getting CRS to export shapely polygon to shapefile

I am trying to export a shapely polygon to a shapefile. I have tried this, but the CRS is missing, when I try to import it in to QGIS. The shapely polygon is from this OSMNX example but edited to ...
1
vote
0answers
203 views

Python: distance of point to polygon border

I want to measure the distance of a point(lat,long) to a the border of a Polygon. So I have created the polygon with the coordinates. from shapely.geometry import Polygon, Point Polygon(zip(lon_list, ...
2
votes
2answers
211 views

Reversing coordinates of MultiPoint using Shapely?

How to reverse the cooridnates order of this MultiPoint: MULTIPOINT (92 169, 100 163.552380952381, 105.2167832167832 160, 266.7552447552447 50, 290 34.17142857142857, 302 26) to this: MULTIPOINT (...
0
votes
1answer
44 views

Writing shapefile of multiple geometry using Python [duplicate]

How to make a shapefile containing points, polygon, and line using python shapely or pyshp?
1
vote
1answer
19 views

Call GEOSVoronoiDiagram from Shapely

GEOSVoronoiDiagram is not published in the Shapely API. However, it is available in the newer GEOS libraries. I'm trying to use it with func = getattr(geos._lgeos, 'GEOSVoronoiDiagram_r') attr = ...
0
votes
2answers
38 views

Getting MemoryError from Fiona when merging large amounts of buffered data (Python)

I am using fiona and shapely together to buffer points and then merge them and write them to a shapefile. For almost all of my datasets, this is working fine. However, I am currently getting a ...
1
vote
0answers
25 views

Obtaining least number of grids (polygons) covering a separate polygon while the grids are overlapping

I have grids as polygons where the grids are overlapping. I want list of grids covering a separate polygon. The image below demonstrate the problem. The red lines are the edges of the grids and the ...
1
vote
0answers
73 views

Making polygon for every point in set using voronois?

I'm trying to make polygons from points, were each point will be represented by one polygon. I tried using voronois, but the results are incomplete. While I more or less understand where this ...
0
votes
1answer
59 views

How to apply the orient function on the geometry of a GeoPandas dataframe

Given a GeoDataFrame where the geometry column contains both Polygons and MultiPolygons. How can I force the orientation (left-hand-rule or right-hand-rule) on these geometries?
0
votes
0answers
75 views

Memory usage (or absolute bytesize) of geometry objects(shapely) in a GeoDataFrame in Python?

I am currently working on analyzing data structure and size of a shapefile. To analyze it, I was wondering how much geometry column consumes the size of a shapefile. Unlike other features, geometry(in ...
0
votes
0answers
34 views

Using Single Polygon for entire dataframe in PySAL?

I'm trying to calculate the queen contiguity weights using pysal's queen_from_shapefile() helper method based on this page Not being a GIS specialist I wanted to check my intuition on this Q&A ...
0
votes
0answers
274 views

Install shapely windows using pip

My question is related to Why is Shapely not installing correctly? However it is not working and I am struggling to find information/understand how to install it. I am running my own environment ...
2
votes
1answer
179 views

How to dissolve overlapping polygons using GeoPandas

Assuming the following: from shapely.affinity import translate from shapely.geometry import Polygon import geopandas p0 = Polygon( [(0,0), (2,0), (2,2), (0,2)] ) p1 = translate(p0, xoff=1) p2 = ...
0
votes
1answer
833 views

OSError: Could not find lib geos_c.dll

After a system re-imaging, I am seeing this error message when trying to run a script involving shapely: OSError: Could not find lib geos_c.dll or load any of its variants ['C:\\Users\\myusername\\...
3
votes
1answer
240 views

Convert contours to polygons maintaining attributes using Python?

I have a series of polylines(contours) that i want to convert to polygons using Python (GeoPandas, Fiona, Shapely). Because these are contours, there will be donut polygons, can anyone point me to how ...