psycopg2.InternalError: parse error - invalid geometry
psycopg2.InternalError: parse error - invalid geometry
x = float(stand[1].split(' ')[0])
y = float(stand[1].split(' ')[1])
coordinate = ppygis.Point(x, y)
coordinate.srid = SRID_WGS84
# Stand delimiters
delimiter = []
line = []
for i in range(2, len(stand)):
# The cycle will run through everythin in the stand list
# But it will only actually do something when it finds a coordinate
# counter
if (len(stand[i].split(' ')) == 1):
# Number of coordinates to process. Adjusted for indexation
ncoords = int(stand[i]) + 1
for c in range(i + 1, i + ncoords, 1):
x = float(stand[c].split(' ')[0])
y = float(stand[c].split(' ')[1])
point = ppygis.Point(x, y)
point.srid = SRID_WGS84
line.append(point)
line = ppygis.LineString((line))
delimiter.append(line)
line = []
delimiter = ppygis.MultiLineString((delimiter))
cur.execute("""
INSERT INTO taxi_stands(id, name, coordinates, delimiter_geom)
VALUES(%s, %s, ST_PointFromText(%s), %s);
""", (taxi_stands_list.index(stand), stand_name, coordinate,
delimiter))
我们正在尝试使用 Python 将 MultiLineString 插入到 PostgreSQL 数据库中。我们正在使用 ppygis
将我们的坐标转换为实际几何图形。支架是要插入的坐标。列表格式如下:
[nº of points in line, x1line1, y1line1, ..., nº of points in line, ...]
插入数据库时出现此错误:
psycopg2.InternalError: parse error - invalid geometry
HINT: "0101000020e6100000645d" <-- parse error at position 22 within geometry
CONTEXT: SQL function "st_pointfromtext" statement 1
如果我们将 ST_PointFromText 更改为 ST_GeomFromText,则错误为:
psycopg2.InternalError: parse error - invalid geometry
HINT: "0101000020e6100000645d" <-- parse error at position 22 within geometry
ppygis python 模块也严重缺乏文档,我们不知道是哪个错误。
有什么帮助吗?谢谢。
不要使用 St_PointFromText() because your geometries are already in WKB format (ST_PointFromText requires geometries in WKT 格式)。
只需将您的陈述更改为:
cur.execute("""
INSERT INTO taxi_stands(id, name, coordinates, delimiter_geom)
VALUES(%s, %s, %s, %s);
""", (taxi_stands_list.index(stand), stand_name, coordinate,
delimiter))
x = float(stand[1].split(' ')[0])
y = float(stand[1].split(' ')[1])
coordinate = ppygis.Point(x, y)
coordinate.srid = SRID_WGS84
# Stand delimiters
delimiter = []
line = []
for i in range(2, len(stand)):
# The cycle will run through everythin in the stand list
# But it will only actually do something when it finds a coordinate
# counter
if (len(stand[i].split(' ')) == 1):
# Number of coordinates to process. Adjusted for indexation
ncoords = int(stand[i]) + 1
for c in range(i + 1, i + ncoords, 1):
x = float(stand[c].split(' ')[0])
y = float(stand[c].split(' ')[1])
point = ppygis.Point(x, y)
point.srid = SRID_WGS84
line.append(point)
line = ppygis.LineString((line))
delimiter.append(line)
line = []
delimiter = ppygis.MultiLineString((delimiter))
cur.execute("""
INSERT INTO taxi_stands(id, name, coordinates, delimiter_geom)
VALUES(%s, %s, ST_PointFromText(%s), %s);
""", (taxi_stands_list.index(stand), stand_name, coordinate,
delimiter))
我们正在尝试使用 Python 将 MultiLineString 插入到 PostgreSQL 数据库中。我们正在使用 ppygis
将我们的坐标转换为实际几何图形。支架是要插入的坐标。列表格式如下:
[nº of points in line, x1line1, y1line1, ..., nº of points in line, ...]
插入数据库时出现此错误:
psycopg2.InternalError: parse error - invalid geometry
HINT: "0101000020e6100000645d" <-- parse error at position 22 within geometry
CONTEXT: SQL function "st_pointfromtext" statement 1
如果我们将 ST_PointFromText 更改为 ST_GeomFromText,则错误为:
psycopg2.InternalError: parse error - invalid geometry
HINT: "0101000020e6100000645d" <-- parse error at position 22 within geometry
ppygis python 模块也严重缺乏文档,我们不知道是哪个错误。
有什么帮助吗?谢谢。
不要使用 St_PointFromText() because your geometries are already in WKB format (ST_PointFromText requires geometries in WKT 格式)。
只需将您的陈述更改为:
cur.execute("""
INSERT INTO taxi_stands(id, name, coordinates, delimiter_geom)
VALUES(%s, %s, %s, %s);
""", (taxi_stands_list.index(stand), stand_name, coordinate,
delimiter))