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-extents

v1.0.0

Published

compute the corner and center bounding coordinates for a geotiff

Downloads

112

Readme

geotiff-extents

compute the corner and center bounding coordinates for a geotiff

example

var fs = require('fs')
var geotiff = require('geotiff')
var epsg = require('epsg-to-proj')
var extents = require('geotiff-extents')

var data = fs.readFileSync(process.argv[2])
var im = geotiff.parse(data).getImage()
var fd = im.getFileDirectory()
var gk = im.getGeoKeys()

console.log(extents({
  tiePoint: fd.ModelTiepoint,
  pixelScale: fd.ModelPixelScale,
  width: fd.ImageWidth,
  height: fd.ImageLength,
  proj: require('proj4'),
  from: epsg[gk.ProjectedCSTypeGeoKey || gk.GeographicTypeGeoKey],
  to: epsg[4326]
}))

output:

$ node extents.js LC80700192015294LGN00_B2.TIF
{ upperLeft: [ -155.62757614534797, 59.781490186078884 ],
  lowerLeft: [ -155.46612438446172, 57.56866631571051 ],
  upperRight: [ -151.27624278582903, 59.79644709112181 ],
  lowerRight: [ -151.3822362875974, 57.58238285553903 ],
  center: [ -153.4380373185701, 58.69959098078464 ] }

and this output matches up with the listgeo command:

$ listgeo -d LC80700192015294LGN00_B2.TIF | tail -n5
Upper Left    (  352500.000, 6630000.000)  (-155.6275761,59.7814902)
Lower Left    (  352500.000, 6383370.000)  (-155.4661244,57.5686663)
Upper Right   (  596730.000, 6630000.000)  (-151.2762428,59.7964471)
Lower Right   (  596730.000, 6383370.000)  (-151.3822363,57.5823829)
Center        (  474615.000, 6506685.000)  (-153.4380373,58.6995910)

api

var extents = require('geotiff-extents')

var ex = extents(opts)

Compute the bounding and center coordinates ex given:

  • opts.tiePoint - an array (or Float64Array etc) of K*6 tie point coordinates mapping (I,J,K) points in raster space to (X,Y,Z) points in model space.
  • opts.pixelScale - an array (or Float64Array etc) of 3 sizes for raster spacing in model space units
  • opts.width - width of the image in raster (pixel) coordinates
  • opts.height - height of the image in raster (pixel) coordinates
  • opts.proj - proj4(src,dst) coordinate transform implementation
  • opts.from - proj string describing the tie point coordinate system
  • opts.to - proj string describing the output coordinate system

The georeferencing tags are defined in more detail in 2.6.1 GeoTIFF Tags for Coordinate Transformations.

The output object ex has these properties, which map to 2-element coordinate pair arrays in the coordinate system specified by opts.to:

  • ex.upperLeft
  • ex.lowerLeft
  • ex.upperRight
  • ex.lowerRight
  • ex.center

install

npm install geotiff-extents

license

BSD