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

cell-aspect-ratio

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cell-aspect-ratio

Utility Functions for working with Cell Aspect Ratios.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 28 Oct 2021

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