Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geojson-vt

Package Overview
Dependencies
Maintainers
29
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-vt

Slice GeoJSON data into vector tiles efficiently

  • 4.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
increased by12.74%
Maintainers
29
Weekly downloads
 
Created

What is geojson-vt?

The geojson-vt package is a library for slicing GeoJSON into vector tiles on the fly. It's primarily designed to handle large amounts of data by cutting them into smaller, more manageable pieces called 'tiles'. These tiles can then be used for efficient rendering and manipulation on map interfaces.

What are geojson-vt's main functionalities?

Slicing GeoJSON into vector tiles

This feature allows you to convert a GeoJSON object into vector tiles. You can then retrieve specific tiles by their x, y, and z coordinates.

const geojsonVt = require('geojson-vt');
const geojsonData = {
  type: 'FeatureCollection',
  features: [...]
};
const options = {};
const tileIndex = geojsonVt(geojsonData, options);
const tile = tileIndex.getTile(z, x, y);

Custom tile generation options

This feature allows you to customize how the GeoJSON data is sliced into vector tiles, including the level of detail, simplification tolerance, and tile dimensions.

const options = {
  maxZoom: 17,  // max zoom to preserve detail on; can't be higher than 24
  tolerance: 3, // simplification tolerance (higher means simpler)
  extent: 4096, // tile extent (both width and height)
  buffer: 64,   // tile buffer on each side
  debug: 0,     // logging level (0 to disable, 1 or 2)
  lineMetrics: false, // whether to enable line metrics tracking for LineString/MultiLineString features
  promoteId: null,   // name of a feature property to promote to feature.id
  generateId: false, // whether to generate feature ids. Cannot be used with promoteId
  indexMaxZoom: 5,       // max zoom in the initial tile index
  indexMaxPoints: 100000 // max number of points per tile in the index
};
const tileIndex = geojsonVt(geojsonData, options);

On-the-fly tile generation

This feature allows you to generate tiles on demand, rather than processing an entire set of tiles upfront. This can be more efficient when dealing with large datasets.

const tile = tileIndex.getTile(z, x, y);
if (!tile) {
  console.log('Tile not found');
} else {
  console.log('Generated tile:', tile);
}

Other packages similar to geojson-vt

Keywords

FAQs

Package last updated on 17 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc