Socket
Socket
Sign inDemoInstall

cell-aspect-ratio

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cell-aspect-ratio

Utility Functions for working with Cell Aspect Ratios.


Version published
Maintainers
1
Install size
13.9 kB
Created

Readme

Source

cell aspect ratio

Utility Functions for working with Cell Aspect Ratios

install

npm install cell-aspect-ratio

what is a cell aspect ratio?

Cell Aspect Ratio (CAR) is the ratio of "real world" height to width for cells in a grid. It's best understood in contrast to Pixel Aspect Ratio (PAR). Whereas PAR refers to the dimensions of a pixel or cell in "pixels", CAR refers to the dimensions of a pixel or cell in meters or degrees.

the resize problem

This library was created to solve a particular image/grid resizing problem. When a grid's height and width don't share a common denominator, it's impossible to resize the image without introducing some image stretching. This image stretching is often undetectable to the human eye, but for geospatial or scientific calculations this is important. Additionally, at least one GeoSpatial format, ASCII Grid, requires that all cells be squares with the same height and width. I need a way to resize without introducing small changes in the height vs. width ratio.

usage

import { resize } from "cell-aspect-ratio";
// or const { resize } = require("cell-aspect-ratio");

const result = resize({
  debug: false,
  height: 5365,
  width: 4201,
  target_height: 54,
  maxDenominator: 100
});

result is an object with information needed to resize the grid precisely

{
  numerator: 1,
  denominator: 99,
  pad_x: 56, // how many empty no-data columns to add to your grid before resizing
  pad_y: 80, // how many empty no-data rows to add to your grid before resizing
  new_area: 23179365,
  new_height: 5445,
  new_width: 4257,
  new_cell_size: 98.99999999999999,
  scale: 0.010101010101010102,
  resized_height: 55,
  resized_width: 43,
  cell_size_diff: 0.35185185185186185
}

Keywords

FAQs

Last updated on 28 Oct 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc