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
1
vote
1answer
28 views

How to convert from OGR geometries (with M-values) to shapely geometries (without M-values)?

Main question Suppose I have a few OGR geometries, all of them containing M-values. Is there a generic solution that allows me to translate them to Shapely geometries without M-values? Shapely and M-...
2
votes
1answer
34 views

Convert area between LineStrings to Polygon in shapely

I need to create a Polygon from the area enclosed by four LineStrings with real world data in shapely. In this example, I want to polygonize the area between b1, b2, t1 and t2. import shapely.wkt b1 = ...
1
vote
0answers
23 views

Reprojecting WGS84 to Winkel-Tripel with new prime meridian breaks polygons

I've been trying to re-project a rather large shapefile of the ocean's polygons (found here) to a Winkel-Tripel using a prime meridian of -96 (US) rather than the standard 0. However, I'm noticing ...
1
vote
2answers
102 views

Shapely deprecation warning message when plotting GeoPandas geodataframe

I am trying to plot a GeoPandas geodataframe as I always do. Now I am having a new pc when I try to plot my geodataframe using : gdf.plot() there is no plot displayed and I receive this message: C:\...
0
votes
0answers
57 views

Converting LINESTRING wkt representation LINESTRING((a b),(c d)) to LineString[(a,b),(c,d)]

I know how to go from line = LineString([(0, 0), (1, 1), (2, 2)]) to LINESTRING ((0 0), (1 1), (2 2)) But not the other way around. How do I do this? The reason I need to do this is that I want to ...
1
vote
0answers
24 views

Splitting LINESTRING at given POINT using split function from shapely

I have a geopandas dataframe that looks likes this: level_0 id \ 0 0 028f342a-b26f-4e36-b5d1-25d3428cac2f 1 1 028f342a-b26f-4e36-b5d1-...
1
vote
0answers
37 views

Buffer not working in GeoPandas

This seems pretty simple but I can't seem to create a buffer around a GeoDataFrame. I'm making this buffer so that it will be the extent of the axes instead of the original layer. This is to make the ...
1
vote
0answers
22 views

Trimming polygon based on its intersection with another polygon using shapely [closed]

I have two polygons intersecting with one another (x1 and x2). How can i trim x2 by the area it intersects with x1, such that x1 and x2 no longer overlap and x1 area/shape remains constant. from ...
0
votes
2answers
11 views

Removing branches from a multilinestring vector and retain the main centerline

I have a vector file that contains a centerline and multiple branches. I wish to remove these branches.I am unable to come up with a logic to remove these branches. Kindly guide.
1
vote
0answers
36 views

Finding distance from point to closest LineString given multiple LineStrings efficiently using Python

I have a dataset with many Points and I also have a GeoJSON file consisting of road networks using LineStrings. I want to estimate traffic by seeing which roads have the largest points on or beside ...
1
vote
1answer
125 views

Rasterio mask doesn't work with shapely polygon

I have raster which I want to mask with shapely polygon.According the rasterio documentation, rasterio.mask can work with shapely geometry.However, in this case, it doesn't work. whenever I use my ...
5
votes
3answers
289 views

Converting polygon to list of coordinates with shapely

