[GRASS-dev] [GRASS GIS] #2055: r.in.gdal lacks flag "-r Limit import to the current region"

GRASS GIS trac at osgeo.org
Thu Sep 15 08:18:37 PDT 2016


#2055: r.in.gdal lacks flag "-r Limit import to the current region"
--------------------------+---------------------------------
  Reporter:  neteler      |      Owner:  grass-dev@…
      Type:  enhancement  |     Status:  new
  Priority:  normal       |  Milestone:  7.2.0
 Component:  Raster       |    Version:  svn-trunk
Resolution:               |   Keywords:  r.in.gdal, r.import
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+---------------------------------

Comment (by neteler):

 Replying to [comment:14 martinl]:
 > Replying to [comment:13 neteler]:
 > > The solution would be "lazy cutting", that is not cutting sharp to the
 boundary but allow for a small "extra". Essentially, like v.in.ogr
 behaves. Resampling is definitely undesired since we usually import as-is
 in r.in.gdal.
 > >
 > > Lines to look at:
 > >
 https://trac.osgeo.org/grass/browser/grass/trunk/raster/r.in.gdal/main.c#L359
 >
 > Please try out attachment:r_in_gdal_2055.diff

 Thank you for that!

 {{{
 # current region setting at 200m res
 GRASS 7.2.svn (eu_laea):~ > g.region -g
 projection=99
 zone=0
 n=3554400
 s=2680400
 w=4025000
 e=4678400
 nsres=200
 ewres=200
 rows=4370
 cols=3267
 cells=14276790

 # input map is larger:
 gdalinfo EUD_CP-DEMS_4500025000-AA.tif
 ...
 Corner Coordinates:
 Upper Left  ( 4000000.000, 3000000.000) (  5d31' 4.07"E, 50d 1'26.83"N)
 Lower Left  ( 4000000.000, 2000000.000) (  6d11'52.97"E, 41d 1'36.49"N)
 Upper Right ( 5000000.000, 3000000.000) ( 19d26'39.40"E, 49d43' 8.38"N)
 Lower Right ( 5000000.000, 2000000.000) ( 18d 1'22.97"E, 40d46'27.19"N)
 Center      ( 4500000.000, 2500000.000) ( 12d17'27.23"E, 45d35'15.84"N)


 # import of 25m EU LAEA DEM with -r
 GRASS 7.3.svn (eu_laea): > r.in.gdal -r EUD_CP-DEMS_4500025000-AA.tif
 out=test
 ...
 (1000,-21180) of size 26137x1 on raster of 40000x40000.
 ERROR 5: EUD_CP-DEMS_4500025000-AA.tif, band 1: Access window out of range
 in RasterIO().  Requested
 (1000,-21179) of size 26137x1 on raster of 40000x40000.
 ERROR 5: EUD_CP-DEMS_4500025000-AA.tif, band 1: Access window out of range
 in RasterIO().  Requested
 (1000,-21178) of size 26137x1 on raster of 40000x40000.
 ERROR 5: EUD_CP-DEMS_4500025000-AA.tif, band 1: Access window out of range
 in RasterIO().  Requested
 (1000,-21177) of size 26137x1 on raster of 40000x40000.
 More than 1000 errors or warnings have been reported. No more will be
 reported from now.
   39%
 ...
  100%

 # resulting map is at 25m as expected
 GRASS 7.2.svn (eu_laea):~ > r.info -g test
 north=3554400
 south=2680375
 east=4678425
 west=4025000
 nsres=25
 ewres=25
 rows=34961
 cols=26137
 cells=913775657
 datatype=FCELL
 ncats=0

 # verification
 GRASS 7.2.svn (eu_laea): > r.external EUD_CP-DEMS_4500025000-AA.tif
 output=original
 r.info -g original
 north=3000000
 south=2000000
 east=5000000
 west=4000000
 nsres=25
 ewres=25
 rows=40000
 cols=40000
 cells=1600000000
 datatype=FCELL
 ncats=0

 ###########
 # stats
 r.univar original
 total null and non-null cells: 913775657
 total null cells: 579614112
 ...

 r.univar test
 total null and non-null cells: 913775657
 total null cells: 0
 }}}

 Looks like a very good start!

 Two issues:
  * bug: it does not write NULL but 0 if the current region is not full
 covered. Perhaps some NULL initialization is yet missing?
  * better suppress the GDAL messages

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2055#comment:15>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list