Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

gdal_smallgrid.sh 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. #!/usr/bin/env bash
  2. #
  3. #
  4. # test reading and writing a very small grid via gdal
  5. # create pixel test grid
  6. gmt grdmath -r -R-0.5/1.5/-0.5/1.5 -I1 X 1 NAN = pixel.nc=nb
  7. gmt grd2xyz pixel.nc > pixel.xyz
  8. diff -q --strip-trailing-cr ${src:-.}/smallgrid.xyz pixel.xyz
  9. # create gridline test grid
  10. gmt grdmath -R0/1/0/1 -I1 X 1 NAN = gridline.nc=nb
  11. gmt grd2xyz gridline.nc > gridline.xyz
  12. diff -q --strip-trailing-cr ${src:-.}/smallgrid.xyz gridline.xyz
  13. gdal_types="u8 u16 i16 u32 i32 float32"
  14. for type in ${gdal_types}; do
  15. # write pixel grid and read back
  16. gmt grdconvert pixel.nc pixel_${type}.tif=gd///99:gtiff/${type}
  17. gmt grdconvert pixel_${type}.tif pixel_${type}.nc=nb
  18. gmt grd2xyz pixel_${type}.tif > pixel_${type}.tif.xyz
  19. gmt grd2xyz pixel_${type}.nc > pixel_${type}.nc.xyz
  20. diff -q --strip-trailing-cr ${src:-.}/smallgrid.xyz pixel_${type}.tif.xyz
  21. diff -q --strip-trailing-cr ${src:-.}/smallgrid.xyz pixel_${type}.nc.xyz
  22. # write gridline grid and read back
  23. gmt grdconvert gridline.nc gridline_${type}.tif=gd///99:gtiff/${type}
  24. gmt grdconvert gridline_${type}.tif gridline_${type}.nc=nb
  25. gmt grd2xyz gridline_${type}.tif > gridline_${type}.tif.xyz
  26. gmt grd2xyz gridline_${type}.nc > gridline_${type}.nc.xyz
  27. diff -q --strip-trailing-cr ${src:-.}/smallgrid.xyz gridline_${type}.tif.xyz
  28. diff -q --strip-trailing-cr ${src:-.}/smallgrid.xyz gridline_${type}.nc.xyz
  29. done
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...