我相信这将是一个非常直接的答案。我是R新手,仍然发现我的数据类型。目前从MySQL导入数据,但我不能完全弄清楚如何分隔WKT点类型内的列。从RK中的WKT点数据中提取和分割纬度长坐标
我正在运行以下语句,其中涉及查询包含在数据库中的shapefile。
mydb = dbConnect(MySQL(), user='root', password='mrwolf',dbname='jtw_schema', host='localhost')
strSQL = "select sa2_main11, astext(shape) as geom from centroids
where (gcc_name11 = 'Greater Sydney')
and (sa4_name11 != 'Central Coast')
and (sa4_name11 not like '%Outer West%')
and (sa4_name11 not like '%Baulkham Hills%')
and (sa4_name11 not like '%Outer South West%')"
dfCord = dbGetQuery(mydb, strSQL)
导致:
sa2_main11 geom
1 116011303 POINT(150.911550090995 -33.7568493603359)
2 116011304 POINT(150.889312296536 -33.7485997378428)
3 116011305 POINT(150.898781823296 -33.7817496751367)
4 116011306 POINT(150.872046414103 -33.7649465663774)
....
我想实现的是
sa2_main11 Lat Long
1 116011303 150.911550090995 -33.7568493603359
2 116011304 150.889312296536 -33.7485997378428
3 116011305 150.898781823296 -33.7817496751367
4 116011306 150.872046414103 -33.7649465663774
....
道歉,如果这是很简单的问题,但搜索了分离WKT数据不能找到任何例子。可以尝试字符串搜索或类似的,但我想可能有一个“R-ISH”的方式来做到这一点。