mmomtchev / node-gdal-async

Node.js bindings for GDAL (Geospatial Data Abstraction Library) with full async support
https://mmomtchev.github.io/node-gdal-async/
Apache License 2.0
136 stars 27 forks source link

work with buffers possible? #177

Closed pcace closed 2 months ago

pcace commented 2 months ago

Hi there, i am trying to figure out how the library works.

for testing i currently do something like this:

const georefImagePath = './tmp/georef_image.tiff'
      await gdal.translateAsync(georefImagePath, ds, [
        '-of',
        'GTiff',
        '-a_srs',
        'EPSG:4326',
        '-a_ullr',
        '13.419277533858136',
        '52.49647748166542',
        '13.425815172448008',
        '52.49249712044625',
      ])
      const ds2 = await gdal.openAsync('./tmp/georef_image.tiff')

      // Translate and split the image by the original tile outline
      const splitImagePath = './tmp/split_image.tiff'
      await gdal.translateAsync(splitImagePath, ds2, [
        '-projwin',
        '392725.32106280397',
        '5817398.500672792',
        '393090.09782117046',
        '5817018.380358465',
        '-projwin_srs',
        'EPSG:25833',
      ])

which kind of works, but is quite annoying, that i am working with files on the disk. is it somehow possible to work with buffers here entirely?

Any help would be great! Thanks a lot!

mmomtchev commented 2 months ago

open and openAsync support opening a Buffer but the command-line tools (translateAsync) do not. You can however use GDAL's own in-memory VFS: https://gdal.org/en/latest/user/virtual_file_systems.html#vsimem-in-memory-files https://mmomtchev.github.io/node-gdal-async/#vsimem