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