我需要使用SQL Server从Linestring中提取点。我知道我可以用geometry.ToString()看到坐标,但我需要新的点几何。我如何做到这一点?Linestring to Points
7
A
回答
1
我几乎不知道几何数据类型,但documentation说,您使用STNumPoints
获得对象中的点数,然后使用STPointN
检索单个点。
6
这里是如何从一个LineString的提取点一个小例子:
declare @LineString geography,
@loop int
declare @Points table (Point geography)
set @LineString = geography::Parse('LINESTRING(
-22.8317451477051 -43.4041786193848,-22.8308925628662 -43.4045524597168,-22.8314971923828 -43.404727935791,
-22.833927154541 -43.4069404602051,-22.8267574310303 -43.4071388244629)')
set @loop = @LineString.STNumPoints()
while @loop > 0
begin
insert into @Points values(@LineString.STPointN(@loop))
set @loop = @loop -1
end
select Point.Lat as Lat, Point.Long as Long from @Points
不要放弃:在T-SQL空间数据是有点棘手,但它的工程!
12
如果你使用SQL 2005+,我会建议用CTE这样做:
DECLARE @GeometryToConvert GEOMETRY
SET @GeometryToConvert =
GEOMETRY::STGeomFromText('LINESTRING (-71.880713132200128 43.149953199689264, -71.88050339886712 43.149719933022993, -71.880331598867372 43.149278533023676, -71.88013753220099 43.147887799692512, -71.879965998867931 43.147531933026357, -71.879658998868422 43.147003933027179, -71.879539598868575 43.146660333027739, -71.879525332201979 43.145994399695439, -71.87959319886852 43.145452399696296, -71.879660598868384 43.14531113302985, -71.879915932201357 43.145025599696908, -71.879923198868028 43.1449217996971, -71.879885998868076 43.144850733030523, -71.879683932201715 43.144662333030851, -71.879601398868488 43.144565333030982, -71.879316798868956 43.144338333031328, -71.879092332202617 43.144019799698469, -71.8789277322029 43.143902533032019, -71.878747932203169 43.143911533031996, -71.878478132203554 43.14405779969843, -71.878328332203807 43.144066133031743, -71.878148732204068 43.144016599698489, -71.8772655988721 43.143174533033118, -71.876876198872708 43.142725133033821, -71.876801532206173 43.142654933033953, -71.876629398873092 43.142600733034044)', 4269)
;
WITH GeometryPoints(N, Point) AS
(
SELECT 1, @GeometryToConvert.STPointN(1)
UNION ALL
SELECT N + 1, @GeometryToConvert.STPointN(N + 1)
FROM GeometryPoints GP
WHERE N < @GeometryToConvert.STNumPoints()
)
SELECT *, Point.STAsText() FROM GeometryPoints
文本结果
空间结果 - STBuffer(0.0001 )
相关问题
- 1. Docking controls to points
- 2. `Multiple definitions` error points to pthread.h
- 3. Three.js - Points
- 4. Java:float [] [] points
- 5. MySQL LineString与Linestring或Polygon的交集
- 6. Matplotlib/python clickable points
- 7. Android:touch points escaped
- 8. jQuery Validation bullet points
- 9. MapField with Points
- 10. three20 pain points
- 11. Numpy meshgrid points
- 12. ios LINESTRING解析
- 13. 您的SQL语法有错误;靠近'SET` points` =`points` +?'
- 14. 从GDAL中删除点LineString
- 15. GTFS Shape Extraneous Data Points
- 16. 删除step line points
- 17. kineticjs line points array contentes
- 18. CakePHP的“Points”系统
- 19. 无法设计LineString
- 20. 从Goocanvas获取坐标:: Points
- 21. ggplot color by factor levels,some color are very similar,unable to identify points for some groups
- 22. latlon points的相对位置
- 23. RavenDB LineString的空间索引
- 24. 使用webgl绘制LineString
- 25. L.mapbox.featureLayer()是否支持LineString?
- 26. LineString中的标记地标
- 27. 将LineString添加到MultiLineString
- 28. KML Linestring绘图问题
- 29. MySQL的错误语法附近“@points
- 30. 对图元文件使用Graphic.DrawLines(Pen pen,Points points),当点数很大时图片无法打开
你是如何让你的观点看起来像这样的?当我显示积分时,他们几乎不清晰。 –
使用STBuffer()函数。理想值取决于你是否在几何或地理上使用它http://technet.microsoft.com/en-us/library/bb933965.aspx –
是的,我正在使用地理与STBuffer(1)和点是长方形的。我怎样才能使他们像你的完美的圈子? –