Skip to main content

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
1 answer
22 views

Generalize/Denoise Multipolygons

I am looking for any Python function, that is able to denoise the area to become more spatially homogenous. In other words, I would like to vanish all small polygons beyond some tolerance. Maybe ...
Luckasino's user avatar
  • 293
2 votes
2 answers
57 views

Buffer without overlaps in Python

I have a set of points with respective lat/long coordinates and each point has a given value associated with it (basically a field measurement). I would like to draw buffers of a given radius around ...
André Lourenço's user avatar
2 votes
1 answer
57 views

AttributeError: 'GeoSeries' object has no attribute 'is_valid_reason' in GeoPandas

I was going over the documentation for checking on valid geometries. When I wanted to try the example for is_valid_reason, got this error: import geopandas as gpd from shapely.geometry import Polygon ...
saQuist's user avatar
  • 826
2 votes
1 answer
109 views

Detecting actual CRS when coordinate in WGS84 is known

My geodataframe includes some points of unknown coordinate reference system, each point has address as well, so I am able to find coordinates for them in WGS84. An example point is: POINT (472593....
szaki's user avatar
  • 21
0 votes
1 answer
35 views

Finding which element of shapely geometry satisfies a predicate

I'm looking for an element of a geometry, which satisfies a predicate, e.g. intersection. Here is a code snippet: from shapely import * p0 = Polygon([(0, 0), (0, 4), (4, 4), (4, 0), (0, 0)]) p1 = ...
Paul Jurczak's user avatar
0 votes
0 answers
43 views

Getting aspect-ratio of shapely rectangle

This snippet calculates an aspect ratio of a rectangle not constrained to be parallel to the coordinate axes: from shapely import * rect = oriented_envelope(LineString([(1, 1), (5, 1), (10, 10)])) p0 ...
Paul Jurczak's user avatar
0 votes
2 answers
116 views

Algorithm for point to polygon distance calculations in shapely

I want to calculate the distance from a point to a polygon. If I run point.distance(polygon) Will it: Search the points that compose the exterior boundary of the polygon, select the closest point ...
Sophie Kolston's user avatar
0 votes
2 answers
75 views

Identify outer wall of the floorplan or building [closed]

For the floor plan of the building with 2 rooms (it can have more as well) Is there Python or Java library which I can use to identify outer-wall (facade) of the building as polygon (a closed shape ...
Arpit's user avatar
  • 111
0 votes
0 answers
42 views

Read binary bytes object from Shapely to_wkb into QGIS

I've a typical case of data exported using shapely to_wkb with hex=False option. screenshot of data as shown in WKBgeom below (without SRID here). I am trying to load the data into QGIS via a virtual ...
karunakar's user avatar
1 vote
2 answers
92 views

Merge partially overlapping line geometries into a single line feature with QGIS, pyqgis, geopandas, shapely

I have a geopackage file with multiline features. The features are extractions from the same line geometries. Some of those extracted lines do overlap, so they partially share the same geometry. Some ...
i.i.k.'s user avatar
  • 1,753
0 votes
1 answer
43 views

shapely.nearest_points wrong result: floating point error?

I am loading a .shp file through GeoPandas that consists of several LineStrings that should be united, but they are not. So I would like to unite them. I am using shapely.nearest_points and creating a ...
Pablo's user avatar
  • 1
0 votes
1 answer
56 views

Finding nearest points on MultiLinestring to specific points

I have a simple MultiLinestring and example points as follows: from shapely.geometry import Point, MultiLineString my_route = MultiLineString([ [(24.142982, 54.329322), (24.142753, 54.328542)], ...
szaki's user avatar
  • 21
0 votes
0 answers
32 views

LineString length obtained from shapely differs from actual real distance [duplicate]

I want to obtain the points of a LineString that are at a distance of 25m from the first point and from the last one of said LineString. I was doing some tests to check whether or not Shapely could be ...
Jon's user avatar
  • 11
1 vote
2 answers
85 views

Intersecting a circle and a geodataframe

I have created a circle which I am trying to intersect with a geodataframe as follows: circle_gdf=gpd.GeoDataFrame(geometry= [circle]) joinCircle = gpd.sjoin(left_df=circle_gdf, right_df=transactions,...
bravopapa's user avatar
  • 485
0 votes
2 answers
162 views

Shapely intersection cuts LineString into MultiLineString instead of LineString

I ran into a problem where shapely.intersection cuts a LineString into a MultiLinestring with lots of short lines instead of a simple LineString. The intersection is made between a circle (Polygon) ...
Andreas's user avatar
  • 83
3 votes
2 answers
122 views

Interpolate intermediate sections

I have a geodataframe with lines. I would like to create intermediate lines between two consecutive lines at a maximum distance of 1 meter For example in the image, I have the red lines and I would ...
Eduardo 's user avatar
3 votes
2 answers
376 views

Rotate a polygon bounding box

I would like to rotate a bounding box given a particular angle. Here is what i get : In this example the rotated bounding box does not contain the AOI blue polygon which is an issue for me. The green ...
Magic Mushroom's user avatar
1 vote
0 answers
65 views

Shapely: self intersecting buffer area [closed]

In shapely I want to draw a movement profile of a person. While the person moves through the area, it "discovers" its environment step by step. I use a buffer to model this in shapely. So ...
Jim Panse's user avatar
  • 203
3 votes
1 answer
117 views

Checking that lines lay on polygon boundaries using PyQGIS

I have a polygon layer with one polygon and a line layer with a lot of lines. I need to check lines lie on the polygon boundaries or not and if they are add them into a graph. I couldn't think of ...
grassu's user avatar
  • 53
1 vote
1 answer
763 views

Is there a way to slice a polygon using shapely?

I have a geodataframe as follows: Here is the layer: # adjust the CRS gdf= gdf.to_crs({'init': 'epsg:26191'}) # compute the area in km2 gdf["area_km2"] = gdf['geometry'].area/ 10**6 I ...
bravopapa's user avatar
  • 485
4 votes
1 answer
598 views

Labelling a Map

I have a map I have made using python, matplotlib, cartopy and shapely. It has a coast, county borders, lakes and rivers. I also shade in districts, in the form of polygons, on the map in order to ...
Baz's user avatar
  • 77
1 vote
1 answer
39 views

Displaying name of point with shapely [closed]

I want to display the names of points on my polygon with shapely. Polygon([(0, 0), (0, 2), (2, 2), (2, 0), (0, 0)]) and Names = [A, B, C, D, A] How can I do it simply?
PAKAM's user avatar
  • 11
4 votes
1 answer
289 views

Shapely "TypeError: 'LineString' object is not iterable" when creating polygon with interior ring that touches the exterior ring

I am using shapely Python package in order to create polygon from several connected lines. My code worked with a simple polygon, but failed when the polygon to be created had interior ring that ...
ABC's user avatar
  • 351
0 votes
1 answer
65 views

unary_union() resulting in unexpected internal edges

I'm joining several together several geographic areas from a geojson file and am being left with unexpected internal edges. import geopandas as gpd from shapely.ops import unary_union utlas = gpd....
philipnye's user avatar
  • 123
0 votes
0 answers
80 views

Find the closest distance between points following a set of LineStrings

I have two datasets of Point coordinates (representing electrical installations) and would like to find the closest match between the two datasets following a given set of LineStrings (representing ...
pieterbons's user avatar
1 vote
1 answer
87 views

Splitting a MultiLineString with Shapely Split preserving the original MultiLineString composition

I have a gdf with Streets. I want to split a street with other streets (left side: Split the brown line at intersection with the green line): Whenever i split it (using shapely split()) I recieve all ...
luidwig's user avatar
  • 61
0 votes
0 answers
31 views

Vectorised distance function for non-continuous lines

I have a function that works out the distance for two countries' shared border, it works fine for any border that is continuous, but (I think) it also adds up empty space between the end of one line ...
George.M's user avatar
1 vote
0 answers
45 views

Implementing undershoot correction in GeoPandas

I am trying to implement an undershoot fixer using GeoPandas and Shapely like the solution from Snapping in Geopandas My other thought is that it might reasonable to identify and extend the undershot ...
Derek_P's user avatar
  • 343
0 votes
0 answers
97 views

MySQL WKB geometry corrupted after QGIS manipulation - Unknown WKB type 535

I have a quite complex issue. I have been using MySQL (MariaDB to be specific) for storing shapely geometries. All went well until the customer wanted to slightly change the position of one point. ...
Tadeas D's user avatar
0 votes
0 answers
121 views

Check for ESRI geometry validity using shapely or similar

I have a geopandas dataframe in Python. Is there a way to check geometry validity under the ESRI scheme as opposed to the OGC spec using shapely/geopandas/some hacky way, or am I constrained to using ...
jesnes's user avatar
  • 453
1 vote
1 answer
269 views

Difference between "ESRI" and "OGC" validity

When I use the Check Geometry tool in ArcGIS Pro, it asks whether I want to validate using ESRI or OGC methods. What is the difference between these two methods? edit I originally asked a second ...
jesnes's user avatar
  • 453
1 vote
1 answer
619 views

Validate GeoJSON geometries using geojson Python package via Fiona

I have an application that allows users to submit a shapefile or GeoJSON file. I would like to use Python to validate the files and geometries within them to make sure I process valid geoms. Im having ...
glw's user avatar
  • 187
0 votes
2 answers
211 views

Determining minx/miny/maxx/maxy for shape from polygon in GeoJSON file

I have implemented the following code to search a GeoJSON file for a point (not asking for a code review or critique): #!/usr/local/bin/python3.11 import os import sys import fiona import shapely def ...
Joel Breazeale's user avatar
1 vote
1 answer
242 views

Finding intersection of two geospatial vector data in shapefile format using Python and GeoPandas

I have two geospatial shapefiles. 1. The first one is a contour shapefile, generated via following code rasterDs = gdal.Open('raster.tif') rasterBand = rasterDs.GetRasterBand(1) contourPath="...
Navneet Srivastava's user avatar
0 votes
0 answers
101 views

Dissolve lines that intersect after attending some dataframe (atributte table) conditions

I need to dissolve all Linestrings from a geodataframe that intersects each other after attending some tabular conditions: 1)have the same ID and 2) have the same opening year. I am working with ...
Marlon's user avatar
  • 21
2 votes
2 answers
51 views

Find the length of linestring shared between polygons

I would like to find the common area between my polygons, in this example my polygons touch and share a line df = GeoDataFrame.from_file('path') df ...
Ash's user avatar
  • 31
0 votes
1 answer
150 views

How to visualize a list of coordinates in [x.y] format?

I have a JSON file with coordinates representing roads stored in a list of lists. The coordinates are stored as [longitude, latitude] in a key called path. Example: [[14.322689, 51.178513], [14....
lummers's user avatar
  • 139
1 vote
2 answers
195 views

Interpolated Point on Line is not actually on Line?

I am trying to debug a problem and am not sure if it is my code or if there's a bug with shapely. I have two geodataframes: one with points and one with lines. For each point in the points ...
bj3t's user avatar
  • 65
1 vote
1 answer
139 views

Incorrect geometry check from OGR and shapely

I have multipolygon and trying to check for validity. Both OGR(.IsValid()) and shapely (is_valid) return True. But if I open the same geometry with QGIS and check with theCheck Geometries plugin it ...
Miko's user avatar
  • 39
-1 votes
1 answer
249 views

Splitting polygon between its neighbor polygons with Voronoi algorithm using Python [closed]

I would like to split the area of my concerned polygon (the blue one in the middle) between his neighbors polygons and affect each splitted area to a neighbor My data looks like: affectid t geometry ...
Ash's user avatar
  • 31
-1 votes
1 answer
149 views

Matching correctly two same polygons that come from different shapefiles [closed]

I am trying to match two polygons that come from two different shapefiles, The one with the border (black line, MULTILINESTRING) and the one with blue color (multiple polygons) in the picture. This ...
Ash's user avatar
  • 31
0 votes
1 answer
206 views

Generate lines from given azimuth and points in GeoPandas

I am reading a points shapefile containing the azimuth information in the attribute table, and I want to generate lines from these data. I have tried to use shapely.Point as a tool, however it can't ...
台師大洪偉豪's user avatar
1 vote
1 answer
307 views

Create Polygon out of minX, minY, maxX, maxY

I have a pandas dataframe with the min and max values from two polygons. How can I create two geometries (Polygons) out of these values using Geopandas or Shapely?
Daniel AG's user avatar
0 votes
1 answer
283 views

Two shapely methods to test if a point is within a polygon are failing [closed]

I am iterating through the polygons in a Fiona collection and am not finding my point is within any of the polygons. I am using the shapefile from here. Can you see the problem? [How can I ...
Joel Breazeale's user avatar
2 votes
2 answers
3k views

Change GeoPandas geometry from GeometryCollection to MultiPolygon

I have a GeoPandas dataframe where the features have a Geometry type of 'GeometryCollection'. It looks like each feature is in fact just a simple polygon, so I'd like to convert the GeometryCollection ...
Cowcross's user avatar
  • 115
0 votes
0 answers
243 views

Exporting polygons from GeoPandas to GeoJSON - end point is not the starting point

I'm quite new to working with GeoPandas, and I try to export the file to GeoJSON, to later display it on a map using Google Maps Platform. While GeoPandas Polygons do not have to end in the same point ...
Omer Tzuk's user avatar
2 votes
1 answer
204 views

Fast quasi-recursive polygon intersection algorithm?

I'm trying to make a map which is colored based on the distance to a target point. I've done this by creating a series of concentric rings. These rings are created by buffering out from the target ...
Arijit Sen's user avatar
1 vote
0 answers
273 views

Install shapely from source using regular installs

I am trying to install shapely (2.0) from source with custom GEOS library. And I need to build from a local directory cloned from git. One aspect in the instructions that really confuses me is the use ...
tinlyx's user avatar
  • 11.1k
1 vote
1 answer
142 views

Does geopandas handle shapefiles (in lat/lon) that straddle the anti-meridian properly?

I have been looking for a way to check if a point lies within a shapefile. i had some code that worked for the most part (using shapely and fiona) but my understanding is that it will exhibit ...
Alan Sanchez's user avatar
0 votes
1 answer
93 views

How to know the origins of the result of shapely's symmetric_difference?

Suppose I have two line geometries: import shapely line1 = shapely.geometry.LineString([(0, 0), (2, 0)]) line2 = shapely.geometry.LineString([(1, 0), (3, 0)]) shapely.symmetric_difference(line1, ...
Felipe D.'s user avatar
  • 2,679

1
2 3 4 5
19