Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write in an Band #63

Open
EchoPouet opened this issue Mar 15, 2019 · 3 comments
Open

Write in an Band #63

EchoPouet opened this issue Mar 15, 2019 · 3 comments

Comments

@EchoPouet
Copy link

Hello,

I convert a Python code with GDAL and Numpy that use gdal.Band.WriteArray method but it doesn't exist in your package.

How to made this operation with your package ?

My Python code :

outband = dsOut.GetRasterBand(1)
outband.WriteArray(OUTPUT[0].transpose())

Thanks

@visr
Copy link
Member

visr commented Mar 15, 2019

If I understand correctly, Python's WriteArray method is something added to the Python GDAL API to make working with NumPy arrays a bit easier. It's not part of the GDAL C API, which is what this package wraps. You can see here at the end that only Python uses WriteArray: https://gdal.org/gdal_tutorial.html.

I see in https://github.com/JuliaGeo/GDAL.jl/blob/master/test/tutorial_raster.jl that we didn't yet translate this last example to Julia, we should do that. You can try it based on the example in C if you want. If you get stuck post it here then we can work it out together. Otherwise I'll get to it when I have some more time.

@EchoPouet
Copy link
Author

I have replaced WriterArray by the code below:

outband = GDAL.getrasterband(dsOut, 1)
xsize = GDAL.getrasterbandxsize(outband)
ysize = GDAL.getrasterbandysize(outband)
outputTranpose = transpose(output[1])
GDAL.rasterio(outband, GDAL.GF_Write, 0, 0, xsize, ysize, Ref(outputTranpose), size(outputTranpose)[1], size(outputTranpose)[2], GDAL.GDT_Float32, 0, 0)
GDAL.setrasternodatavalue(outband,` 0.)

Maybe you should add this example in your tutorial.

Thanks for your help.

@visr
Copy link
Member

visr commented Mar 27, 2019

Glad that you've been able to make it work. I'll reopen the issue to serve as a reminder to add test/tutorial code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants