Skip to main content
added 6 characters in body
Source Link
Dlan
  • 29
  • 2

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder):
for ThisFile in files:                   # iterate the files
    fN,fE = os.path.splitext(ThisFile)   # separate file name and extension
    if fE.lower() == 'LCCS-2018.nc':
        # this is a netCDF file, though other extensions might exist
        # you will need to provide these details or ascertain them from
        # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 

Format: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:XXX-YEAR.nc:BandName OutputFilename.tifgdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:XXX-YEAR.nc:BandName OutputFilename.tif

Example code: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:LCCS-2018.nc:lccs_class LCCS-2018.tifgdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:LCCS-2018.nc:lccs_class LCCS-2018.tif

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 

Format: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:XXX-YEAR.nc:BandName OutputFilename.tif

Example code: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:LCCS-2018.nc:lccs_class LCCS-2018.tif

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder):
for ThisFile in files:                   # iterate the files
    fN,fE = os.path.splitext(ThisFile)   # separate file name and extension
    if fE.lower() == 'LCCS-2018.nc':
        # this is a netCDF file, though other extensions might exist
        # you will need to provide these details or ascertain them from
        # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command

Format: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:XXX-YEAR.nc:BandName OutputFilename.tif

Example code: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:LCCS-2018.nc:lccs_class LCCS-2018.tif

added 1114 characters in body
Source Link
Dlan
  • 29
  • 2

How do I translate (extract) multiband netCDF to individual raster geotiff?

I am new to scripting, so I am hoping you could help me with how I should write my gdal translate script starting from setting my working directory.


Instructions that come with the data:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:xxxYEAR.nc:BandName OutputFilename.tif

So far:

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 

There are some other instructions:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

with Year the year : 2016, 2017 or 2018; and BandName one of the following: lccs_class; processed_flag; current_pixel_state; observation_count; change_count.

Format: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:XXX-YEAR.nc:BandName OutputFilename.tif

Example code: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:LCCS-2018.nc:lccs_class LCCS-2018.tif

How do I translate (extract) multiband netCDF to individual raster geotiff?

I am new to scripting, so I am hoping you could help me with how I should write my gdal translate script starting from setting my working directory.


Instructions that come with the data:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:xxxYEAR.nc:BandName OutputFilename.tif

So far:

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 

How do I translate (extract) multiband netCDF to individual raster geotiff?

I am new to scripting, so I am hoping you could help me with how I should write my gdal translate script starting from setting my working directory.


Instructions that come with the data:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:xxxYEAR.nc:BandName OutputFilename.tif

So far:

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 

There are some other instructions:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

with Year the year : 2016, 2017 or 2018; and BandName one of the following: lccs_class; processed_flag; current_pixel_state; observation_count; change_count.

Format: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:XXX-YEAR.nc:BandName OutputFilename.tif

Example code: gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:LCCS-2018.nc:lccs_class LCCS-2018.tif

added 1114 characters in body
Source Link
Dlan
  • 29
  • 2

How do I translate (extract) multiband netCDF to individual raster geotiff?

I am new to scripting, so I am hoping you could help me with how I should write my gdal translate script starting from setting my working directory.


Instructions that come with the data:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:xxxYEAR.nc:BandName OutputFilename.tif

So far:

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 

How do I translate (extract) multiband netCDF to individual raster geotiff?

I am new to scripting, so I am hoping you could help me with how I should write my gdal translate script starting from setting my working directory.


Instructions that come with the data:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:xxxYEAR.nc:BandName OutputFilename.tif

How do I translate (extract) multiband netCDF to individual raster geotiff?

I am new to scripting, so I am hoping you could help me with how I should write my gdal translate script starting from setting my working directory.


Instructions that come with the data:

The maps can be transformed to the GTiff format using GDAL as follows, replacing Year, Band_Name and Output_Filename with the parameters of interest:

gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te -180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 -t_srs EPSG:4326 NETCDF:xxxYEAR.nc:BandName OutputFilename.tif

So far:

import os, sys # the standard imports

BaseFolder = r'C:\Users\Dlan\Desktop\netCDF_TIFF' # change this to match your data

for FullPath, dirs, files in os.walk(BaseFolder): for ThisFile in files: # iterate the files fN,fE = os.path.splitext(ThisFile) # separate file name and extension if fE.lower() == 'LCCS-2018.nc': # this is a netCDF file, though other extensions might exist # you will need to provide these details or ascertain them from # the input NetCDF file name.

        Year = '2018'
        Band = 'lccs_class'
        OutputName = 'LCCS-2018'

       
        GDAL_Command = 'gdalwarp -of Gtiff -co COMPRESS=LZW -co TILED=YES -ot Byte -te '\
                                     '-180.0000000 -90.0000000 180.0000000 90.0000000 -tr 0.002777777777778 0.002777777777778 '\
                                     '-t_srs EPSG:4326 NETCDF:{}YEAR.nc:{} {}.tif'.format( Year, Band, os.path.join(FullPath,OutputName))
        os.system(GDAL_Command) # run the command 
edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
Loading
deleted 82 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
Loading
added 431 characters in body
Source Link
Dlan
  • 29
  • 2
Loading
Source Link
Dlan
  • 29
  • 2
Loading