Skip to content

Commit

Permalink
rename rast to Raster
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Apr 25, 2024
1 parent e52b064 commit e3cebe1
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Terra"
uuid = "cfcdd479-6883-4e94-b5c8-0a25d121abce"
authors = ["Dongdong Kong <kongdd@users.noreply.github.com>"]
version = "0.1.0"
version = "0.1.1"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand Down
8 changes: 4 additions & 4 deletions examples/example_apply.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ntime = length(dates)
data = rand(length(lon), length(lat), ntime)
dims = X(lon), Y(lat), Ti(dates)
ra = rast(data, dims)
ra = Raster(data, dims)
probs = [0.05, 0.95]
dims_new = Dim{:prob}(probs)
Expand All @@ -34,7 +34,7 @@ res = Ipaper.apply(data, 3; by=date_year(dates), fun=NanQuantile, combine=true,
obj_size(res)
```

## 0.2. 版本2: rast
## 0.2. 版本2: Raster
> dimension信息终身携带
```{julia}
Expand Down Expand Up @@ -71,12 +71,12 @@ nc_info(f)
### 1.0.1. R语言

```{julia}
r = rast("temp.nc", name=:pr)
r = Raster("temp.nc", name=:pr)
```

```{r}
library(terra)
f = "temp.nc"
rast(f)
Raster(f)
```

2 changes: 1 addition & 1 deletion scripts/previous/hello.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```{julia}
using Terra
f = "data/MOD13A2_Henan_2015_2020_10km.tif"
r = rast(f; missingval=0.0f0)
r = Raster(f; missingval=0.0f0)
r[r .== 0.0f0] .= NaN32;
```

Expand Down
6 changes: 3 additions & 3 deletions scripts/previous/zarr-01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"source": [
"# 第一次读写\n",
"fout = \"f_star.tif\"\n",
"ra = rast(A)\n",
"ra = Raster(A)\n",
"@time st_write(ra, fout)"
]
},
Expand Down Expand Up @@ -100,7 +100,7 @@
"source": [
"# 第二次读写\n",
"# 可能是tiled的原因导致文件偏大\n",
"ra = rast(A)\n",
"ra = Raster(A)\n",
"@time st_write(ra, fout)"
]
},
Expand Down Expand Up @@ -208,7 +208,7 @@
"import Terra\n",
"\n",
"b = Terra.bbox(70, 15, 140, 55)\n",
"r2 = Terra.rast(A, b);"
"r2 = Terra.Raster(A, b);"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions scripts/s4_upload_to_GEE.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ library(terra)
library(Ipaper)
indir = "/mnt/z/GitHub/jl-spatial/Whittaker2.jl/scripts/Project_Global_LAI_smoothing/OUTPUT/global_param_lambda_vcurve"
fs = dir(indir, "*.tif", full.names = TRUE)
# f = fs[1]; plot(rast(f), main = basename(f))
# f = fs[1]; plot(Raster(f), main = basename(f))
write_fig({
par(mfrow = c(3, 2))
for(f in fs) {
plot(rast(f), main = basename(f))
plot(Raster(f), main = basename(f))
}
}, "Figure1_global_lambda_vcurve.pdf", 11, 7)
```
Expand Down Expand Up @@ -93,7 +93,7 @@ using Ipaper
indir = realpath("/mnt/z/GitHub/jl-spatial/Whittaker2.jl/scripts/Project_Global_LAI_smoothing/OUTPUT/global_param_lambda_vcurve")
fs = dir(indir, "tif")
ra = rast(fs[1], lazy=true)
ra = Raster(fs[1], lazy=true)
x, y = st_dims(ra)
l = (;xsize=length(x),ysize=length(y),num_bands=1)
Expand Down
6 changes: 3 additions & 3 deletions src/Terra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const AG = ArchGDAL
@reexport using Ipaper.sf
@reexport using Rasters
using Rasters: AbstractRaster
rast = Raster
Raster = Raster
brick = RasterStack

include("GDAL/GDAL.jl")
Expand All @@ -32,14 +32,14 @@ include("IO.jl")

include("MFDataset/MFDataset.jl")

# include("rast.jl")
# include("Raster.jl")
include("apply.jl")
include("tools.jl")

include("tools_Ipaper.jl")
include("main_cdo.jl")

export rast, brick,
export Raster, brick,
rast_apply,
set_names

Expand Down
2 changes: 1 addition & 1 deletion src/apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ntime = length(dates)
data = rand(length(lon), length(lat), ntime)
dims = X(lon), Y(lat), Ti(dates)
ra = rast(data, dims)
ra = Raster(data, dims)
probs = [0.05, 0.95]
dims_new = Dim{:prob}(probs)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ using NetCDFTools
include("test-MFDataset.jl")
include("test-mapslices.jl")
include("test-apply.jl")
include("test-rast.jl")
include("test-Raster.jl")
include("test-gdal_polygonize.jl")
include("test-st_mosaic.jl")
8 changes: 4 additions & 4 deletions test/test-MFDataset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dir_root = dirname(dirname(@__FILE__))
b = bbox(70, 15, 140, 55)
A = rand(10, 10, 5)

ra1 = rast(A, b; name=:x)
ra2 = rast(A, b; name=:y)
ra1 = Raster(A, b; name=:x)
ra2 = Raster(A, b; name=:y)

@test_nowarn ras = brick(ra1, ra2)
end
Expand All @@ -22,11 +22,11 @@ end
@testset "tiff file" begin
# b = bbox(70, 15, 140, 55)
# A = rand(10, 10)
# ra = rast(A, b)
# ra = Raster(A, b)
f = "$dir_root/data/test1.tif"
# write(f, ra, force=true)

ra = rast(f)
ra = Raster(f)
@test st_bbox(ra) == st_bbox(f)
end
## 数据保存没有问题,可能是读取的时候出现了bug
Expand Down
2 changes: 1 addition & 1 deletion test/test-apply.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
data = rand(length(lon), length(lat), ntime)
dims = X(lon), Y(lat), Ti(dates)

ra = rast(data, dims)
ra = Raster(data, dims)

probs = [0.05, 0.95]
dims_new = Dim{:prob}(probs)
Expand Down
4 changes: 2 additions & 2 deletions test/test-gdal_polygonize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using ArchGDAL
b = bbox([70, 15, 140, 55]...)

A[1] = 0
ra = rast(A, b)
ra = Raster(A, b)
# ra.A

f = "test_nodata.tif"
Expand Down Expand Up @@ -51,7 +51,7 @@ end
# A = rand(Bool, 7 * n, 4 * n, 100)
# b = bbox([70, 15, 140, 55]...)

# ra = rast(A, b)
# ra = Raster(A, b)
# ra.A

# ## 1. without nodata
Expand Down
8 changes: 4 additions & 4 deletions test/test-rast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ using Rasters.Extents: extent

# 2d array
data = rand(70, 40)
ra2 = rast(data, b)
ra2 = Raster(data, b)
@test st_bbox(ra2) == b

# 3d array
data = rand(70, 40, 10)
ra3 = rast(data, b)
ra3 = Raster(data, b)
@test st_bbox(ra3) == b


Expand All @@ -26,7 +26,7 @@ using Rasters.Extents: extent
b = bbox(70, 15, 140, 55)
data = rand(70, 40, ntime)
# obj_size(data)
ra = rast(data, b; date=dates)
ra = Raster(data, b; date=dates)
@test collect(ra.dims[3]) == dates
end

Expand All @@ -35,7 +35,7 @@ end
A = rand(360, 180)
b = bbox(-180, -90, 180, 90)

ra = rast(A, b)
ra = Raster(A, b)
# write("a.tif", ra, force=true)
# run(`gdalinfo a.tif`)
ext = extent(ra)
Expand Down

0 comments on commit e3cebe1

Please sign in to comment.