New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

topojson-simplify

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

topojson-simplify

Topology-preserving simplification and filtering for TopoJSON.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

TopoJSON Simplify

Topology-preserving simplification and filtering for TopoJSON. Smaller files, faster rendering!

For an introduction to line simplification:

  • https://bost.ocks.org/mike/simplify/
  • https://www.jasondavies.com/simplify/

Installing

If you use NPM, npm install topojson-simplify. Otherwise, download the latest release. You can also load directly from unpkg. AMD, CommonJS, and vanilla environments are supported. In vanilla, a topojson global is exported:

<script src="https://unpkg.com/topojson-client@2"></script>
<script src="https://unpkg.com/topojson-simplify@0.1"></script>
<script>

topojson.presimplify(topology);

</script>

Try topojson-simplify in your browser.

API Reference

# topojson.presimplify(topology[, weight])

… If weight is not specified, it defaults to planarTriangleArea.

# topojson.simplify(topology[, minWeight])

… The specified topology must have previously been passed to presimplify. If minWeight is not specified, it defaults to Number.MIN_VALUE.

# topojson.quantile(topology, p)

… Returns the p-quantile of the weighted points in the given topology, where p is a number in the range [0, 1]. This value is then typically passed to simplify as the minWeight. For example, the median weight can be computed using p = 0.5, the first quartile at p = 0.25, and the third quartile at p = 0.75. This particular implementation uses the R-7 method, which is the default for the R programming language and Excel. The specified topology must have previously been passed to presimplify.

Filtering

# filter(ring, interior)

To filter a topology, you supply a filter function to filter. The filter function is invoked for each ring in the input topology, being passed two arguments: the ring, specified as an array of points where each point is a two-element array of numbers, and the interior flag. If interior is false, the given ring is the exterior ring of a polygon; if interior is true, the given ring is an interior ring (a hole). The filter function must then return true if the ring should be preserved, or false if the ring should be removed.

See filterAttached and filterWeight for built-in filter implementations.

# topojson.filter(topology[, filter])

# topojson.filterAttached(topology)

# topojson.filterWeight(topology[, minWeight[, weight]])

… If minWeight is not specified, it defaults to Number.MIN_VALUE. If weight is not specified, it defaults to planarRingArea.

Geometry

# topojson.planarRingArea(ring, interior)

# topojson.planarTriangleArea(triangle)

# topojson.sphericalRingArea(ring, interior)

# topojson.sphericalTriangleArea(triangle)

Command Line Reference

toposimplify

# toposimplify [options…] [file] <>

… See also topojson.simplify.

# toposimplify -h
# toposimplify --help

Output usage information.

# toposimplify -V
# toposimplify --version

Output the version number.

# toposimplify -o file
# toposimplify --out file

Specify the output TopoJSON file name. Defaults to “-” for stdout.

# toposimplify -p value
# toposimplify --planar-area value

Specify simplification threshold value as the minimum planar triangle area, typically in square pixels.

# toposimplify -P value
# toposimplify --planar-quantile value

Specify simplification threshold value as the minimum quantile of planar triangle areas. The value should be in the range [0, 1].

# toposimplify -s value
# toposimplify --spherical-area value

Specify simplification threshold value as the minimum spherical triangle area (spherical excess), in steradians.

# toposimplify -S value
# toposimplify --spherical-quantile value

Specify simplification threshold value as the minimum quantile of spherical triangle areas (spherical excess). The value should be in the range [0, 1].

# toposimplify -f
# toposimplify --filter-detached

Remove detached rings that are smaller than the simplification threshold after simplifying.

# toposimplify -F
# toposimplify --filter-all

Remove any rings that are smaller than the simplification threshold after simplifying.

Keywords

FAQs

Package last updated on 03 Nov 2016

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