Skip to main content
added 81 characters in body
Source Link
Taras
  • 34k
  • 4
  • 73
  • 148

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 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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>
from shapely.wkt import loads

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

With GeoPandas

import geopandas as gpd
df = gpd.read_file("lines.shp")
df.geometry.iloc[0]
<shapely.geometry.linestring.LineString object at 0x11e5bd630>
print(df.geometry.iloc[0])
LINESTRING (-0.6551724137931035 -0.05491698595146888, -0.3358876117496808 0.4610472541507024, 0.07279693486590033 0.4763729246487867, 0.3690932311621966 0.3742017879948915, 0.5019157088122606 0.51213282247765)
import geopandas as gpd

df = gpd.read_file("lines.shp")
df.geometry.iloc[0]
<shapely.geometry.linestring.LineString object at 0x11e5bd630>
print(df.geometry.iloc[0])
LINESTRING (-0.6551724137931035 -0.05491698595146888, -0.3358876117496808 0.4610472541507024, 0.07279693486590033 0.4763729246487867, 0.3690932311621966 0.3742017879948915, 0.5019157088122606 0.51213282247765)

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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>

With GeoPandas

import geopandas as gpd
df = gpd.read_file("lines.shp")
df.geometry.iloc[0]
<shapely.geometry.linestring.LineString object at 0x11e5bd630>
print(df.geometry.iloc[0])
LINESTRING (-0.6551724137931035 -0.05491698595146888, -0.3358876117496808 0.4610472541507024, 0.07279693486590033 0.4763729246487867, 0.3690932311621966 0.3742017879948915, 0.5019157088122606 0.51213282247765)

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

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

With GeoPandas

import geopandas as gpd

df = gpd.read_file("lines.shp")
df.geometry.iloc[0]
<shapely.geometry.linestring.LineString object at 0x11e5bd630>
print(df.geometry.iloc[0])
LINESTRING (-0.6551724137931035 -0.05491698595146888, -0.3358876117496808 0.4610472541507024, 0.07279693486590033 0.4763729246487867, 0.3690932311621966 0.3742017879948915, 0.5019157088122606 0.51213282247765)
added 390 characters in body
Source Link
gene
  • 55.4k
  • 3
  • 113
  • 191

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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>
 
line1

With GeoPandas

import ==geopandas line2as (2gpd
df shapely= geometriesgpd.read_file("lines.shp")
Truedf.geometry.iloc[0]
line1<shapely.geometry.linestring.LineString ==object wktat 0x11e5bd630>
print(1df.geometry.iloc[0])
LINESTRING shapely(-0.6551724137931035 geometry-0.05491698595146888, and-0.3358876117496808 10.4610472541507024, string0.07279693486590033 0.4763729246487867, 0.3690932311621966 0.3742017879948915, 0.5019157088122606 0.51213282247765)
False

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)])
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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>
 
line1 == line2 (2 shapely geometries)
True
line1 == wkt (1 shapely geometry and 1 string)
False

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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>

With GeoPandas

import geopandas as gpd
df = gpd.read_file("lines.shp")
df.geometry.iloc[0]
<shapely.geometry.linestring.LineString object at 0x11e5bd630>
print(df.geometry.iloc[0])
LINESTRING (-0.6551724137931035 -0.05491698595146888, -0.3358876117496808 0.4610472541507024, 0.07279693486590033 0.4763729246487867, 0.3690932311621966 0.3742017879948915, 0.5019157088122606 0.51213282247765)
added 27 characters in body
Source Link
gene
  • 55.4k
  • 3
  • 113
  • 191

To simply answer your question, LINESTRING((0 0), (10 10)) (string) is simply 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)])
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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>

line1 == line2 (2 shapely geometries)
True
line1 == wkt (1 shapely geometry and 1 string)
False

LINESTRING((0 0), (10 10)) (string) is simply 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)])
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 WKT string to shapely geometry:

from shapely.wkt import loads
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>

line1 == line2 (2 shapely geometries)
True
line1 == wkt (1 shapely geometry and 1 string)
False

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)])
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
line2 = loads(wkt)
print(line2, type(line2))
LINESTRING (0 0, 10 10) <class 'shapely.geometry.linestring.LineString'>

line1 == line2 (2 shapely geometries)
True
line1 == wkt (1 shapely geometry and 1 string)
False
Source Link
gene
  • 55.4k
  • 3
  • 113
  • 191
Loading