Turf中的point
是一个帮助函数,用于创建一个Point
对象,表示地理空间中的一个点。可以在使用Turf进行空间分析时,用point
来作为输入数据。
const point = turf.point(coordinates, properties);
coordinates
(Array<number>|Array<Array<number>>): 表示点坐标的数组。必须是2维或3维的。二维点的坐标格式为[longitude, latitude]
,三维点的坐标格式为[longitude, latitude, elevation]
。经度和纬度的单位是度,高程的单位可以是米、英尺等。properties
(Object, 可选): 一个包含点属性的对象。Point
对象。const coordinates = [-73.97, 40.77];
const properties = {name: 'Central Park'};
const point = turf.point(coordinates, properties);
Error
: 如果 coordinates
参数无效,将抛出 Error
。可能的原因包括:
coordinates
不是2维或3维数组。coordinates
包含非数字的值。coordinates
中经度或纬度的值超出了其有效范围。经度的有效范围是-180
到180
,纬度的有效范围是-90
到90
。