2

I cannot figure it out if it's possible to get pixel information from my rasters using gdallocationinfo in javascript. I found node-gdal, but after reading its documentation I'm not sure if gdallocationinfo is usable.

I basically need this:

gdallocationinfo mytiff.vrt lonlat.lon lonlat.lat -valonly -geoloc

So I added to my javascript the following as a test (after node-gdal was succesfully installed as explained in the link above):

var gdal = require("gdal");
var dataset = gdal.open("mytiff.vrt");
console.log("number of bands: " + dataset.bands.count());
console.log("width: " + dataset.rasterSize.x);
console.log("height: " + dataset.rasterSize.y);
console.log("geotransform: " + dataset.geoTransform);
console.log("srs: " + (ds.srs ? ds.srs.toWKT() : 'null'));

but I get:

Uncaught ReferenceError: require is not defined

It seems to me that node-gdal is not being recognized, do I need to add some kind of src path to my HTML file first to get node-gdal working?

  • 2
    node-gdal is only meant for node.js (which runs server-side, not client-side) – brianreavis Sep 21 '15 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.