# 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 the one I manage to generate.

Let say that I wish to divide a LineString into 6 equal segments, then this method work perfectly:

``````from shapely.geometry import LineString, MultiPoint
from shapely.ops import split

line = LineString([(0, 0), (10, 10)])
splitter = MultiPoint([line.interpolate((i/4), normalized=True) for i in range(1, 4)])
split(line, splitter).wkt
``````

which returns:

``````'GEOMETRYCOLLECTION (LINESTRING (0 0, 2.5 2.5), LINESTRING (2.5 2.5, 5 5), LINESTRING (5 5, 7.5 7.5), LINESTRING (7.5 7.5, 10 10))'
``````

With my method (on my data)

``````zone_short_edges['line'] = zone_short_edges.apply(lambda row: LineString([row['fr_point'], row['to_point']]), axis=1) #Create a linestring column
zone_short_edges['midpoint'] = zone_short_edges.apply(lambda row: row['line'].centroid, axis=1) #Find centroid
zone_short_edges = zone_short_edges.set_geometry("line")
zone_short_edges = zone_short_edges.set_geometry("midpoint")
``````

I generate `POINT`s and `LINESTRING`s of this type:

``````         id  vertex_id                    fr_point  \
1  Allé 119          2  POINT (119.79008 28.35047)
3  Allé 119          4  POINT (122.85067 44.85106)

to_point  seg_length  \
1  POINT (122.85067 28.08433)    3.072140
3  POINT (119.92314 44.71798)    2.930553

line  \
1  LINESTRING (119.79008 28.35047, 122.85067 28.0...
3  LINESTRING (122.85067 44.85106, 119.92314 44.7...

midpoint
1  POINT (121.32038 28.21740)
3  POINT (121.38690 44.78452)
``````

that is, `LINESTRING (119.79008 28.35047, 122.85067 28.0454, 122.3434 23.323)`. And I therefore cannot use the linestring splitting method. Also, the result of the method is linestrings in the form I have to begin with.

What is the difference between `LineString([(0, 0), (10, 10)])` and `LINESTRING((0 0), (10 10))`?

To simply answer your question, `LINESTRING((0 0), (10 10))` (string) is the WKT representation of `LineString([(0, 0), (10, 10)])` (geometry) used by shapely (and thus GeoPandas) to print a geometry.

``````from shapely.geometry import LineString

line = LineString([(0, 0), (10, 10)])
line
<shapely.geometry.linestring.LineString object at 0x11e5bd438>
print (line, type(line))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>
wkt = line.wkt
print(wkt,type(wkt))
LINESTRING (0 0, 10 10) <class 'str'>
``````

From a WKT string to a shapely geometry:

``````from shapely.wkt import loads

print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>
``````

With GeoPandas

``````import geopandas as gpd