1r.in.gdal(1) Grass User's Manual r.in.gdal(1)
2
3
4
6 r.in.gdal - Imports raster data into a GRASS raster map using GDAL
7 library.
8
10 raster, import, create location
11
13 r.in.gdal
14 r.in.gdal --help
15 r.in.gdal [-ojeflakcrp] input=name output=name [band=integer[,inte‐
16 ger,...]] [memory=integer] [target=name] [title=phrase] [off‐
17 set=integer] [num_digits=integer] [map_names_file=name] [loca‐
18 tion=name] [table=file] [gdal_config=string] [gdal_doo=string]
19 [--overwrite] [--help] [--verbose] [--quiet] [--ui]
20
21 Flags:
22 -o
23 Override projection check (use current location’s projection)
24 Assume that the dataset has same projection as the current location
25
26 -j
27 Perform projection check only and exit
28
29 -e
30 Extend region extents based on new dataset
31 Also updates the default region if in the PERMANENT mapset
32
33 -f
34 List supported formats and exit
35
36 -l
37 Force Lat/Lon maps to fit into geographic coordinates (90N,S;
38 180E,W)
39
40 -a
41 Auto-adjustment for lat/lon
42 Attempt to fix small precision errors in resolution and extents
43
44 -k
45 Keep band numbers instead of using band color names
46
47 -c
48 Create the location specified by the "location" parameter and exit.
49 Do not import the raster file.
50
51 -r
52 Limit import to the current region
53
54 -p
55 Print number of bands and exit
56
57 --overwrite
58 Allow output files to overwrite existing files
59
60 --help
61 Print usage summary
62
63 --verbose
64 Verbose module output
65
66 --quiet
67 Quiet module output
68
69 --ui
70 Force launching GUI dialog
71
72 Parameters:
73 input=name [required]
74 Name of raster file to be imported
75
76 output=name [required]
77 Name for output raster map
78
79 band=integer[,integer,...]
80 Band(s) to select (default is all bands)
81
82 memory=integer
83 Maximum memory to be used (in MB)
84 Cache size for raster rows
85 Default: 300
86
87 target=name
88 Name of GCPs target location
89 Name of location to create or to read projection from for GCPs
90 transformation
91
92 title=phrase
93 Title for resultant raster map
94
95 offset=integer
96 Offset to be added to band numbers
97 If 0, no offset is added and the first band is 1
98 Default: 0
99
100 num_digits=integer
101 Zero-padding of band number by filling with leading zeros up to
102 given number
103 If 0, length will be adjusted to ’offset’ number without leading
104 zeros
105 Default: 0
106
107 map_names_file=name
108 Name of the output file that contains the imported map names
109
110 location=name
111 Name for new location to create
112
113 table=file
114 File prefix for raster attribute tables
115 The band number and ".csv" will be appended to the file prefix
116
117 gdal_config=string
118 GDAL configuration options
119 Comma-separated list of key=value pairs
120
121 gdal_doo=string
122 GDAL dataset open options
123 Comma-separated list of key=value pairs
124
126 r.in.gdal allows a user to create a GRASS GIS raster map layer, or
127 imagery group, from any GDAL supported raster map format, with an
128 optional title. The imported file may also be optionally used to create
129 a new location.
130
131 GDAL supported raster formats
132 Full details on all GDAL supported formats are available at:
133
134 http://www.gdal.org/formats_list.html
135
136 Selected formats out of the more than 140 supported formats:
137 Long Format Name Code Creation Georeferencing Maximum file size
138 ---------------------------------------------+-------------+----------+--------------+-----------------
139 ADRG/ARC Digitilized Raster Graphics ADRG Yes Yes --
140 Arc/Info ASCII Grid AAIGrid Yes Yes 2GB
141 Arc/Info Binary Grid (.adf) AIG No Yes --
142 Arc/Info Export E00 GRID E00GRID No Yes --
143 ArcSDE Raster SDE No Yes --
144 ASCII Gridded XYZ XYZ Yes Yes --
145 BSB Nautical Chart Format (.kap) BSB No Yes --
146 CEOS (Spot for instance) CEOS No No --
147 DB2 DB2 Yes Yes No limits
148 DODS / OPeNDAP DODS No Yes --
149 EarthWatch/DigitalGlobe .TIL TIL No No --
150 ENVI .hdr Labelled Raster ENVI Yes Yes No limits
151 Envisat Image Product (.n1) ESAT No No --
152 EOSAT FAST Format FAST No Yes --
153 Epsilon - Wavelet compressed images EPSILON Yes No --
154 Erdas 7.x .LAN and .GIS LAN No Yes 2GB
155 ERDAS Compressed Wavelets (.ecw) ECW Yes Yes
156 Erdas Imagine (.img) HFA Yes Yes No limits
157 Erdas Imagine Raw EIR No Yes --
158 ERMapper (.ers) ERS Yes Yes
159 ESRI .hdr Labelled EHdr Yes Yes No limits
160 EUMETSAT Archive native (.nat) MSGN No Yes
161 FIT FIT Yes No --
162 FITS (.fits) FITS Yes No --
163 Fuji BAS Scanner Image FujiBAS No No --
164 GDAL Virtual (.vrt) VRT Yes Yes --
165 Generic Binary (.hdr Labelled) GENBIN No No --
166 GeoPackage GPKG Yes Yes No limits
167 Geospatial PDF PDF Yes Yes --
168 GMT Compatible netCDF GMT Yes Yes 2GB
169 Golden Software Surfer 7 Binary Grid GS7BG Yes Yes 4GiB
170 Graphics Interchange Format (.gif) GIF Yes No 2GB
171 GRASS Raster Format GRASS No Yes --
172 GSat File Format GFF No No --
173 Hierarchical Data Format Release 4 (HDF4) HDF4 Yes Yes 2GiB
174 Hierarchical Data Format Release 5 (HDF5) HDF5 No Yes 2GiB
175 Idrisi Raster RST Yes Yes No limits
176 ILWIS Raster Map (.mpr,.mpl) ILWIS Yes Yes --
177 Image Display and Analysis (WinDisp) IDA Yes Yes 2GB
178 In Memory Raster MEM Yes Yes
179 Intergraph Raster INGR Yes Yes 2GiB
180 IRIS IRIS No Yes --
181 Japanese DEM (.mem) JDEM No Yes --
182 JAXA PALSAR Product Reader (Level 1.1/1.5) JAXAPALSAR No No --
183 JPEG2000 (.jp2, .j2k) JP2OpenJPEG Yes Yes
184 JPEG JFIF (.jpg) JPEG Yes Yes 4GiB
185 KMLSUPEROVERLAY KMLSUPEROVERLAY Yes Yes
186 MBTiles MBTiles Yes Yes --
187 Meta Raster Format MRF Yes Yes --
188 Meteosat Second Generation MSG No Yes
189 MG4 Encoded Lidar MG4Lidar No Yes --
190 Microsoft Windows Device Independent Bitmap BMP Yes Yes 4GiB
191 Military Elevation Data (.dt0, .dt1, .dt2) DTED Yes Yes --
192 Multi-resolution Seamless Image Database MrSID No Yes --
193 NASA Planetary Data System PDS No Yes --
194 NetCDF netCDF Yes Yes 2GB
195 Netpbm (.ppm,.pgm) PNM Yes No No limits
196 NITF NITF Yes Yes 10GB
197 NLAPS Data Format NDF No Yes No limits
198 NOAA NGS Geoid Height Grids NGSGEOID No Yes
199 NOAA Polar Orbiter Level 1b Data Set (AVHRR) L1B No Yes --
200 OGC Web Coverage Service WCS No Yes --
201 OGC Web Map Service, and TMS, WorldWind, On EaWMS No Yes --
202 OGC Web Map Tile Service WMTS No Yes --
203 OGDI Bridge OGDI No Yes --
204 Oracle Spatial GeoRaster GEORASTER Yes Yes No limits
205 OziExplorer .MAP MAP No Yes --
206 OZI OZF2/OZFX3 OZI No Yes --
207 PCI Geomatics Database File PCIDSK Yes Yes No limits
208 PCRaster PCRaster Yes Yes
209 Planet Labs Mosaics API PLMosaic No Yes --
210 Portable Network Graphics (.png) PNG Yes No
211 PostGIS Raster (previously WKTRaster) PostGISRaster No Yes --
212 RadarSat2 XML (product.xml) RS2 No Yes 4GB
213 Rasdaman RASDAMAN No No No limits
214 Rasterlite - Rasters in SQLite DB Rasterlite Yes Yes --
215 Raster Product Format/RPF (CADRG, CIB) RPFTOC No Yes --
216 R Object Data Store R Yes No --
217 ROI_PAC Raster ROI_PAC Yes Yes --
218 R Raster (.grd) RRASTER No Yes --
219 SAGA GIS Binary format SAGA Yes Yes --
220 SAR CEOS SAR_CEOS No Yes --
221 Sentinel 1 SAR SAFE (manifest.safe) SAFE No Yes No limits
222 Sentinel 2 SENTINEL2 No Yes No limits
223 SGI Image Format SGI Yes Yes --
224 SRTM HGT Format SRTMHGT Yes Yes --
225 TerraSAR-X Complex SAR Data Product COSAR No No --
226 TerraSAR-X Product TSX Yes No --
227 TIFF / BigTIFF / GeoTIFF (.tif) GTiff Yes Yes 4GiB/None for BigTIFF
228 USGS ASCII DEM / CDED (.dem) USGSDEM Yes Yes --
229 USGS Astrogeology ISIS cube (Version 3) ISIS3 No Yes --
230 USGS SDTS DEM (*CATD.DDF) SDTS No Yes --
231 Vexcel MFF MFF Yes Yes No limits
232 VICAR VICAR No Yes --
233 VTP Binary Terrain Format (.bt) BT Yes Yes --
234 WEBP WEBP Yes No --
235 WMO GRIB1/GRIB2 (.grb) GRIB No Yes 2GB
236
237 Location Creation
238 r.in.gdal attempts to preserve projection information when importing
239 datasets if the source format includes projection information, and if
240 the GDAL driver supports it. If the projection of the source dataset
241 does not match the projection of the current location r.in.gdal will
242 report an error message (Projection of dataset does not appear to match
243 current location) and then report the PROJ_INFO parameters of the
244 source dataset.
245
246 If the user wishes to ignore the difference between the apparent coor‐
247 dinate system of the source data and the current location, they may
248 pass the -o flag to override the projection check.
249
250 If the user wishes to import the data with the full projection defini‐
251 tion, it is possible to have r.in.gdal automatically create a new loca‐
252 tion based on the projection and extents of the file being read. This
253 is accomplished by passing the name to be used for the new location via
254 the location parameter. Upon completion of the command, a new location
255 will have been created (with only a PERMANENT mapset), and the raster
256 will have been imported with the indicated output name into the PERMA‐
257 NENT mapset.
258
259 Support for GCPs
260 In case the image contains GCPs they are written to a POINTS file
261 within an imagery group. They can directly be used for i.rectify.
262
263 The target option allows you to automatically re-project the GCPs from
264 their own projection into another projection read from the PROJ_INFO
265 file of the location name target.
266
267 If the target location does not exist, a new location will be created
268 matching the projection definition of the GCPs. The target of the out‐
269 put group will be set to the new location, and i.rectify can now be
270 used without any further preparation.
271
272 Some satellite images (e.g. NOAA/AVHRR, ENVISAT) can contain hundreds
273 or thousands of GCPs. In these cases thin plate spline coordinate
274 transformation is recommended, either before import with gdalwarp -tps
275 or after import with i.rectify -t.
276
277 Map names: Management of offset and leading zeros
278 The offset parameter allows adding an offset to band number(s) which is
279 convenient in case of the import of e.g. a continuous time series split
280 across different input files.
281
282 The num_digits parameter allows defining the number of leading zeros
283 (zero padding) in case of band numbers (e.g., to turn band.1 into
284 band.001).
285
287 Import of large files can be significantly faster when setting memory
288 to the size of the input file.
289
290 The r.in.gdal command does support the following features, as long as
291 the underlying format driver supports it:
292
293 Color Table
294 Bands with associated colortables will have the color tables trans‐
295 ferred. Note that if the source has no colormap, r.in.gdal in
296 GRASS 5.0 will emit no colormap. Use r.colors map=... color=grey
297 to assign a greyscale colormap. In a future version of GRASS
298 r.in.gdal will likely be upgraded to automatically emit greyscale
299 colormaps.
300
301 Data Types
302 Most GDAL data types are supported. Float32 and Float64 type bands
303 are translated as GRASS floating point cells (but not double preci‐
304 sion ... this could be added if needed), and most other types are
305 translated as GRASS integer cells. This includes 16bit integer
306 data sources. Complex (some SAR signal data formats) data bands
307 are translated to two floating point cell layers (*.real and
308 *.imaginary).
309
310 Georeferencing
311 If the dataset has affine georeferencing information, this will be
312 used to set the north, south, east and west edges. Rotational
313 coefficients will be ignored, resulting in incorrect positioning
314 for rotated datasets.
315
316 Projection
317 The datasets projection will be used to compare to the current
318 location or to define a new location. Internally GDAL represents
319 projections in OpenGIS Well Known Text format. A large subset of
320 the total set of GRASS projections are supported.
321
322 Null Values
323 Raster bands for which a null value is recognised by GDAL will have
324 the null pixels transformed into GRASS style nulls during import.
325 Many generic formats (and formats poorly supported by GDAL) do not
326 have a way of recognising null pixels in which case r.null should
327 be used after the import.
328
329 GCPs
330 Datasets that have Ground Control Points will have them imported as
331 a POINTS file associated with the imagery group. Datasets with
332 only one band that would otherwise have been translated as a simple
333 raster map will also have an associated imagery group if there are
334 ground control points. The coordinate system of the ground control
335 points is reported by r.in.gdal but not preserved. It is up to the
336 user to ensure that the location established with i.target has a
337 compatible coordinate system before using the points with i.rec‐
338 tify.
339
340 Raster Attribute Tables
341 r.in.gdal can write out raster attribute tables as CSV files.
342 Moreover, information in raster attribute tables is automatically
343 imported as long as the field definitions contain information about
344 how to use a field, e.g. for color information or for labels.
345
346 Planned improvements to r.in.gdal in the future include support for
347 reporting everything known about a dataset if the output parameter is
348 not set.
349
350 Error Messages
351 "ERROR: Input map is rotated - cannot import."
352 In this case the image must be first externally rotated, applying the
353 rotation info stored in the metadata field of the raster image file.
354 For example, the gdalwarp software can be used to transform the map to
355 North-up (note, there are several gdalwarp parameters to select the
356 resampling algorithm):
357 gdalwarp rotated.tif northup.tif
358
359 "ERROR: Projection of dataset does not appear to match the current
360 location."
361 You need to create a location whose projection matches the data you
362 wish to import. Try using location parameter to create a new location
363 based upon the projection information in the file. If desired, you can
364 then re-project it to another location with r.proj. Alternatively you
365 can override this error by using the -o flag.
366
367 "WARNING: G_set_window(): Illegal latitude for North"
368 Latitude/Longitude locations in GRASS can not have regions which exceed
369 90° North or South. Non-georeferenced imagery will have coordinates
370 based on the images’s number of pixels: 0,0 in the bottom left;
371 cols,rows in the top right. Typically imagery will be much more than 90
372 pixels tall and so the GIS refuses to import it. If you are sure that
373 the data is appropriate for your Lat/Lon location and intentd to reset
374 the map’s bounds with the r.region module directly after import you may
375 use the -l flag to constrain the map coordinates to legal values.
376 While the resulting bounds and resolution will likely be wrong for your
377 map the map’s data will be unaltered and safe. After resetting to known
378 bounds with r.region you should double check them with r.info, paying
379 special attention to the map resolution. In most cases you will want to
380 import into the datafile’s native projection, or into a simple XY loca‐
381 tion and use the Georectifaction tools (i.rectify et al.) to properly
382 project into the target location. The -l flag should only be used if
383 you know the projection is correct but the internal georeferencing has
384 gotten lost, and you know the what the map’s bounds and resolution
385 should be beforehand.
386
388 ECAD Data
389 The European Climate Assessment and Dataset (ECAD) project provides
390 climate data for Europe ranging from 1950 - 2015 or later (Terms of
391 use). To import the different chunks of data provided by the project
392 as netCDF files, the offset parameter can be used to properly assign
393 numbers to the series of daily raster maps from 1st Jan 1950 (in case
394 of importing the ECAD data split into multi-annual chunks). The ECAD
395 data must be imported into a LatLong location.
396
397 By using the num_digits parameter leading zeros are added to the map
398 name numbers, allowing for chronological numbering of the imported
399 raster map layers, so that g.list lists them in the correct order.
400 Here, use num_digits=5 to have a 5 digit suffix with leading zeros
401 (00001 - 99999).
402 # Import of ECAD data split into chunks
403 # Import precipitation data
404 r.in.gdal -o input=rr_0.25deg_reg_1950-1964_v12.0.nc output=precipitation num_digits=5 offset=0
405 r.in.gdal -o input=rr_0.25deg_reg_1965-1979_v12.0.nc output=precipitation num_digits=5 offset=5479
406 r.in.gdal -o input=rr_0.25deg_reg_1980-1994_v12.0.nc output=precipitation num_digits=5 offset=10957
407 r.in.gdal -o input=rr_0.25deg_reg_1995-2015_v12.0.nc output=precipitation num_digits=5 offset=16436
408 # Import air pressure data
409 r.in.gdal -o input=pp_0.25deg_reg_1950-1964_v12.0.nc output=air_pressure num_digits=5 offset=0
410 r.in.gdal -o input=pp_0.25deg_reg_1965-1979_v12.0.nc output=air_pressure num_digits=5 offset=5479
411 r.in.gdal -o input=pp_0.25deg_reg_1980-1994_v12.0.nc output=air_pressure num_digits=5 offset=10957
412 r.in.gdal -o input=pp_0.25deg_reg_1995-2015_v12.0.nc output=air_pressure num_digits=5 offset=16436
413 # Import min temperature data
414 r.in.gdal -o input=tn_0.25deg_reg_1950-1964_v12.0.nc output=temperatur_min num_digits=5 offset=0
415 r.in.gdal -o input=tn_0.25deg_reg_1965-1979_v12.0.nc output=temperatur_min num_digits=5 offset=5479
416 r.in.gdal -o input=tn_0.25deg_reg_1980-1994_v12.0.nc output=temperatur_min num_digits=5 offset=10957
417 r.in.gdal -o input=tn_0.25deg_reg_1995-2015_v12.0.nc output=temperatur_min num_digits=5 offset=16436
418 # Import max temperature data
419 r.in.gdal -o input=tx_0.25deg_reg_1950-1964_v12.0.nc output=temperatur_max num_digits=5 offset=0
420 r.in.gdal -o input=tx_0.25deg_reg_1965-1979_v12.0.nc output=temperatur_max num_digits=5 offset=5479
421 r.in.gdal -o input=tx_0.25deg_reg_1980-1994_v12.0.nc output=temperatur_max num_digits=5 offset=10957
422 r.in.gdal -o input=tx_0.25deg_reg_1995-2015_v12.0.nc output=temperatur_max num_digits=5 offset=16436
423 # Import mean temperature data
424 r.in.gdal -o input=tg_0.25deg_reg_1950-1964_v12.0.nc output=temperatur_mean num_digits=5 offset=0
425 r.in.gdal -o input=tg_0.25deg_reg_1965-1979_v12.0.nc output=temperatur_mean num_digits=5 offset=5479
426 r.in.gdal -o input=tg_0.25deg_reg_1980-1994_v12.0.nc output=temperatur_mean num_digits=5 offset=10957
427 r.in.gdal -o input=tg_0.25deg_reg_1995-2015_v12.0.nc output=temperatur_mean num_digits=5 offset=16436
428
429 GTOPO30 DEM
430 To avoid that the GTOPO30 data are read incorrectly, you can add a new
431 line "PIXELTYPE SIGNEDINT" in the .HDR to force interpretation of the
432 file as signed rather than unsigned integers. Then the .DEM file can be
433 imported. Finally, e.g. the ’terrain’ color table can be assigned to
434 the imported map with r.colors.
435
436 GLOBE DEM
437 To import GLOBE DEM tiles (approx 1km resolution, better than GTOPO30
438 DEM data), the user has to download additionally the related HDR
439 file(s). Finally, e.g. the ’terrain’ color table can be assigned to
440 the imported map with r.colors. See also their DEM portal.
441
442 Raster file import over network
443 Since GDAL 2.x it is possible to import raster data over network (see
444 GDAL Virtual File Systems) including Cloud Optimized GeoTIFF, i.e.
445 access uncompressed and compressed raster data via a http(s) or ftp
446 connection. As an example the import of the global SRTMGL1 V003 tiles
447 at 1 arc second (about 30 meters) resolution, void-filled:
448 r.in.gdal /vsicurl/https://www.datenatlas.de/geodata/public/srtmgl1/srtmgl1.003.tif output=srtmgl1_v003_30m memory=2000
449 g.region raster=srtmgl1_v003_30m -p
450 r.colors srtmgl1_v003_30m color=srtm_plus
451
452 Worldclim.org data
453 To import the BIL data from Worldclim, the following line has to be
454 added to each .hdr file:
455 PIXELTYPE SIGNEDINT
456
457 To import the ESRI Grd data from Worldclim, the broken spatial extent
458 (exceeding the boundaries) needs to be fixed prior to import:
459 # example: tmean dataset
460 gdal_translate -a_ullr -180 90 180 -60 tmean_1 tmean_1_fixed.tif
461 r.in.gdal input=tmean_1_fixed.tif output=tmean_1
462
463 HDF
464 The import of HDF bands requires the specification of the individual
465 bands as seen by GDAL:
466 # Example MODIS FPAR
467 gdalinfo MOD15A2.A2003153.h18v04.004.2003171141042.hdf
468 ...
469 Subdatasets:
470 SUBDATASET_1_NAME=HDF4_EOS:EOS_GRID:"MOD15A2.A2003153.h18v04.004.2003171141042.hdf":MOD_Grid_MOD15A2:Fpar_1km
471 SUBDATASET_1_DESC=[1200x1200] Fpar_1km MOD_Grid_MOD15A2 (8-bit unsigned integer)
472 SUBDATASET_2_NAME=HDF4_EOS:EOS_GRID:"MOD15A2.A2003153.h18v04.004.2003171141042.hdf":MOD_Grid_MOD15A2:Lai_1km
473 SUBDATASET_2_DESC=[1200x1200] Lai_1km MOD_Grid_MOD15A2 (8-bit unsigned integer)
474 ...
475 # import of first band, here FPAR 1km:
476 r.in.gdal HDF4_EOS:EOS_GRID:"MOD15A2.A2003153.h18v04.004.2003171141042.hdf":MOD_Grid_MOD15A2:Fpar_1km \
477 out=fpar_1km_2003_06_02
478 # ... likewise for other HDF bands in the file.
479
481 r.colors, r.import, r.in.ascii, r.in.bin, r.null, t.register
482
483 GRASS GIS Wiki page: Import of Global datasets
484
486 GDAL Pages: http://www.gdal.org/
487
489 Frank Warmerdam (email).
490
491 Last changed: $Date: 2018-09-24 16:54:20 +0200 (Mon, 24 Sep 2018) $
492
494 Available at: r.in.gdal source code (history)
495
496 Main index | Raster index | Topics index | Keywords index | Graphical
497 index | Full index
498
499 © 2003-2019 GRASS Development Team, GRASS GIS 7.6.0 Reference Manual
500
501
502
503GRASS 7.6.0 r.in.gdal(1)