如何将linestring转换为地质层中的多个经度纬度列
这是我的一行输入,
Name geometry
Jalan W.R. Supratman LINESTRING (95.317339 5.5603499, 95.3169007 5.5602832, 95.3165735 5.5602391, 95.3161729 5.5602097, 95.3161289 5.5601326, 95.3160873 5.5600178)
这是我的预期输出
Name Langitude Longitude
Jalan W.R. Supratman 95.317339 5.5603499
Jalan W.R. Supratman 95.3169007 5.5602832
Jalan W.R. Supratman 95.3165735 5.5602391
Jalan W.R. Supratman 95.3161729 5.5602097
Jalan W.R. Supratman 95.3161289 5.5601326
Jalan W.R. Supratman 95.3160873 5.5600178
编辑:
这是我尝试
def utm_to_latlon(coords, zone_number, zone_letter):
easting = coords[0]
northing = coords[1]
return utm.to_latlon(easting, northing, zone_number, zone_letter)
# Using nested list comprehension
df ["lat_lon_tuple"] = [[utm_to_latlon(xy, 44, "N") for xy in tuple(geom.coords)] for geom in df.geometry]
错误消息的内容
<ipython-input-5-4dfd2badb8b4> in <listcomp>(.0)
5
6 # Using nested list comprehension
----> 7 df ["lat_lon_tuple"] = [[utm_to_latlon(xy, 44, "N") for xy in tuple(geom.coords)] for geom in df.geometry]
AttributeError: 'str' object has no attribute 'coords'
Here's my one row of input
Name geometry
Jalan W.R. Supratman LINESTRING (95.317339 5.5603499, 95.3169007 5.5602832, 95.3165735 5.5602391, 95.3161729 5.5602097, 95.3161289 5.5601326, 95.3160873 5.5600178)
Here's my expected output
Name Langitude Longitude
Jalan W.R. Supratman 95.317339 5.5603499
Jalan W.R. Supratman 95.3169007 5.5602832
Jalan W.R. Supratman 95.3165735 5.5602391
Jalan W.R. Supratman 95.3161729 5.5602097
Jalan W.R. Supratman 95.3161289 5.5601326
Jalan W.R. Supratman 95.3160873 5.5600178
Edit:
Here's what I try
def utm_to_latlon(coords, zone_number, zone_letter):
easting = coords[0]
northing = coords[1]
return utm.to_latlon(easting, northing, zone_number, zone_letter)
# Using nested list comprehension
df ["lat_lon_tuple"] = [[utm_to_latlon(xy, 44, "N") for xy in tuple(geom.coords)] for geom in df.geometry]
The error message
<ipython-input-5-4dfd2badb8b4> in <listcomp>(.0)
5
6 # Using nested list comprehension
----> 7 df ["lat_lon_tuple"] = [[utm_to_latlon(xy, 44, "N") for xy in tuple(geom.coords)] for geom in df.geometry]
AttributeError: 'str' object has no attribute 'coords'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用索引爆炸
,然后应用系列
:结果:
Explode
with index and then applySeries
:Result:
您可以转换定义使用
coords
属性,然后将其转换为shapely.deometry.multipoint
:完成此操作后,您可以使用
df.explode
::You can convert the coordinates defining the
LineString
with thecoords
attribute, then convert this to ashapely.geometry.MultiPoint
:Once this is done, you can use
df.explode
: