Created
October 15, 2018 00:30
-
-
Save spestana/83b9334afef551ff85839ed14be487cd to your computer and use it in GitHub Desktop.
Trim CONUS GOES-16 NetCDF imagery to an area around California. Create tif and png image copies.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
rem input directory with NetCDF files | |
set NCdir=%1 | |
rem directory for outputs | |
set outdir=%2 | |
for /R %NCdir% %%f in (*.nc) do ( | |
set "fileFull=%%~nxf" | |
set "fileNumber=%fileFull:~26,14%" | |
echo %fileNumber% | |
rem create a new NetCDF file, subset to only our area of interest using image pixel coordinates | |
gdal_translate -of netCDF -projwin -2685383 3200000 -2000000 4200000 NETCDF:"%%f":Rad "%outdir%%%~nf_CA.nc" | |
rem create a tif image of this new subset NetCDF file | |
gdal_translate -ot float32 -unscale -CO COMPRESS=deflate NETCDF:"%outdir%%%~nf_CA.nc":Rad "%outdir%img\%%~nf.tif" | |
rem set SRS to WGS84 | |
gdalwarp -t_srs EPSG:4326 -dstnodata -999.0 "%outdir%img\%%~nf.tif" "%outdir%img\%%~nf_geo.tif" | |
rem create a png image for easy visualization | |
gdal_translate -ot Byte -of png -scale 0 650 0 255 "%outdir%img\%%~nf_geo.tif" "%outdir%img\%%~nf_geo.png" | |
rem clean up the temporary files we don't want to keep | |
del "%outdir%img\%%~nf.tif" | |
del "%outdir%img\%%~nf_geo.tif" | |
) | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment