2

Is it possible with the GDAL library to read an image (e.g. GeoTiff) from a memory stream, like stdin instead of a defined location on the local disk?

It would be useful to read data in streaming environments. In my case I would like to use the Hadoop Streaming API, which reads the datastream from HDFS, so passing a file URI to the GDALOpen() function is not possible.

  • Is this anything to that direction osgeo-org.1560.x6.nabble.com/…? Found from the web with search "gdal memory stream". – user30184 Apr 26 '16 at 8:33
  • Thanks, I skipped this one, because it started with C# bindings. But it really answers my question, there is a VSIFileFromMemBuffer C/C++ function to read a stream into a virtual file and retrieve a path starting with "/vsimem/". The problem was that I looked for a solution to pass the memory stream to GDALDataSet or GDALOpen and not to get a virtual path for the data :) – mcserep Apr 26 '16 at 8:53
2
var geoJsonToBeCaclBytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(geometry));
string geoJsonToBeCaclFileName = $"/vsimem/{Guid.NewGuid()}.geo.json";
Gdal.AllRegister();
Gdal.FileFromMemBuffer(geoJsonToBeCaclFileName, geoJsonToBeCaclBytes);

maybe load these memory stream into /vsimem file path, then use gdal api read these file through this path.

see also : https://www.gdal.org/gdal_virtual_file_systems.html#gdal_virtual_file_systems_vsihdfs

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.