I received a code, that expects a list of coordinates such as this as input area_polygon = [{'lat': 46.037286, 'lng': 14.471329}, {'lat': 46.036733, 'lng': 14.467378}, {...
0
votes
0answers
16 views

How to generate shapely.geomtery.polygon from GTFS feed

I want to generate a graph using osmnx.graph.graph_from_polygon method. It requires a shapely.geometry.polygon as an input. Using GTFS Feed, is it possible to generate the polygon. I am aware, it can ...
0
votes
1answer
51 views

How to extract the boundaries of Shapely MultiPoint? [closed]

I have a shapely MultiPoint object but need to extract the boundaries into a Polygon object. I'm currently using the convex_hull of the MultiPoint object but my MultiPoint sets can have sharp inward ...
0
votes
0answers
50 views

How to perfectly snap the boundaries of contiguous polygons?

I want to perfectly snap the boundaries of contiguous polygons using Python and QGIS. However, I don't want the polygons to merge into a single polygon. I have tried to snap the polygons using shapely ...
0
votes
0answers
26 views

Iterating over two very large dataframes: finding the closest LineString (1/150k) to a Point (1/1.2m)

I have a dataset of calls (1.2m rows), each with a 'Point' geometry. Likewise I have a street dataset (150k rows), each with a LineString geometry. My goal is to identify, for each call, the closest ...
-1
votes
2answers
50 views

Finding distance from Point to LineString in meters using Python [closed]

I have tried this following method to find distance but it is giving me distance like 0.12. I don't know what that 0.12 is meant and I want the distance to be in meters or kilometers. line.distance(...
1
vote
1answer
137 views

ImportError when importing Linestring from shapely.geometry [closed]

With this code I tried to import shapely.geometry: import shapely as shp import geopandas as gpd from shapely.geometry import Polygon, Linestring However, I faced the following error: ImportError: ...
1
vote
2answers
186 views

How do you flip/invert/reverse the order of the coordinates of shapely geometries?

Is there a generic way to flip/invert/reverse the order of the coordinates of a shapely geometry? Here are a couple of examples of what I mean. Example 1 Input: LINESTRING (0 0, 1 1, 3 1, -3 3) Output:...
1
vote
0answers
41 views

Split LineString with MultiPoint - Shapely

I want to split a LineString object at a MultiPoint object. I use the following code to do this. Among other things, I use the functions interpolate() and project() to snap the points onto the line ...
1
vote
1answer
85 views

Is there a way to "sort" points in a MultiLineString such that they seem more like a continuous LineString?

Is there a way to "sort" the points of a MultiLineString such that they follow a more sequential order? Let me illustrate what I mean with a graphical example: Input Suppose I have the ...
1
vote
1answer
39 views

How to read shapely file in specific coordinate format or change coordinate format packed DMS with decimal to DMS format

I am using GeoPandas to read a shapefile using read_file() function. However, my polygons are in the following format: (longitude: latitude) = (3229083.936279297 13792922.909729). Also, whenever I ...
4
votes
2answers
215 views

Filtering by geometry type in GeoPandas

I have a GeoPandas GeoDataFrame with a geometry column that contains both POLYGONs and MULTIPOLYGONs. How do I filter only MULTIPOLYGONs? I used this approach, but I am sure there might be better ones:...
1
vote
1answer
67 views

Geopandas: How to associate a Point to a Linestring using the original Linestring order

Using Geopandas, Shapely Suppose I have a Linestring that represents a (cornered) street: LineString([(1, 1), (2, 2), (3, 1)] Note that the order of points in this linestring matters because ...
2
votes
2answers
77 views

Turn a MultiPolygon with Nested Shells into a Polygon with Holes

I am reading GeoJSON into shapely objects and need help, I have a massive MultiPolygon with several nested Polygons in it. I believe this is why it is not considered a valid shape? as_shape.is_valid -&...
0
votes
0answers
64 views

Generate outline polygon of a point respectively raster data set

background: I have given multiple large text files representing points and elevation (X,Y,Z). At a larger step I will combine into one large mosaiced DEM. goal: To indicate each datasets point extent ...
0
votes
1answer
33 views

Error when creating geodataframe from lists [geographic coordinates and GRIB CRS]

I'm working with meteorological data and I want to insert the grid points and also their polygon in a GeoDataFrame. They are generated by ERA5 and in a GRIB format. When I try to create the ...
1
vote
1answer
113 views

How to import PostGIS into BigQuery GIS?

I have to import PostGIS data into BigQuery GIS. In order to do this, I dumped the PostGIS data in CSV and import it into BigQuery. This is working for all the columns but not the geometric one. If I ...
6
votes
1answer
106 views

How is polygon intersection implemented in JTS/Shapely?

I am using Shapely, which from the questions How is intersection implemented in Shapely? What is the algorithm that Shapely used to check if two polygons intersect? uses the JTS as a backend. ...
2
votes
1answer
44 views

Get centroid of a polygon and transform pixel coords with X,Y coords [closed]

Is there a way to get the coordinates of the centroid of a polygon and transform them into latitude and longitude? I am using Shapely to convert contours into polygons from Google Satellite images. I ...
0
votes
1answer
54 views

How to separate in two lists the coordinates of a 2D list

I have created a program that calculates the intersection of two regions on the surface of the Earth based on 2D coordinates given by the user. It asks if the user wants to add more coordinates and ...
2
votes
1answer
117 views

Get the outer shape of a MultiLineString

i have a bunch of shapely MultiLineStrings, which I would like to "convert" to Polygons so that the "outer" boundaries of the MultiLineStrings serve as edges. One of my ...
0
votes
0answers
38 views

Buffer result differ with Shapely and QGIS

I am creating buffers using both Geopandas/Shapely (0.8.1/1.7.1) and QGIS (3.10.10). I see slight differences in the results with both software. I have a projection EPSG: 25832 in both software. I am ...
6
votes
1answer
312 views

Removing small holes from the polygon

I am writing a post-processing flow on Python. I am trying to come up with an algorithm to remove the small holes from the polygon. I am using osgeo OGR right now, but I'm ok to do this part with ...
1
vote
0answers
34 views

Split Raster into Tiles - Set Extent

I am using this questions solution to split a raster I have into 1500x1500 tiles. The code works. I have recently been trying to figure out how to set the starting and ending points of the raster ...
1
vote
0answers
72 views

Efficient way to remove overlapping sections of polygons in Python

I have "tiers" of polygons that might overlap. Each tier could contain any number of polygons. If a polygon from tier 1 overlaps with one from tier 2, I would like to remove the overlapping ...
1
vote
1answer
142 views

Converting GPS track to MultiLineString using GeoPandas and shapely [closed]

I have many GPS tracks (long, lat, alt, timestamp) from heavy trucks. Trucks are go on some paths. How can I extract the path from GPS tracks without deviation and convert it to one MultiLineString? ...
0
votes
0answers
29 views

Check polygons inside polygons in a multipolygon shapefile [duplicate]

I have a multiple geometries (polygons) shapefile in which there are many polgons inside polygons. I have to remove these polygons lying inside polygons. I know a way where I can loop through m ...
1
vote
2answers
347 views

How to merge/dissolve multiple polygons into one single polygon?

Problem: I want to merge this Multipolygon into a single Polygon (without the inner lines). And I want the merged Polygon in WKT, not just a visual plot. EDIT: Sorry I wasn't explicit enough. I had ...
1
vote
1answer
29 views

Efficient algorithm to find neighbour geometries that are visible / can be reached with a straight line from the query geometry [closed]

I have a list of lines in shapely. The lines do not intersect, but may have starting/ending points at the same coord. What I want is a function which takes a geometry and the list of lines and tells ...
0
votes
0answers
34 views

parallel_offset changes number of point in LineString(Shapely)

import matplotlib.pyplot as plt import pandas as pd from shapely.geometry import LineString from shapely.geometry.base import JOIN_STYLE path = [ dict(x=0, y=0), dict(x=1, y=0), dict(x=2, ...
1
vote
0answers
589 views

Splitting polygon into equal area polygons using shapely

I would like to split complex geometries into n smallest geometries of the same area in Python. While I can divide simple geometry in the following way: from shapely.geometry import LineString, ...
2
votes
0answers
32 views

Finding the bounds of a single pixel in a raster in Python

I have a satellite image and a group of polygons scattered around the image. The polygons are small and cover a single-pixel most of the time; I'm trying to create a new raster where each pixel value ...
1
vote
1answer
105 views

Dragging a polygon in shapely

If I have a polygon and I translate it in a direction n to a new location, how can I create a new polygon formed by the act of translation? To take a simple example consider the rectangle below with ...
2
votes
0answers
62 views

Polygon simplification without intersection in GeoPandas/Shapely

Is there an in-the-can solution for simplifying a boundary that won't intersect the original poly? Something like .convex_hull but with a fillet option possibly? For example, .simplify() produces ...
0
votes
0answers
65 views

Fiona Saving Gives DriverIOError

I have a script that I used before to clip polygons. I modified it a touch to use in another place, but am running into a fiona.errors.DriverIOError. As far as I can tell, all the code is working ...
0
votes
2answers
1k views

How to convert string type to shapely object

I used to have a Pandas data frame with geometry column (I guess you call it as GeoPandas data frame) where all the instances were multiline string with shapely.geometry data type. When I saved it as ...
0
votes
1answer
47 views

GeoPandas: Error plotting after clipping shapefile

I am interested in plotting data on the city of Göteborg (in English Gothenburg, Sweden). I am starting with shapefiles of Sweden and then clipping them to concentrate my study in Göteborg. # ...
0
votes
0answers
58 views

Multiple 3D polygons to a single 2D MultiPolygon having individual overlapping features or a single 3D MultiPolygonZ

I narrowed a 3D problem to a GeoDataFrame G containing four Shapely polygons, each is a 3D flat triangle. In 3 dimensions, these polygons all share a common summit and also a common edge, 2-by-2. They ...
0
votes
1answer
164 views

Convert distance() in shapely to kilometres

I am using the following code: x = POINT(-1.154321, 55.124412) y = POINT(-1.2354352, 56.2345235) distance = x.distance(y) print(distance) I am unsure what distance measurement is being used, but my ...

1
2 3 4 5
16