Skip to main content
Version: 7.1.0

findPoint

Description

Finds a particular Point from a GeoJSON using @turf/meta indexes.

Negative indexes are permitted.

Parameters

NameTypeDescription
geojsonFeatureCollection | Feature | GeometryAny GeoJSON Feature or Geometry
options?ObjectOptional parameters (default {})
options.featureIndex?numberFeature Index (default 0)
options.multiFeatureIndex?numberMulti-Feature Index (default 0)
options.geometryIndex?numberGeometry Index (default 0)
options.coordIndex?numberCoord Index (default 0)
options.properties?ObjectTranslate Properties to output Point (default {})
options.bbox?BBoxTranslate BBox to output Point (default {})
options.id?number | stringTranslate Id to output Point (default {})

Returns

Examples

var multiLine = turf.multiLineString([
[
[10, 10],
[50, 30],
[30, 40],
],
[
[-10, -10],
[-50, -30],
[-30, -40],
],
]);

// First Segment (defaults are 0)
turf.findPoint(multiLine);
// => Feature<Point<[10, 10]>>

// First Segment of the 2nd Multi-Feature
turf.findPoint(multiLine, { multiFeatureIndex: 1 });
// => Feature<Point<[-10, -10]>>

// Last Segment of last Multi-Feature
turf.findPoint(multiLine, { multiFeatureIndex: -1, coordIndex: -1 });
// => Feature<Point<[-30, -40]>>

Installation

$ npm install @turf/meta

import { findPoint } from "@turf/meta";
const result = findPoint(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.findPoint(...);