Skip to content

Commit 28a21cf

Browse files
Allow reproject(obj, target_crs) as well (#856)
* Allow `reproject(obj, target_crs)` as well Just allows a different argument order so that Rasters and GO reproject definitions are compatible * add test * Error message on 2 GeoFormats Co-authored-by: Felix Cremer <[email protected]> * Update src/methods/reproject.jl Co-authored-by: Felix Cremer <[email protected]> --------- Co-authored-by: Felix Cremer <[email protected]>
1 parent 9a718eb commit 28a21cf

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/methods/reproject.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ are silently returned without modification.
2121
$CRS_KEYWORD
2222
"""
2323
reproject(x; crs::GeoFormat) = reproject(crs, x)
24+
reproject(x, target::GeoFormat) = reproject(target, x)
25+
reproject(::GeoFormat, ::GeoFormat) = throw(ArgumentError("You need to provide a raster object to reproject. Got two coordinate reference systems."))
2426
reproject(target::GeoFormat, x) = rebuild(x; dims=reproject(target, dims(x)))
2527
reproject(target::GeoFormat, dims::Tuple) = map(d -> reproject(target, d), dims)
2628
reproject(target::GeoFormat, l::Lookup) = l

test/reproject.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using Rasters: reproject, convertlookup
2424
y = Y(Projected(-80.0:1.0:80.0; crs=EPSG(4326), dim=Y(), order=ReverseOrdered(), span=Regular(1.0), sampling=Intervals(Start())))
2525

2626
x1, y1 = reproject((x, y); crs=projcea)
27+
@test reproject((x, y), projcea) == reproject(projcea, (x, y))
2728
@test span(x1) isa Irregular
2829
@test span(y1) isa Irregular
2930
x2, y2 = reproject((x, y); crs=EPSG(4326))

0 commit comments

Comments
 (0)