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

@mluds/georaster

v1.5.7

Published

Wrapper around Georeferenced Rasters like GeoTIFF, NetCDF, JPG, and PNG that provides a standard interface

Downloads

131

Readme

georaster

Wrapper around Georeferenced Rasters like GeoTIFF, NetCDF, JPG, and PNG that provides a standard interface. You can also create your own georaster from simple JavaScript objects.

load from url on front-end

const parseGeoraster = require("georaster");
fetch(url)
  .then(response => response.arrayBuffer() )
  .then(parseGeoraster)
  .then(georaster => {
      console.log("georaster:", georaster);
  });

load from file on back-end

const parseGeoraster = require("georaster");
fs.readFile("data/GeogToWGS84GeoKey5.tif", (error, data) => {
    parseGeoraster(data).then(georaster => {
      console.log("georaster:", georaster);
    })
});

load from simple object on front-end

const parseGeoraster = require("georaster");
const values = [ [ [0, 1, 2], [0, 0, 0], [2, 1, 1] ] ];
const noDataValue = 3;
const projection = 4326;
const xmin = -40;
const ymax = 14;
const pixelWidth = 0.00001;
const pixelHeight = 0.00001;
const metadata = { noDataValue, projection, xmin, ymax, pixelWidth, pixelHeight };
const georaster = parseGeoraster(values, metadata);

load cloud optimized geotiff

This option allows you to basically load the pixels only when you need them versus the other options that require you to load the whole image into memory. It will also attempt to automatically discover any available overview files.

where to clip

top is how many pixels from the top of the image to skip over before we start clipping

bottom is how many pixels from the bottom of the image to skip over before we start clipping

left is how many pixels in from the left side of the image to skip over before we start clipping

right is how many pixels in from the right side of the image to skip over before we start clipping

clipping resolution

width is how many pixels wide should be the returned image. This helps to configure the resolution.

height is how many pixels tall should be the returned image. This helps to configure the resolution.

resampling

resampleMethod is how to resample the pixels for the returned image. This value is passed on to geotiff.js' readRasters function and defaults to 'bilinear'. The alternative is 'nearest', which is faster and better for categorical data like landcover and continous classes with smooth variation like temperature.

  const raster_url = "https://landsat-pds.s3.amazonaws.com/c1/L8/024/030/LC08_L1TP_024030_20180723_20180731_01_T1/LC08_L1TP_024030_20180723_20180731_01_T1_B1.TIF";
  parseGeoraster(raster_url).then(georaster => {
    console.log(georaster.height);
    const options = { left: 0, top: 0, right: 4000, bottom: 4000, width: 10, height: 10 };
    georaster.getValues(options).then(values => {
      console.log("clipped values are", values);
    });
  });

required properties

| name | description | | ---- | ----------- | | maxs | array with max value for each band | | mins | array with min value for each band | | ranges | array with difference between max and min value for each band | | noDataValue | no data value | | pixelWidth | width of pixel in dimension of coordinate reference system | | pixelHeight | height of pixel in dimension of coordinate reference system | | projection | equal to EPSG code, like 4326 | | values | two dimensional array of pixel values (for Cloud Optimized GeoTIFF's, use getValues instead) | | width | number of pixels wide raster is | | xmax | xmax in crs, which is often in longitude | | xmin | xmin in crs, which is often in longitude | | ymin | ymin in crs, which is often in latitude | | ymax | ymax in crs, which is often in latitude |

optional properties

| name | description | | ---- | ----------- | | palette | Array that maps raster values to RGBA colors |

functions

| name | description | | ---- | ----------- | | getValues | described above | | toCanvas | experimental! returns a canvas picture of the data. You can pass in options object with height or width specified |

loading georaster package through a script tag

<script src="https://unpkg.com/georaster"></script>

You can view a simple demo of this here

Support

Post a Github issue or contact the package author, Daniel J. Dufour, at [email protected]