Giter VIP home page Giter VIP logo

Comments (7)

springmeyer avatar springmeyer commented on September 14, 2024

@brandonreavis and @brandonreavis will know more, but I think the bindings to get at this info should be in place. I just updated an example to work with latest master: 417c566

from node-gdal.

springmeyer avatar springmeyer commented on September 14, 2024

Oh, and I'll add that until formal docs are available don't hesistate to look in the c++ code to see what is available: https://github.com/naturalatlas/node-gdal/blob/master/src/gdal_rasterband.cpp#L24-L57. The NODE_SET_PROTOTYPE_METHOD entries add methods you can call like band.toString() and the ATTR entries add properties like band.maximum.

from node-gdal.

brandonreavis avatar brandonreavis commented on September 14, 2024

Ah, thats what GDAL's GetColorInterpretation() function is for (details). I haven't done much with rasters personally, so I only added bindings for the functions that sounded important haha. I haven't touched that method but that should be easy to add. I'll get on that shortly.

Once I add it I think you should be able to do what you want with something like:

console.log("# of bands: "+dataset.bands.count());
dataset.bands.forEach(function(band){
     console.log("band["+band.id+"] color: "+band.colorInterpretation);
})

This also reminds me of another thing I have been thinking about... Do we want to convert all GDAL enums into their string names instead of integers? It would be easier to understand when printed out to the console.

from node-gdal.

brandonreavis avatar brandonreavis commented on September 14, 2024

Also, sorry for the commit that screwed up everything last night hah. I have been trying to keep a crude method/attribute list here, but I havent updated it to reflect last night's change yet. I'll update that today as well.

It can be tricky to understand how to use each function by just glancing at the code sometimes - especially with methods like gdal.open() which is implemented half in JS and half in C++

from node-gdal.

GretaCB avatar GretaCB commented on September 14, 2024

Awesome @brandonreavis , thanks for the custom addition! And no worries about the commit yesterday, I had no idea.

from node-gdal.

brandonreavis avatar brandonreavis commented on September 14, 2024

I just updated the list of methods and attributes so its more current and easier to follow. Here it is: (link)

I still need to add the colorInterpretation attribute.

from node-gdal.

brandonreavis avatar brandonreavis commented on September 14, 2024

Alright now you should be able to do what you need!

> var gdal = require('./lib/gdal')
undefined
> var ds = gdal.open('examples/sample.tif')
undefined
> var band = ds.bands.get(1)
undefined
> band.colorInterpretation
'Gray'

The list of all the possible strings is here: (link)

from node-gdal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.