Hi all, I’m struggling to figure out how to use ArchGDAL.gdalwarp (currently only unsafe_gdalwarp is documented). ArchGDAL.gdalwarp’s first parameter being a function is a bit confusing as well.
Here’s the GDAL CLI version of what I’m trying to implement in ArchGDAL (params I already have in Julia are represented by the all caps strings):
I can do a PR if you’d like. Feel free to create an issue in GeoData.jl and tag me! Can probably get to that next week. Also feel free to copy/paste the above if you want to implement it.
I have a similar issue trying to resample with gdalwarp(). I want to write a function to save both the warped dataset and the Matrix of the band for processing. I need the dataset to use the getgeotransform(dataset) and getproj(dataset) methods to retrieve the x/y from the row/col of the pixel.
From my understanding, it seems like gdalwarp() calls the unsafe_gdalwarp() method and then destroys the warped dataset. This is what I tried, but the returned dataset is NULL
function reproject_dem(param, output_bounds)
dst_cs = AG.importEPSG(point2epsg(param.lon, param.lat)) # UTM projected coordinate system
AG.read(param.dem_file) do source
AG.gdalwarp([source], ["-t_srs", "$(AG.toWKT(dst_cs))",
"-te",string.(output_bounds)...,
"-te_srs", "$(AG.toWKT(dst_cs))",
"-tr","$(param.pixel_spacing_in_m)","$(param.pixel_spacing_in_m)",
"-r", "cubic"]) do warped
warped,
AG.read(AG.getband(warped, 1))
end
end
end
I ended up using Rasters.warp() because I have to limit the output with a set of bounds defined in the destination CRS, and it seems not possible with Rasters.resample()
If you have time please make a github issue spelling out what should happen and why it doesn’t and I’ll fix it. resample should be able to handle this.