-
Notifications
You must be signed in to change notification settings - Fork 13
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
GDAL.gdalwarpappoptionsnew missing "-te"? and "-cutline" issue #115
Comments
Hmm, I don't fully understand. We automatically support all options that the GDAL build we provide supports. If you run the latest GDAL.jl, that should be GDAL 3.2.1. I believe the options that you are passing in the vector should all be strings. In the latest example you pass Note by the way that you may find it more convenient to use this: https://yeesian.com/ArchGDAL.jl/latest/reference/#ArchGDAL.unsafe_gdalwarp Or if you want to run the command line utility
Then it will be exactly like https://gdal.org/programs/gdalwarp.html |
Ok, I got this. options = GDAL.gdalwarpappoptionsnew(["-t_srs",pr_m, "-of","GTiff","-tr","1000","1000","-te","606520.000", "4575750.000", "653485.000", "4639545.000", "-te_srs",pr_m], C_NULL) worked! In the second example: options = GDAL.gdalwarpappoptionsnew(["-t_srs",pr_m, "-of","GTiff","-tr","1000","1000","-cl",mask,"-crop_to_cutline"], C_NULL) instead of mask, I used a full name with a directory and extension but it did not work (no error, just the original extent). Btw. I looked thru options in GDAL.jl but I could not find a function that would give me only georeferenced extent [xmin ymin xmax ymax]. So, I have used: gdalinfo to print the band information and took the extent from the text . Any suggestion for a better approach using GDAL.jl (not ArchGDAL)? Unless I have missed appropriate function or option? Ok, next time I will first check ArchGDAL.jl before asking about GDAL.jl ;) Thank you very much! |
If you're looking to use ArchGDAL, you can follow yeesian/ArchGDAL.jl#129 (comment). Otherwise, something like the following might work: ds = GDAL.gdalopenex(filename, GDAL.GDAL_OF_READONLY, C_NULL, C_NULL, C_NULL)
transform = Array{Cdouble}(undef, 6)
result = GDAL.gdalgetgeotransform(dataset, pointer(transform))
xmin = transform[1]
ymax = transform[4]
xmax = xmin + transform[2] * GDAL.gdalgetrasterxsize(ds)
ymin = ymax + transform[6] * GDAL.gdalgetrasterysize(ds)
// [...]
GDAL.gdalclose(ds) Let us know how it worked out for you? |
Yes, that worked well! Thank you very much! |
Great! I'll close the issue then :) |
Hello,
I have been exploring reprojection in Julia.
The simple approach of raster reprojection based on the other raster, it works:
mask= GDAL.gdalopen(mask_dir, GDAL.GA_ReadOnly)
pr_m = GDAL.gdalgetprojectionref(mask)
options = GDAL.gdalwarpappoptionsnew(["-t_srs",pr_m, "-of","GTiff","-tr","1000","1000"], C_NULL)
ds_warped = GDAL.gdalwarp("U:/test5.tif", Ptr{GDAL.GDALDatasetH}(C_NULL), 1, [tif], options, C_NULL)
GDAL.gdalwarpappoptionsfree(options)
GDAL.gdalclose(ds_warped)
However, when I added "-te" and "-te_srs" (https://gdal.org/programs/gdalwarp.html) to have the extent of the smaller raster (from each I took the output projection):
options = GDAL.gdalwarpappoptionsnew(["-t_srs",pr_m, "-of","GTiff","-tr","1000","1000","-te","606520.000 4575750.000 653485.000 4639545.000", "-te_srs",pr_m], C_NULL)
I got an info that :
GDALError (CE_Failure, code 6):
Unknown option name '-te'
Any plans to implement that option?
I have also tried to just use the source raster (that is smaller) to cut the extent:
options = GDAL.gdalwarpappoptionsnew(["-t_srs",pr_m, "-of","GTiff","-tr","1000","1000","-cl",mask,"-crop_to_cutline"], C_NULL)
But I am getting just the original extent of the reprojected raster.
I would appreciate some advice.
Best,
Monika
The text was updated successfully, but these errors were encountered: