Opened 15 years ago

Last modified 5 years ago

#798 new enhancement

r.in.gdal : subdataset handling

Reported by: rouault Owned by: grass-dev@…
Priority: normal Milestone: 7.8.3
Component: Raster Version: unspecified
Keywords: r.in.gdal Cc:
CPU: All Platform: All

Description

Transfering GDAL's http://trac.osgeo.org/gdal/ticket/486 ticket here as being the more appropriate place :

1) If a raster has zero raster bands, error out with a brief explanation 
   instead of trying to fetch band zero and crashing. 

2) If a file has subdataset metadata, provide an option to list the subdatasets.
Minimally provide the datasetnames that would be needed to use to import them.
Ideally offer a commandline option to import all sub-datasets.

Change History (12)

comment:1 by martinl, 15 years ago

Milestone: 6.5.0

comment:2 by hamish, 12 years ago

Component: DefaultRaster
CPU: UnspecifiedAll
Keywords: r.in.gdal added
Platform: UnspecifiedAll

would be nice. :)

Perhaps easier is a wrapper GUI tool around gdalinfo's output?

Hamish

comment:3 by Nikos Alexandris, 11 years ago

Would "include" any kind of mutli-container, i.e. HDF or NITF files?

in reply to:  3 comment:4 by hamish, 11 years ago

Replying to hamish:

would be nice. :) Perhaps easier is a wrapper GUI tool around gdalinfo's output?

Replying to nikosa:

Would "include" any kind of mutli-container, i.e. HDF or NITF files?

any format supported by the installed GDAL...

Hamish

comment:5 by marisn, 6 years ago

Milestone: 6.5.07.8.0

GRASS 6.5 has EOLed, but this wish is still not implemented. r.in.gdal does not crash if subdatasets are present and prints a warning, but still there is no option to print subdatasets.

A new flag ("-s"?) should be introduced to print subdataset identifiers suitable for passing to input. It should work together with "-p" flag. "-s" "-p" combination should print all subdatasets with all their bands.

A new input option "subdataset" should be introduced. It should accept integer to indicate subdataset number for import (see gdalinfo output for numbers). It would allow to import subdatasets without specifying them in input parameter thus greatly simplifying work with subdatasets.

comment:6 by mmetz, 6 years ago

In 74373:

r.in.gdal: +info on subdatasets, see #798

in reply to:  5 ; comment:7 by mmetz, 6 years ago

Replying to marisn:

GRASS 6.5 has EOLed, but this wish is still not implemented. r.in.gdal does not crash if subdatasets are present and prints a warning, but still there is no option to print subdatasets.

Subdatasets are now (trunk r74373) printed if present, no flag needed.

Related but independent of that, import fails early if no raster bands are found.

A new input option "subdataset" should be introduced. It should accept integer to indicate subdataset number for import (see gdalinfo output for numbers). It would allow to import subdatasets without specifying them in input parameter thus greatly simplifying work with subdatasets.

What exactly is the advantage of another new option "subdataset" instead of providing the name of the subdataset to be imported? In any case, you need to read the names and descriptions of the available subdatasets first.

in reply to:  7 comment:8 by marisn, 6 years ago

Replying to mmetz:

Subdatasets are now (trunk r74373) printed if present, no flag needed.

Thanks. Still I am not certain if printing anything more than a warning should not be done only on a request. Let it stay like this unless someone can show an use case where it would be a bad thing.

Related but independent of that, import fails early if no raster bands are found.

This is a good question. If no bands are specified, all bands are imported. Following this logic, all subdatasets should be imported. Still I do understand why it could be a bad idea ;-)

What exactly is the advantage of another new option "subdataset" instead of providing the name of the subdataset to be imported? In any case, you need to read the names and descriptions of the available subdatasets first.

The names of subdatasets can be really verbose and thus hard to handle. Besides, subdatasets are not supported in r.import. Such option would make it a bit easier to implement it.

Here's an example of how import of subdataset looks like now (yes, thats 208 symbols for a subdataset name and 251 symbol for whole import command and that's without any extras!):

r.in.gdal input=/home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip output=S2A_MSIL2A_20180413
WARNING: Input contains subdatasets which may need to be imported
         separately by name:
Subdataset 1:
  Name: SENTINEL2_L2A:/vsizip//home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.SAFE/MTD_MSIL2A.xml:10m:EPSG_32634
Subdataset 3:
  Name: SENTINEL2_L2A:/vsizip//home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.SAFE/MTD_MSIL2A.xml:20m:EPSG_32634
Subdataset 5:
  Name: SENTINEL2_L2A:/vsizip//home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.SAFE/MTD_MSIL2A.xml:60m:EPSG_32634
Subdataset 7:
  Name: SENTINEL2_L2A:/vsizip//home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.SAFE/MTD_MSIL2A.xml:TCI:EPSG_32634
ERROR: No raster bands found in
       </home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip>

r.in.gdal input=SENTINEL2_L2A:/vsizip//home/marisn/data/S2_2018/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.zip/S2A_MSIL2A_20180413T095031_N0207_R079_T34VFH_20180413T102702.SAFE/MTD_MSIL2A.xml:10m:EPSG_32634 output=S2A_MSIL2A_20180413

Besides the import works easy only form CLI, as in GUI simple copy/paste contains line wrapping symbols that need to be removed first. Thus being able to provide an option subdataset=1,3 would make it short and easy (1st run – get a list of subdatasets; add subdataset number(s); 2nd run to finish import). Subdataset option, of course, would not conflict with specifying subdataset name directly as input parameter thus keeping current functionality unchanged.

comment:9 by neteler, 5 years ago

Milestone: 7.8.07.8.1

Ticket retargeted after milestone closed

comment:10 by neteler, 5 years ago

Milestone: 7.8.17.8.2

Ticket retargeted after milestone closed

comment:11 by neteler, 5 years ago

Milestone: 7.8.2

Ticket retargeted after milestone closed

comment:12 by neteler, 5 years ago

Milestone: 7.8.3
Note: See TracTickets for help on using tickets.