Opened 10 years ago

Last modified 9 days ago

#798 new enhancement

r.in.gdal : subdataset handling

Reported by: rouault Owned by: grass-dev@…
Priority: normal Milestone: 7.8.2
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 (10)

comment:1 Changed 10 years ago by martinl

Milestone: 6.5.0

comment:2 Changed 7 years ago by hamish

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 Changed 6 years ago by Nikos Alexandris

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

comment:4 in reply to:  3 Changed 6 years ago by hamish

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 Changed 7 months ago by marisn

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 Changed 7 months ago by mmetz

In 74373:

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

comment:7 in reply to:  5 ; Changed 7 months ago by mmetz

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.

comment:8 in reply to:  7 Changed 7 months ago by marisn

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 Changed 2 months ago by neteler

Milestone: 7.8.07.8.1

Ticket retargeted after milestone closed

comment:10 Changed 9 days ago by neteler

Milestone: 7.8.17.8.2

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.