turf-inside travis-ci npm

Checks to see if a point is inside of a polygon.

2 years after

turf-inside

build status

turf inside module

turf.inside(point, polygon)

Takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.

Parameters

parameter type description
point Feature.\<Point> input point
polygon Feature.\<Polygon MultiPolygon> input polygon or multipolygon

Example

var pt1 = {
  "type": "Feature",
  "properties": {
    "marker-color": "#f00"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [-111.467285, 40.75766]
  }
};
var pt2 = {
  "type": "Feature",
  "properties": {
    "marker-color": "#0f0"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [-111.873779, 40.647303]
  }
};
var poly = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [-112.074279, 40.52215],
      [-112.074279, 40.853293],
      [-111.610107, 40.853293],
      [-111.610107, 40.52215],
      [-112.074279, 40.52215]
    ]]
  }
};

var features = {
  "type": "FeatureCollection",
  "features": [pt1, pt2, poly]
};

//=features

var isInside1 = turf.inside(pt1, poly);
//=isInside1

var isInside2 = turf.inside(pt2, poly);
//=isInside2

Returns Boolean, true if the Point is inside the Polygon; false if the Point is not inside the Polygon

Installation

Requires nodejs.

$ npm install turf-inside

Tests

$ npm test

Related Repositories

browserify-handbook

browserify-handbook

how to build modular applications with browserify ...

cheap-ruler

cheap-ruler

Fast approximations for common geographic measurements ...

hoodie-plugin-tutorial

hoodie-plugin-tutorial

A detailed walkthrough of the plugin writing process ...

TALOS

TALOS

Computer Network Defender's Toolkit, specializing in active defense techniques. ...

geoplyr

geoplyr

Working with spatial data inside dataframes and other solutions for spatial pain ...


Top Contributors

morganherlocker lyzidiamond tmcw ThomasG77 tcql

Releases

-   v1.1.4 zip tar