Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
1 answer
115 views

Multilinestrings to Linestring using Python

I have a geodataframe (download link) that contains the geometry of bus lines. It is a Multilinestring. I need to transform the geometry into a single Linestring. My first idea was to use .explode (...
Daniel AG's user avatar
  • 117
2 votes
1 answer
50 views

Extracting linework from a GeoDataFrame

I have raster data where each pixel is assigned a feature id and the features form connected pixel regions. We could think of this as a rasterized map of different countries. raster = np.array([ [...
Christoph's user avatar
  • 143
2 votes
0 answers
86 views

Remove side branches from linestring

I'm trying to create a centerline from a (curved) polygon. To do this I'm using the PostGIS ST_ApproximateMedialAxis tool. However, this creates a lot of side branches, whereas I only want to keep the ...
eve's user avatar
  • 21
2 votes
1 answer
135 views

is this posible to extract coastline or border line from multipolygon geojson but keep them separate

i have multipolygon cities , how to get coastline or border line that not intersect with other cities, and keep separate each cities, is that possible? there any software or programing method (like ...
good112233's user avatar
0 votes
2 answers
302 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
2 votes
1 answer
538 views

Python length of roads inside polygons

I have two datasets: one about each road in a country (and its linestring), and another one about the polygons of each region. I want to estimate the length of each road in the polygon that is ...
MG Fern's user avatar
  • 23
1 vote
0 answers
73 views

Adding overlapping routes when there is no overlapping route using buffer and union

I am trying to do something to do with routes, Let's say I have 3 routes rt1 and rt2 are overlapping routes that share some length but r3 does not overlap with either of them. How would I just add the ...
OwO's user avatar
  • 13
1 vote
0 answers
73 views

Mapping self-intersections of a transformed LineString

I’m using shapely to solve a problem in physic. My problem can be represented in 2D with a LineString. In order to solve my problem I need to : Apply a transformation to the original LineString Find ...
lamilam's user avatar
  • 11
4 votes
1 answer
165 views

Avoid losing overlapping areas when buffering line with Python

LineString is the path of the transport on the field with attached equipment. Is it possible to use GeoPandas or third-party Python libraries to find overlapping areas when buffering a path line to a ...
Roman's user avatar
  • 53
1 vote
1 answer
231 views

Parquet files and PySpark: creating linestring column from node references

I've used osm-parquetizer to convert my pbf files to parquet to parallelise my actions using PySpark and Apache Sedona to query as such. The schemas created by the parquetizer didn't have a geometry/...
Aniketh Reddimi's user avatar
3 votes
1 answer
610 views

Getting the polygons contained in closed MultiLinestring using Python

Given a set of "streets", how can I get the "blocks" contained in those streets? For example, I'd like to extract four blocks / polygons from this 2 x 2 "checkerboard": ...
zadrozny's user avatar
  • 318
0 votes
1 answer
2k views

Shapely Split a LineString based on Intersections with other LineStrings

I'm new to using Shapely, and I have some question. I have a LineString and I wish to split it based on intersections of other LineStrings. If the intersection turns out to be a single point, then we ...
M. Fire's user avatar
  • 31
-1 votes
1 answer
328 views

Can't find LineString or Point for Python

I am trying to use PolyLabel. I did a pip install shapely first. But the from shapely import LineString fails to find LineString. Also, in polylabel there is an from ..geometry import Point which ...
Jay Mosk's user avatar
  • 111
1 vote
2 answers
1k views

How to show points on LineString in QGIS?

I created a shape file with the following schema in python: schema = { "geometry": "LineString", "properties": {"id": "int"}, }...
jlcv's user avatar
  • 345
1 vote
1 answer
129 views

How to split up Linestrings based on type and connectivity using Python? [closed]

I am working with a road network, where I extracted only the three main road types. In the next step, I would like to union all Linestrings based on their road type and connectivity. That means that I ...
Danny's user avatar
  • 35
1 vote
1 answer
535 views

Splitting multiple Linestrings into 1 metre parts with GeoPandas shapely

I have a GeoPandas dataframe which contains many rows and also a column named 'geometry' with the following input: geometry LINESTRING (445125.050522556 5536587.67127983, 445124.450035... I ...
coder338's user avatar
2 votes
2 answers
1k views

Merging LineString with MultiLineString with Python

Is it possible to use shapely or some other Python software to merge a LineString with a MultiLineString? Shapely's ops.linemerge fails here. I am attempting to merge segments of the same road, ...
zadrozny's user avatar
  • 318
3 votes
1 answer
2k views

Converting column with LineString geometries to np.array

I have a GeoDataFrame of a street network with the geometry of each row as a LineString. Say something like: type id tags geometry lanes bridge name highway 0 way 34953479 {'...
arkriger's user avatar
  • 337
0 votes
0 answers
299 views

How to smooth the Linestring after adding additional point?

Actually I am tracking vessel, where I am already having path, and current position. Now the trouble is, obviously the vessel will not be on same coordinates as provided in the path.So I want to ...
Rajan's user avatar
  • 101
2 votes
0 answers
2k views

Shapely intersection between LineString and multiple Polygons

I am trying to get a function to return True when a LineString intersects with any polygon in a list of polygons. Currently, I am using a for loop to iterate through all the polygons and check one by ...
sopafria554's user avatar
5 votes
2 answers
2k views

Exploding LineString into segments using Shapely

I am trying to find explode lines tool in QGIS equivalent in shapely or geopandas (which uses shapely anyway). does anyone know this? note that geopandas.GeoDataFrame.explode() does not work because ...
sutan's user avatar
  • 969
1 vote
1 answer
2k views

Replace MultiPoint, GeometryCollection & LineString geometries in shapefile with Point geometries [closed]

I have a geopandas dataframe that contains shapely MultiPoint, LineString, GeometryCollection and Point geometries. Cannot save the the geopandas because of this neither perform other operations (...
pyaj's user avatar
  • 175
3 votes
1 answer
584 views

Extract river nodes from linestring [closed]

I want to extract the coordinates of river confluences. I have a shapefile of rivers in a watershed. I want to get the coordinates of each point where a river joins another. import geopandas as gpd ...
pyaj's user avatar
  • 175
2 votes
1 answer
922 views

Splitting line on intersection to another line using Shapely

I'm finding a solution for split a LineString on intersection to another LineString. My first solution is: from shapely import wkt from shapely.ops import split first_line = wkt.loads('LINESTRING (28....
MaxDragonheart's user avatar
4 votes
1 answer
3k views

Creating a geodataframe from a list of LineStrings or routes

I have created a separate LineString for each origin-destination couples of subdivisions and I did it manually cause when I use a for loop it creates a dataframe with 1 LineString from all lines... ...
Kareem Alaraby's user avatar
-1 votes
2 answers
5k 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(...
Venkatesh Telu's user avatar
2 votes
2 answers
8k views

Splitting MultiLine or LineString into equal segments of particular length using GeoPandas and shapely

I don't have a license for any software. So, I want to do it in Python. How do I split the multiline or any linestring into equal segments by taking the length as input? This is the code that I am ...
Venkatesh Telu's user avatar
2 votes
1 answer
6k 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: ...
yasser abd's user avatar
3 votes
2 answers
3k 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 ...
Felipe D.'s user avatar
  • 2,749
0 votes
1 answer
883 views

Creating LineString geometry from Point geometries with Python's OSGEO/OGR library

Is it possible to create a LineString object with Python's osgeo/ogr library starting from multiple Point objects? For example, I know from the Python GDAL/OGR Cookbook that I can create a ...
Felipe D.'s user avatar
  • 2,749
0 votes
1 answer
4k views

Something wrong with GeoJSON for LineString

I'm using Python's GeoJSON package to created a simple LineString, put it in a Feature, and put that in a FeatureCollection I'll call featColl. featColl.errors() returns no errors. Below is the dumped ...
Richard Belew's user avatar
4 votes
1 answer
3k 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 ...
Ben's user avatar
  • 203
0 votes
0 answers
1k views

Super-efficient geo-intersection operations in Python

I am working with big spatial data. I have about 2.3 million multilinestrings (driven routes) and I seek to count the number of intersections of each individual multilinestring with a set of ~60-150 ...
Ben's user avatar
  • 203
0 votes
1 answer
483 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. # ...
Joehat's user avatar
  • 285
1 vote
1 answer
1k views

Clipping GeoPandas dataframe containing linestrings with polygon boundaries creates multilinestrings

I have generated GeoPandas dataframes with several LineStrings like the one below id geometry 0 2 LINESTRING (499944.093 7655354.222, 499943.989... 1 ...
Julianno Sambatti's user avatar
1 vote
1 answer
206 views

Delete polygons that have one or more side parts in common [closed]

I am trying to solve a particular case of comparison of polygons to others. I have five polygons distributed as in the figure below. The black polygon is the one with the largest area. There may be ...
Steve's user avatar
  • 19
5 votes
1 answer
576 views

Difference between LINESTRING((x1 x2), (x3 x4), (x5 x6), (x7 x8)) and LineString([(x1,x2), (x3,x4), (x5,x6), (x7,x8)])

I am a little confused about how objects are being defined and represented and mostly because some of the solutions I find for solving issues I have demand that the input data be in an other form than ...
Serge de Gosson de Varennes's user avatar
2 votes
0 answers
667 views

Create MultiLineStrings segments between points with Python Shapely

I have a layer of LineString and MultiLineString geometries. I'm trying to create a single geometry of the LineStrings split by certain snapped points. This is an illustration of the current data that ...
user8675309's user avatar
0 votes
0 answers
390 views

Extrapolating arc via Python function

I am looking for a Python code/function that can extend an arc linestring up to a pre-defined length while maintaining the same arc of the original line. The idea is to repeat the configuration of the ...
Julianno Sambatti's user avatar
1 vote
3 answers
2k views

Python Create Dictionary with Shapely Points from Linestring coordinates

I have a Geodataframe with Linestring Z geometries as follows: id_line geometry 1 LINESTRING Z (0 0 0, 5 6 9, 1 2 3, ...) 2 LINESTRING Z (7 8 9, 9 8 7, 1 2 5, ...) each of the Linestring is made ...
MigueL's user avatar
  • 113
3 votes
1 answer
1k views

Shapely strange splits when splitting LineString and Polygon

I noticed a strange behavior while splitting a LineString with e Polygon: in the below image I have a Polygon (in green) and two lines. If I split the blue Linestring with the polygon the result of ...
Domenico V.'s user avatar
2 votes
0 answers
673 views

How to merge lines from shapefile using PyShp and Shapely and save them in a new shapefile?

I have files with line segments that cover road network of towns. The issue is that each street with specific name consists of smaller segments that I need to merge into one line covering the whole ...
krltos's user avatar
  • 223
2 votes
0 answers
482 views

Calculating length along multiple line segments in GeoPandas [closed]

I would like to calculate the distance between two points. They are connected with multiple line segments. Each LineString only consisting out of two points. How do I connect these LineString segments ...
tartearth's user avatar
3 votes
1 answer
670 views

Can't Form DataFrame from Parallel Offset Output

I've been developing code to take a .csv with lat-long coords and convert them to LineStrings before creating parallel offsets for them. This has been working so far, but yesterday after clearing my ...
vbray6's user avatar
  • 31
2 votes
2 answers
1k views

Shapely command error: from shapely.geometry import LineString

I am trying to run a program but getting the following error when I am using the command: from shapely.geometry import LineString Error: FileNotFoundError: Could not find module 'C:\Users\SWWB\...
Aizaz's user avatar
  • 21
7 votes
1 answer
1k views

Change linestring values with GeoPandas

I'm working on a stormtracking project, and I realized that the longitude sign of some values in my GeoPandas dataframe are wrong; i.e. I need negative longitudes instead of positive ones. When I ...
Guimeteo's user avatar
0 votes
1 answer
6k views

Calculating distance between two Linestring using Python

I have two linestring, each linestring represents a rail road. I am trying to calculate minimum distance between these two linestrings. Which function is efficient to do this? I have only come across ...
Suchithra's user avatar
2 votes
1 answer
445 views

How to add intersection vertices to a ShapelyLinestring?

Assume that I have two shapely LineStrings. I want to find their intersection and then add the intersection point as vertices into the respective LineStrings. from shapely.geometry import LineString #...
J.Galt's user avatar
  • 129
2 votes
1 answer
2k views

Density per grid cell

I have a shapefile with the following format. These are storm tracks and each unique "Serial" represents one storm track. import matplotlib.pyplot as plt import geopandas as gpd input = &...
kiyas's user avatar
  • 21
2 votes
1 answer
6k views

Pandas dataframe to Shapely LineString using GroupBy & SortBy

I have a pandas dataframe that contains information to construct (poly)lines, and I want to use shapely & geopandas tools to make a SHP. In the example below, I have 3 lines differentiated by &...
a11's user avatar
  • 950