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