# Can't get the expected resolution using Rasters.resample

**URL:** https://discourse.julialang.org/t/cant-get-the-expected-resolution-using-rasters-resample/126118
**Category:** Geo
**Created:** [February 20, 2025, 3:16pm UTC](https://discourse.julialang.org/t/cant-get-the-expected-resolution-using-rasters-resample/126118 "2025-02-20T15:16:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)
#### Post date: [February 20, 2025, 3:16pm UTC](https://discourse.julialang.org/t/cant-get-the-expected-resolution-using-rasters-resample/126118/1 "2025-02-20T15:16:14Z")

</div>

I tried the following code snippet to resample high-resolution data to a lower resolution. The first method works, but the second one doesn’t. It seems I missed some parameters for the “`to`” keyword in the `resample` function.

```julia
begin
	lon1,lat1 = X(-179.5:0.1:179.5), Y(-89.5:0.1:89.5)
	var1 = Raster(rand(lon1, lat1), crs=EPSG(4326))

	lon2,lat2 = X(-179.5:1:179.5), Y(-89.5:1:89.5)

#first method
	ref = Raster(rand(lon2, lat2))
	var2 = resample(var1; to=ref, crs=EPSG(4326), method="average")

#second method
	var3 = resample(var1; to=(X=lon2,Y=lat2), crs=EPSG(4326), method="average")
end

```

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [February 20, 2025, 4:18pm UTC](https://discourse.julialang.org/t/cant-get-the-expected-resolution-using-rasters-resample/126118/2 "2025-02-20T16:18:19Z")

</div>

Yes its a little annoying that it swallows that and doesn’t tell you whats wrong.

Passing your dimensions just as a tuple is the solution, you dont need the NamedTuple. But that also doesn’t work at the moment!

I will make better error messages for this and fix the inputs, probably good to copy this to a github issue

---

<div class="post-metadata">

### Author: ![MJulia](https://avatars.discourse-cdn.com/v4/letter/m/7cd45c/32.png) [@MJulia](https://discourse.julialang.org/u/MJulia)
#### Post date: [February 21, 2025, 2:25am UTC](https://discourse.julialang.org/t/cant-get-the-expected-resolution-using-rasters-resample/126118/3 "2025-02-21T02:25:04Z")

</div>

yes, it’s done.
