npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geotiff-tile

v0.20.0

Published

Generate a Map Tile from a GeoTIFF File.

Downloads

428

Readme

geotiff-tile

Generate a Map Tile from a GeoTIFF File.

install

npm install geotiff-tile

basic usage

import { createTile } from "geotiff-tile";

await createTile({
  // bounding box of tile in format [xmin, ymin, xmax, ymax]
  bbox: [-122.49755859375, 38.8520508, -120.06958007812499, 40.697299008636755],

  // spatial reference system of the bounding box
  // as a EPSG Code number
  bbox_srs = 4326,

  // geometry to clip by in GeoJSON format
  cutline: geojson,

  // spatial reference system of cutline
  cutline_srs,

  // set to higher number to increase logging
  debug_level = 0,

  // how many points to add to each side of the bounding box if reprojecting
  // optional, default is 100
  density = 100,

  // instance of geotiff.js
  geotiff,

  // function that accepts a pixel array of values of type
  // ({ pixel }: { pixel: number[] }) => number[]
  expr,

  // layout using xdim layout syntax
  // https://github.com/danieljdufour/xdim
  layout = "[band][row,column]",

  // resampling method
  method,

  // round pixel values to integers
  round,

  // optional
  // override default nested tile array types
  tile_array_types: ["Array", "Uint8ClampedArray"],

  // optional
  // if tile_array_types is not specified, choose
  // the strategy for deciding which type of arrays
  // auto - safest and default option, only uses typed array if it's sure there won't be any clamping
  // geotiff - use the same array types that geotiff.js uses (good if not stretching min or max)
  // untyped - use only untyped arrays
  // undefined - same as auto
  tile_array_types_strategy: "untyped",

  // over-ride default "no data" value in output tile
  tile_no_data: 0,

  // projection of the tile
  // as an EPSG code
  tile_srs: 3857,

  // tile height in pixel
  tile_height: 512,

  // width of tile in pixels
  tile_width: 512,

  // resolution of the tile
  // from 0 (lowest) to 1 (highest)
  tile_resolution: 0.5,

  // whether to use overviews if available
  // default is true
  // setting to false will mean the usage of the highest resolution data
  use_overview: false,

  // optional, default is false
  // enable experimental turbocharging via proj-turbo
  turbo: false
})

advanced usage

over-riding geotiff no data value

If for some reason your geotiff has values that should be treated as no data, but this isn't properly set in the metadata, you can over-ride the no data value

await createTile({
  geotiff,
  geotiff_no_data: -32767,
  // rest is the same
})

over-riding geotiff srs

If for some reason geotiff-tile can't parse the correct projection from your geotiff, you can manually specify the projection via the geotiff_srs parameter.

await createTile({
  geotiff,
  geotiff_srs: 3031,
  // rest is the same
})

image pixel coordinates and simple srs

You can also select pixels using a "simple" spatial reference system where the bottom left of your data is the origin [0, 0] and the top-right corner is [width, height]. This is inspired by Leaflet's Simple CRS.

await createTile({
  bbox: [128, 656, 144, 672],
  bbox_srs: "simple",

  // rest is the same
})