yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
137 stars 25 forks source link

unsafe_gdalwarp not working as expected #397

Closed alex-s-gardner closed 8 months ago

alex-s-gardner commented 8 months ago

Lets start by loading packages that are needed

using Rasters
using ArchGDAL
using GeoFormatTypes

now let's create an example tif file that we will try to warp

fn = "test.tif"
lat = Y((-90):res:(90 - res))
lon = X((-180):res:(180-res))

ras = Raster(rand(lat, lon), crs=EPSG(4326))
write(fn, ras, force=true)

now let's use ArchGDAL.unsafe_gdalwarp to warp the file into a new projection

ds = ArchGDAL.read(fn)
options = ["-t_srs" "EPSG:3031" "-te" "-2700000" "-2200000" "2800000" "2300000" "-tr" "5000" "5000" "-r" "near" "-of" "GTiff"]
ArchGDAL.unsafe_gdalwarp([ds], options, dest="test2.tif")

the above creates the right size file but the file contains no valid data

now if we run the exact same command in bash at the terminal

gdalwarp -overwrite -t_srs EPSG:3031 -tr 500.0 500.0 -r near -te -2700000 -2200000 2800000 2300000 -of GTiff /Users/gardnera/Documents/GitHub/GRACE.jl/test.tif /Users/gardnera/Documents/GitHub/GRACE.jl/test2.tif

we get the correct file with valid data

rafaqz commented 8 months ago

Youre missing a - on "of", maybe thats it?

Rasters.jl has warp which uses this... so it definately works in general.

alex-s-gardner commented 8 months ago

Youre missing a - on "of", maybe thats it?

Unfortunately that made no difference

evetion commented 8 months ago

The -tr parameters are at least different (factor 10), not sure if that could be it?

alex-s-gardner commented 8 months ago

Hmm... updating libraries and things seem to work as expected this morning.. not sure what the issue was. Closing this, thank you everyone for you help with this.