Skip to content

Commit 6e03a06

Browse files
committed
updated masking tutorial
1 parent c46a572 commit 6e03a06

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

docs/source/howto/masks.rst

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,36 @@ FORCE comes with a program to generate processing masks from vector data (e.g. s
5353
5454
force-cube -h
5555
56-
Usage: force-cube [-hvirsantobj] input-file(s)
57-
58-
optional:
59-
-h = show this help
60-
-v = show version
61-
-i = show program's purpose
62-
-r = resampling method
63-
any GDAL resampling method for raster data, e.g. cubic (default)
64-
is ignored for vector data
65-
-s = pixel resolution of cubed data, defaults to 10
66-
-a = optional attribute name for vector data. force-cube will burn these values
67-
into the output raster. default: no attribute is used; a binary mask
68-
with geometry presence (1) or absence (0) is generated
69-
-l = layer name for vector data (default: basename of input, without extension)
70-
-n = output nodate value (defaults to 255)
71-
-t = output data type (defaults to Byte; see GDAL for datatypes;
72-
but note that FORCE HLPS only understands Int16 and Byte types correctly)
73-
-o = output directory: the directory where you want to store the cubes
74-
defaults to current directory
75-
'datacube-definition.prj' needs to exist in there
76-
-b = basename of output file (without extension)
77-
defaults to the basename of the input-file
78-
cannot be used when multiple input files are given
79-
-j = number of jobs, defaults to 'as many as possible'
80-
81-
mandatory:
82-
input-file(s) = the file(s) you want to cube
83-
84-
-----
85-
see https://force-eo.readthedocs.io/en/latest/components/auxilliary/cube.html
56+
$ Usage: force-cube [-hvirsantobj] input-file(s)
57+
$
58+
$ optional:
59+
$ -h = show this help
60+
$ -v = show version
61+
$ -i = show program's purpose
62+
$ -r = resampling method
63+
$ any GDAL resampling method for raster data, e.g. cubic (default)
64+
$ is ignored for vector data
65+
$ -s = pixel resolution of cubed data, defaults to 10
66+
$ -a = optional attribute name for vector data. force-cube will burn these values
67+
$ into the output raster. default: no attribute is used; a binary mask
68+
$ with geometry presence (1) or absence (0) is generated
69+
$ -l = layer name for vector data (default: basename of input, without extension)
70+
$ -n = output nodate value (defaults to 255)
71+
$ -t = output data type (defaults to Byte; see GDAL for datatypes;
72+
$ but note that FORCE HLPS only understands Int16 and Byte types correctly)
73+
$ -o = output directory: the directory where you want to store the cubes
74+
$ defaults to current directory
75+
$ 'datacube-definition.prj' needs to exist in there
76+
$ -b = basename of output file (without extension)
77+
$ defaults to the basename of the input-file
78+
$ cannot be used when multiple input files are given
79+
$ -j = number of jobs, defaults to 'as many as possible'
80+
$
81+
$ mandatory:
82+
$ input-file(s) = the file(s) you want to cube
83+
$
84+
$ -----
85+
$ see https://force-eo.readthedocs.io/en/latest/components/auxilliary/cube.html
8686
8787
8888
@@ -100,10 +100,10 @@ In the following example, we generate a processing mask for the administrative a
100100
101101
force-cube -o /data/europe/mask vienna.shp
102102
103-
0...10...20...30...40...50...60...70...80...90...100 - done.
104-
0...10...20...30...40...50...60...70...80...90...100 - done.
105-
0...10...20...30...40...50...60...70...80...90...100 - done.
106-
0...10...20...30...40...50...60...70...80...90...100 - done.
103+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
104+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
105+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
106+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
107107
108108
109109
In this example, Vienna is covered by four tiles, a cubed GeoTiff was generated in each tile:
@@ -112,10 +112,10 @@ In this example, Vienna is covered by four tiles, a cubed GeoTiff was generated
112112
113113
ls /data/europe/mask/X*/vienna.tif
114114
115-
/data/europe/mask/X0077_Y0058/vienna.tif
116-
/data/europe/mask/X0077_Y0059/vienna.tif
117-
/data/europe/mask/X0078_Y0058/vienna.tif
118-
/data/europe/mask/X0078_Y0059/vienna.tif
115+
$ /data/europe/mask/X0077_Y0058/vienna.tif
116+
$ /data/europe/mask/X0077_Y0059/vienna.tif
117+
$ /data/europe/mask/X0078_Y0058/vienna.tif
118+
$ /data/europe/mask/X0078_Y0059/vienna.tif
119119
120120
121121
For speedy visuailzation, build overviews and pyramids:
@@ -125,17 +125,17 @@ For speedy visuailzation, build overviews and pyramids:
125125
force-pyramid /data/europe/mask/X*/*.tif
126126
force-mosaic /data/europe/mask
127127
128-
computing pyramids for vienna.tif
129-
0...10...20...30...40...50...60...70...80...90...100 - done.
130-
computing pyramids for vienna.tif
131-
0...10...20...30...40...50...60...70...80...90...100 - done.
132-
computing pyramids for vienna.tif
133-
0...10...20...30...40...50...60...70...80...90...100 - done.
134-
computing pyramids for vienna.tif
135-
0...10...20...30...40...50...60...70...80...90...100 - done.
136-
137-
mosaicking vienna.tif
138-
4 chips found.
128+
$ computing pyramids for vienna.tif
129+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
130+
$ computing pyramids for vienna.tif
131+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
132+
$ computing pyramids for vienna.tif
133+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
134+
$ computing pyramids for vienna.tif
135+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
136+
$
137+
$ mosaicking vienna.tif
138+
$ 4 chips found.
139139
140140
141141
.. figure:: img/tutorial-mask-vector.jpg
@@ -152,31 +152,31 @@ FORCE comes with a program to generate processing masks from a raster image with
152152
153153
force-procmask -h
154154
155-
Usage: force-procmask [-sldobj] input-basename calc-expr
156-
157-
optional:
158-
-s = pixel resolution of cubed data, defaults to 10
159-
-l = input-layer: band number in case of multi-band input rasters,
160-
defaults to 1
161-
-d = input directory: the datacube directory
162-
defaults to current directory
163-
'datacube-definition.prj' needs to exist in there
164-
-o = output directory: the directory where you want to store the cubes
165-
defaults to current directory
166-
-b = basename of output file (without extension)
167-
defaults to the basename of the input-file,
168-
appended by '_procmask'
169-
-j = number of jobs, defaults to 'as many as possible'
170-
171-
Positional arguments:
172-
- input-basename: basename of input data
173-
- calc-expr: Calculation in gdalnumeric syntax, e.g. 'A>2500'"
174-
The input variable is 'A'
175-
For details about GDAL expressions, see
176-
https://gdal.org/programs/gdal_calc.html
177-
178-
-----
179-
see https://force-eo.readthedocs.io/en/latest/components/auxilliary/procmask.html
155+
$ Usage: force-procmask [-sldobj] input-basename calc-expr
156+
$
157+
$ optional:
158+
$ -s = pixel resolution of cubed data, defaults to 10
159+
$ -l = input-layer: band number in case of multi-band input rasters,
160+
$ defaults to 1
161+
$ -d = input directory: the datacube directory
162+
$ defaults to current directory
163+
$ 'datacube-definition.prj' needs to exist in there
164+
$ -o = output directory: the directory where you want to store the cubes
165+
$ defaults to current directory
166+
$ -b = basename of output file (without extension)
167+
$ defaults to the basename of the input-file,
168+
$ appended by '_procmask'
169+
$ -j = number of jobs, defaults to 'as many as possible'
170+
$
171+
$ Positional arguments:
172+
$ - input-basename: basename of input data
173+
$ - calc-expr: Calculation in gdalnumeric syntax, e.g. 'A>2500'"
174+
$ The input variable is 'A'
175+
$ For details about GDAL expressions, see
176+
$ https://gdal.org/programs/gdal_calc.html
177+
$
178+
$ -----
179+
$ see https://force-eo.readthedocs.io/en/latest/components/auxilliary/procmask.html
180180
181181
182182
In the example given below, our input image is a multiband continuous fields dataset,
@@ -193,16 +193,16 @@ In our case, the data are already in datacube format, covering 597 tiles:
193193
cd /data/europe/pred
194194
ls X*/*.tif | head
195195
196-
X0052_Y0045/CONFIELD_MLP.tif
197-
X0052_Y0046/CONFIELD_MLP.tif
198-
X0052_Y0047/CONFIELD_MLP.tif
199-
X0052_Y0048/CONFIELD_MLP.tif
200-
X0052_Y0049/CONFIELD_MLP.tif
201-
X0052_Y0050/CONFIELD_MLP.tif
202-
X0052_Y0051/CONFIELD_MLP.tif
203-
X0052_Y0052/CONFIELD_MLP.tif
204-
X0052_Y0053/CONFIELD_MLP.tif
205-
X0053_Y0045/CONFIELD_MLP.tif
196+
$ X0052_Y0045/CONFIELD_MLP.tif
197+
$ X0052_Y0046/CONFIELD_MLP.tif
198+
$ X0052_Y0047/CONFIELD_MLP.tif
199+
$ X0052_Y0048/CONFIELD_MLP.tif
200+
$ X0052_Y0049/CONFIELD_MLP.tif
201+
$ X0052_Y0050/CONFIELD_MLP.tif
202+
$ X0052_Y0051/CONFIELD_MLP.tif
203+
$ X0052_Y0052/CONFIELD_MLP.tif
204+
$ X0052_Y0053/CONFIELD_MLP.tif
205+
$ X0053_Y0045/CONFIELD_MLP.tif
206206
207207
208208
We generate the masks using ``force-procmask``, which internally uses ``gdal_calc.py`` for executing the raster algebra.
@@ -225,11 +225,11 @@ To generate a mask with tree cover > 30%, we use the following:
225225
'A>3000'
226226
227227
228-
Computers / CPU cores / Max jobs to run
229-
1:local / 80 / 597
230-
231-
Computer:jobs running/jobs completed/%of started jobs/Average seconds to complete
232-
ETA: 0s Left: 0 AVG: 0.00s local:0/597/100%/0.1s
228+
$ Computers / CPU cores / Max jobs to run
229+
$ 1:local / 80 / 597
230+
$
231+
$ Computer:jobs running/jobs completed/%of started jobs/Average seconds to complete
232+
$ ETA: 0s Left: 0 AVG: 0.00s local:0/597/100%/0.1s
233233
234234
235235
We now have one cubed mask for each input image in the mask directory:
@@ -238,7 +238,7 @@ We now have one cubed mask for each input image in the mask directory:
238238
239239
ls /data/europe/mask/X*/forest-mask.tif | wc -l
240240
241-
597
241+
$ 597
242242
243243
244244
For speedy visuailzation, build overviews and pyramids:
@@ -248,18 +248,18 @@ For speedy visuailzation, build overviews and pyramids:
248248
force-pyramid /data/europe/mask/X*/forest-mask.tif
249249
force-mosaic /data/europe/mask
250250
251-
computing pyramids for forest-mask.tif
252-
0...10...20...30...40...50...60...70...80...90...100 - done.
253-
computing pyramids for forest-mask.tif
254-
0...10...20...30...40...50...60...70...80...90...100 - done.
255-
computing pyramids for forest-mask.tif
256-
0...10...20...30...40...50...60...70...80...90...100 - done.
257-
computing pyramids for forest-mask.tif
258-
0...10...20...30...40...50...60...70...80...90...100 - done.
259-
...
260-
261-
mosaicking forest-mask.tif
262-
597 chips found.
251+
$ computing pyramids for forest-mask.tif
252+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
253+
$ computing pyramids for forest-mask.tif
254+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
255+
$ computing pyramids for forest-mask.tif
256+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
257+
$ computing pyramids for forest-mask.tif
258+
$ 0...10...20...30...40...50...60...70...80...90...100 - done.
259+
$ ...
260+
$
261+
$ mosaicking forest-mask.tif
262+
$ 597 chips found.
263263
264264
265265
.. figure:: img/tutorial-mask-raster.jpg

0 commit comments

Comments
 (0)