1r.import(1) GRASS GIS User's Manual r.import(1)
2
3
4
6 r.import - Imports raster data into a GRASS raster map using GDAL li‐
7 brary and reprojects on the fly.
8
10 raster, import, projection
11
13 r.import
14 r.import --help
15 r.import [-enlo] input=name [band=integer[,integer,...]] [mem‐
16 ory=memory in MB] [output=name] [resample=string] [extent=string]
17 [resolution=string] [resolution_value=float] [title=phrase]
18 [--overwrite] [--help] [--verbose] [--quiet] [--ui]
19
20 Flags:
21 -e
22 Estimate resolution only
23
24 -n
25 Do not perform region cropping optimization
26
27 -l
28 Force Lat/Lon maps to fit into geographic coordinates (90N,S;
29 180E,W)
30
31 -o
32 Override projection check (use current location’s projection)
33 Assume that the dataset has the same projection as the current lo‐
34 cation
35
36 --overwrite
37 Allow output files to overwrite existing files
38
39 --help
40 Print usage summary
41
42 --verbose
43 Verbose module output
44
45 --quiet
46 Quiet module output
47
48 --ui
49 Force launching GUI dialog
50
51 Parameters:
52 input=name [required]
53 Name of GDAL dataset to be imported
54
55 band=integer[,integer,...]
56 Input band(s) to select (default is all bands)
57
58 memory=memory in MB
59 Maximum memory to be used (in MB)
60 Cache size for raster rows
61 Default: 300
62
63 output=name
64 Name for output raster map
65
66 resample=string
67 Resampling method to use for reprojection
68 Options: nearest, bilinear, bicubic, lanczos, bilinear_f, bicu‐
69 bic_f, lanczos_f
70 Default: nearest
71 nearest: nearest neighbor
72 bilinear: bilinear interpolation
73 bicubic: bicubic interpolation
74 lanczos: lanczos filter
75 bilinear_f: bilinear interpolation with fallback
76 bicubic_f: bicubic interpolation with fallback
77 lanczos_f: lanczos filter with fallback
78
79 extent=string
80 Output raster map extent
81 Options: input, region
82 Default: input
83 input: extent of input map
84 region: extent of current region
85
86 resolution=string
87 Resolution of output raster map (default: estimated)
88 Options: estimated, value, region
89 Default: estimated
90 estimated: estimated resolution
91 value: user-specified resolution
92 region: current region resolution
93
94 resolution_value=float
95 Resolution of output raster map (use with option resolution=value)
96
97 title=phrase
98 Title for resultant raster map
99
101 r.import imports a map or selected bands from a GDAL raster datasource
102 into the current location and mapset. If the projection of the input
103 does not match the projection of the location, the input is reprojected
104 into the current location. If the projection of the input does match
105 the projection of the location, the input is imported directly with
106 r.in.gdal.
107
109 r.import checks the projection metadata of the dataset to be imported
110 against the current location’s projection. If not identical a related
111 error message is shown.
112 To override this projection check (i.e. to use current location’s pro‐
113 jection) by assuming that the dataset has the same projection as the
114 current location the -o flag can be used. This is also useful when geo‐
115 data to be imported do not contain any projection metadata at all. The
116 user must be sure that the projection is identical in order to avoid to
117 introduce data errors.
118
119 Resolution
120 r.import reports the estimated target resolution for each input band.
121 The estimated resolution will usually be some floating point number,
122 e.g. 271.301. In case option resolution is set to estimated (default),
123 this floating point number will be used as target resolution. Since the
124 target resolution should be typically the rounded estimated resolution,
125 e.g. 250 or 300 instead of 271.301, flag -e can be used first to obtain
126 the estimate without importing the raster bands. Then the desired res‐
127 olution is set with option resolution_value and option resolu‐
128 tion=value. For latlong locations, the resolution might be set to arc
129 seconds, e.g. 1, 3, 7.5, 15, and 30 arc seconds are commonly used reso‐
130 lutions.
131
132 Resampling methods
133 When reprojecting a map to a new spatial reference system, the pro‐
134 jected data is resampled with one of four different methods: nearest
135 neighbor, bilinear, bicubic interpolation or lanczos.
136
137 In the following, common use cases are:
138
139 nearest is the simplest method and the only possible method for cate‐
140 gorical data.
141
142 bilinear does linear interpolation and provides smoother output than
143 nearest. bilinear is recommended when reprojecting a DEM for hydrologi‐
144 cal analysis or for surfaces where overshoots must be avoided, e.g.
145 precipitation should not become negative.
146
147 bicubic produces smoother output than bilinear, at the cost of over‐
148 shoots. Here, valid pixels that are adjacent to NULL pixels or edge
149 pixels are set to NULL.
150
151 lanczos produces the smoothest output of all methods and preserves con‐
152 trast best. lanczos is recommended for imagery. Both bicubic and lanc‐
153 zos preserve linear features. With nearest or bilinear, linear features
154 can become zigzag features after reprojection.
155
156 In the bilinear, bicubic and lanczos methods, if any of the surrounding
157 cells used to interpolate the new cell value are NULL, the resulting
158 cell will be NULL, even if the nearest cell is not NULL. This will
159 cause some thinning along NULL borders, such as the coasts of land ar‐
160 eas in a DEM. The bilinear_f, bicubic_f and lanczos_f interpolation
161 methods can be used if thinning along NULL edges is not desired. These
162 methods "fall back" to simpler interpolation methods along NULL bor‐
163 ders. That is, from lanczos to bicubic to bilinear to nearest.
164
165 For explanation of the -l flag, please refer to the r.in.gdal manual.
166
167 When importing whole-world maps the user should disable map-trimming
168 with the -n flag. For further explanations of -n flag, please refer the
169 to r.proj manual.
170
172 Import of SRTM V3 global data at 1 arc-seconds resolution
173 The SRTM V3 1 arc-second global data (~30 meters resolution) are avail‐
174 able from EarthExplorer (http://earthexplorer.usgs.gov/). The SRTM
175 collections are located under the "Digital Elevation" category.
176
177 Example for North Carolina sample dataset (the tile name is
178 "n35_w079_1arc_v3.tif"):
179 # set computational region to e.g. 10m elevation model:
180 g.region raster=elevation -p
181 # Import with reprojection on the fly. Recommended parameters:
182 # resample Resampling method to use for reprojection - bilinear
183 # extent Output raster map extent - region: extent of current region
184 # resolution Resolution of output raster map
185 # - region: current region resolution - limit to g.region setting from above
186 r.import input=n35_w079_1arc_v3.tif output=srtmv3_resamp10m resample=bilinear \
187 extent=region resolution=region title="SRTM V3 resampled to 10m resolution"
188 # beautify colors:
189 r.colors srtmv3_resamp10m color=elevation
190
191 Import of WorldClim data
192 Import of a subset from WorldClim Bioclim data set, to be reprojected
193 to current location projection (North Carolina sample dataset). Dif‐
194 ferent resolutions are available, in this example we use the 2.5
195 arc-minutes resolution data. During import, we spatially subset the
196 world data to the North Carolina region using the extent parameter:
197 # download selected Bioclim data (2.5 arc-minutes resolution)
198 # optionally tiles are available for the 30 arc-sec resolution
199 wget http://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/bio_2-5m_bil.zip
200 # extract BIO1 from package (BIO1 = Annual Mean Temperature):
201 unzip bio_2-5m_bil.zip bio1.bil bio1.hdr
202 # prior to import, fix broken WorldClim extent using GDAL tool
203 gdal_translate -a_ullr -180 90 180 -60 bio1.bil bio1_fixed.tif
204 # set computational region to North Carolina, 4000 m target pixel resolution
205 g.region -d res=4000 -ap
206 # subset to current region and reproject on the fly to current location projection,
207 # using -n since whole-world map is imported:
208 r.import input=bio1_fixed.tif output=bioclim01 resample=bilinear \
209 extent=region resolution=region -n
210 # temperature data are in °C * 10
211 r.info bioclim01
212 r.univar -e bioclim01
213
215 r.in.gdal, r.proj
216
218 Markus Metz
219 Improvements: Martin Landa, Anna Petrasova
220
222 Available at: r.import source code (history)
223
224 Accessed: Saturday Oct 28 18:19:20 2023
225
226 Main index | Raster index | Topics index | Keywords index | Graphical
227 index | Full index
228
229 © 2003-2023 GRASS Development Team, GRASS GIS 8.3.1 Reference Manual
230
231
232
233GRASS 8.3.1 r.import(1)