Crystal wrapper for GDAL. Only a subset of the library is supported for now.
-
Add the dependency to your
shard.yml
:dependencies: lib_gdal: github: crmorello/lib_gdal
-
Run
shards install
require "lib_gdal"
You will need GDAL installed.
It should work just like the GDAL C api does. Be careful passing pointers around, definitely use Bytes where possible.
file_name_cstr = data_path.to_unsafe.as(Pointer(Char))
dataset = LibGDAL.open(file_name_cstr, LibGDAL::Access::ReadOnly)
max_x = LibGDAL.get_raster_x_size(dataset)
max_y = LibGDAL.get_raster_y_size(dataset)
band = LibGDAL.get_raster_band(dataset, 1)
geo_tran = LibC.malloc(6 * sizeof(Float64)).as(Pointer(Float64))
has_no_data_value = uninitialized Int32
no_data_value = LibGDAL.get_no_data_value(@band, pointerof(has_no_data_value)).to_u8! || 0_u8
error = LibGDAL.get_geo_transform(dataset, @geo_tran)
LibGDAL.close(dataset)
LibC.free(geo_tran) if geo_tran
......
buffer = Bytes.new(buffer_size)
LibGDAL.raster_io(band, LibGDAL::RWFlag::Read, 0, 0, x_size, y_size, buffer, x_size, y_size, LibGDAL::DataType::GDT_Byte, 0, 0)
- Fork it (https://github.com/crmorello/lib_gdal/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Corey Morello - creator and maintainer