[pktools] 95/375: added examples and faqs for apps

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:54:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch upstream-master
in repository pktools.

commit 8f3133045b01ba1ad5185adc518109f748fdab97
Author: Pieter Kempeneers <kempenep at gmail.com>
Date:   Wed Apr 24 11:10:26 2013 +0200

    added examples and faqs for apps
---
 doc/examples_pkcreatect.dox | 22 ++++++++++++++++++++++
 doc/examples_pkcrop.dox     | 31 +++++++++++++++++++++++++++++++
 doc/examples_pkdumpogr.dox  | 15 +++++++++++++++
 doc/examples_pkextract.dox  | 37 +++++++++++++++++++++++++++++++++++++
 doc/examples_pkfilter.dox   | 10 ++++++++++
 doc/examples_pkgetmask.dox  | 11 +++++++++++
 doc/examples_pkmosaic.dox   | 26 ++++++++++++++++++++++++++
 doc/examples_pkndvi.dox     |  5 +++++
 doc/examples_pkreclass.dox  | 18 ++++++++++++++++++
 doc/examples_pksetmask.dox  | 26 ++++++++++++++++++++++++++
 doc/examples_pksieve.dox    |  5 +++++
 doc/examples_pkstat.dox     | 16 ++++++++++++++++
 doc/examples_pkstatogr.dox  | 12 ++++++++++++
 doc/faq_pkmosaic.dox        | 29 +++++++++++++++++++++++++++++
 src/apps/pkextract.cc       |  2 +-
 15 files changed, 264 insertions(+), 1 deletion(-)

diff --git a/doc/examples_pkcreatect.dox b/doc/examples_pkcreatect.dox
new file mode 100644
index 0000000..4206533
--- /dev/null
+++ b/doc/examples_pkcreatect.dox
@@ -0,0 +1,22 @@
+\section examples_pkcreatect Examples of pkcreatect
+\code
+pkcreatect -i image.tif -o image_ct.tif -min 0 -max 50
+\endcode
+attach color table to image with values between 0 and 50
+
+
+\code
+pkcreatect -i image.tif -o image_ct.tif -min 0 -max 100 -l legend.tif -g
+\endcode
+attach grey scale "color" table to image with values between 0 and 100 and create a legend image (annotation needs to be drawn manually)
+
+\code
+pkcreatect -i image.tif -o image_ct.tif -ct colourtable.txt
+\endcode
+attach predefined color table to image
+
+\code
+pkcreatect -i image.tif -o image_noct.tif -ct none
+\endcode
+remove color table from image 
+  
diff --git a/doc/examples_pkcrop.dox b/doc/examples_pkcrop.dox
new file mode 100644
index 0000000..2e94a0f
--- /dev/null
+++ b/doc/examples_pkcrop.dox
@@ -0,0 +1,31 @@
+\section examples_pkcrop Examples of pkcrop
+\code
+pkcrop -i input.tif -ulx 100 -uly 1000 -lrx 600 -lry 100 -o output.tif
+\endcode
+crop image.tif to the given bounding box
+
+\code
+pkcrop -i input.tif -e polygon.shp -o output.tif
+gdal_rasterize -i -burn 0 -l extent extent.shp output.tif
+\endcode
+crop image.tif to the envelop of the given polygon and mask all pixels outside polygon as 0 (using gdal_rasterize)
+
+\code
+pkcrop -i input.tif -b 3 -b 2 -b 1
+\endcode
+extract bands 3,2,1 (starting from 0) in that order from multi-band raster image input.tif
+
+\code
+pkcrop -i fimage.tif -s 100 -ot Byte -o bimage.tif -ct colortable.txt
+\endcode
+scale raster floating point image fimage.tif with factor 100 and write as single byte image with the given colourtable (for auto scaling, see next example)
+
+\code
+pkcrop -i fimage.tif -as 0 -as 100 -ot Byte -o bimage.tif -ct colortable.txt
+\endcode
+auto scale raster floating point image fimage.tif to [0:100] and write as single byte image with the given colourtable 
+
+\code
+pkcrop -i large.tif $(pkinfo -i small.tif -bb) -o output.tif
+\endcode
+crop raster image large.tif to the bounding box of raster image small.tif   
diff --git a/doc/examples_pkdumpogr.dox b/doc/examples_pkdumpogr.dox
new file mode 100644
index 0000000..cf61c3c
--- /dev/null
+++ b/doc/examples_pkdumpogr.dox
@@ -0,0 +1,15 @@
+\section examples_pkdumpogr Examples of pkdumpogr
+\code
+pkdumpogr -i input.shp
+\endcode
+dump entire content of vector file to standard output
+
+\code
+pkdumpogr -i input.shp -o output.txt -n ATTRIBUTE -pos
+\endcode
+dump only ATTRIBUTE of vector file including x and y position and output to ASCII file
+
+\code
+pkdumpogr -i input.shp -o output.txt -n ATTRIBUTE1 -n ATTRIBUTE2 -t
+\endcode
+dump the two attributes ATTRIBUTE1 and ATTRIBUTE2 of vector file and transpose output 
diff --git a/doc/examples_pkextract.dox b/doc/examples_pkextract.dox
new file mode 100644
index 0000000..9e3b3b0
--- /dev/null
+++ b/doc/examples_pkextract.dox
@@ -0,0 +1,37 @@
+\section examples_pkextract Examples of pkextract
+\code
+pkextract -i input.tif -s points.shp -o extracted.shp
+\endcode
+extract all bands from input.tif to extracted.shp at pixel locations defined in points.shp.
+
+\code
+pkextract -i input.tif -s points.shp -o extracted.shp -m mask.tif -f 255
+\endcode
+extract all bands from input.tif to extracted.shp at pixel locations defined in points.shp that have not a value 255 in mask.tif
+
+\code
+pkextract -i input.tif -s locations.shp -o training.shp -c -1
+\endcode
+extract all classes (classes must have value different from 0) in input image input.tif to extracted.shp at pixel locations defined in points.shp
+
+\code
+pkextract -i input.tif -s polygons.shp -o extracted.shp -l -b 0
+\endcode
+extract band 0 from input.tif to polygon vector file extracted.shp at centroids of polygons in polygons.shp.
+
+\code
+pkextract -i input.tif -s polygons.shp -o extracted.shp -l -r 1 -b 1
+\endcode
+extract band 1 from input.tif to polygon vector file extracted.shp as means of polygons in polygons.shp.
+
+\code
+pkextract -i input.tif -s sample.tif -o extracted.shp -t 10 -c 1 -c 2 -c 3
+\endcode
+extract all bands for a random sample of 10 percent of the pixels in sample.tif where sample.tif equals 1,2 or 3 (class values) to extracted.shp.
+
+\code
+pkextract -i input.tif -s sample.tif -o extracted.shp -t -5000 -c 1
+\endcode
+extract all bands for the first 5000 pixels (if available) where sample.tif equals 1 to extracted.shp.
+
+
diff --git a/doc/examples_pkfilter.dox b/doc/examples_pkfilter.dox
new file mode 100644
index 0000000..fdb9dcb
--- /dev/null
+++ b/doc/examples_pkfilter.dox
@@ -0,0 +1,10 @@
+\section examples_pkfilter Examples of pkfilter
+\code
+pkfilter -i input.tif -o filter.tif -dx 3 -dy 3 -f dilate -c
+\endcode
+filter input.tif with morphological dilation filter. Use a circular kernel (instead of rectangular) of size 3x3.
+
+\code
+pkfilter -i input.tif -o filter.tif -dx 3 -dy 3 -class 255 -f dilate -c
+\endcode
+Similar to previous example, but consider only values of 255 for filtering operation. Typical usage: dilate cloud values in input image that are flagged as 255
diff --git a/doc/examples_pkgetmask.dox b/doc/examples_pkgetmask.dox
new file mode 100644
index 0000000..70ba325
--- /dev/null
+++ b/doc/examples_pkgetmask.dox
@@ -0,0 +1,11 @@
+\section examples_pkgetmask Examples of pkgetmask
+\code
+pkgetmask -i input.tif -o output.tif --min 0 -t 1 -f 0
+\endcode
+create mask, setting all negative values to 0 (rest to 1)
+
+\code
+pkgetmask -i input.tif -o output.tif --min 0 --max 10 --min 0 --max 250 -b 0 -b 1
+\endcode
+create mask. Mask is set to 0 (default value for -f) if either band 0 is not between 0 and 10 OR (default operator) band 1 is not between 0 and 250. Else mask is set to 1 (default value for -t) 
+
diff --git a/doc/examples_pkmosaic.dox b/doc/examples_pkmosaic.dox
new file mode 100644
index 0000000..f6b0baa
--- /dev/null
+++ b/doc/examples_pkmosaic.dox
@@ -0,0 +1,26 @@
+\section examples_pkmosaic Examples of pkmosaic
+\code
+pkmosaic -i input1.tif -i input2.tif -o output.tif
+\endcode
+create mosaic from two input images. If images overlap, keep only last image (default rule)
+
+\code
+pkmosaic -i input1.tif -i input2.tif -o output.tif -m 4 --validBand 1 -t 255 -f 0
+\endcode
+create mosaic from two input images. Values of 255 in band 1 (starting from 0) are masked as invalid (rule=4). Typical use when multi-band image contains cloud mask
+
+\code
+pkmosaic -i input1.tif -i input2.tif -o output.tif -m 1 --rband=0 --rband=1 -t 255 -f 0
+\endcode
+create maximum NDVI (normalized difference vegetation index) composit. Values of 255 in band 0 (default) are masked as invalid and flagged as 0 if no other valid coverage. Typical use for (e.g., MODIS) images where red and near infrared spectral bands are stored in bands 0 and 1 respectively
+
+\code
+pkmosaic -i input1.tif -i input2.tif -i input3.tif -o output.tif -m 5 -w 0.75 -w 1.5 -w 0.75
+\endcode
+create composite image using weighted mean: output=(3/4*input1+6/4*input2+3/4*input2)/3.0
+
+\code
+pkmosaic -i large.tif $(for IMAGE in *.tif;do pkinfo -i $IMAGE --cover $(pkinfo -i coverage.tif -bb);done) -m 4 -min 0 -o output.tif
+\endcode
+create composit of all images found in current directory that cover (part of) coverage.tif. Values smaller or equal to 0 are invalid and flagged as 0 (default flag value)
+
diff --git a/doc/examples_pkndvi.dox b/doc/examples_pkndvi.dox
new file mode 100644
index 0000000..86fb272
--- /dev/null
+++ b/doc/examples_pkndvi.dox
@@ -0,0 +1,5 @@
+\section examples_pkpolygonize Examples of pkpolygonize
+\code
+pkpolygonize -i input.tif -m input.tif -o ouput.shp
+\endcode
+create vector file from raster image (typically a classification image), based on pixel (land cover class) values. 
diff --git a/doc/examples_pkreclass.dox b/doc/examples_pkreclass.dox
new file mode 100644
index 0000000..b55354c
--- /dev/null
+++ b/doc/examples_pkreclass.dox
@@ -0,0 +1,18 @@
+\section examples_pkpolygonize Examples of pkpolygonize
+\code
+pkreclass -i input1.tif -o output.tif -c 1 -r 0 -c 2 -r 0
+\endcode
+replace pixel values 1 and 2 with value 0
+
+\code
+pkreclass -i vector.shp -o output.shp -c FROM -r TO -n INFIELD
+\endcode
+replace FROM with TO in field INFIELD (of type string) in vector file vector.shp and write to new vector output.shp
+
+for((i=0;i<256;++i));do if(($i<100));then echo "$i 1";else echo "$i 0";fi;done > code.txt; pkreclass -i input1.tif -o output.tif –code code.txt; # replace all values smaller than 100 with 1, all other values with 0
+
+\code
+pkreclass -i input1.tif -o output.tif $(for((i=0;i<256;++i));do if(($i<100));then echo -n " -c $i " " -r 1";else echo " -c $i " " -r 0";fi;done)
+\endcode
+same as previous but without temporary file 
+
diff --git a/doc/examples_pksetmask.dox b/doc/examples_pksetmask.dox
new file mode 100644
index 0000000..7bc3848
--- /dev/null
+++ b/doc/examples_pksetmask.dox
@@ -0,0 +1,26 @@
+\section examples_pkpolygonize Examples of pkpolygonize
+\code
+pksetmask -i input.tif -m mask.tif -o output.tif -ot Byte -t 0 -f 255
+\endcode
+copy pixel values from input.tif to output.tif, applying mask.tif, setting all values to 255 where mask is 0.
+
+\code
+pksetmask -i input.tif -m mask.tif -o output.tif -ot Byte -t 1 -f 255 --operator '!'
+\endcode
+copy values from input.tif to output.tif, but set all values to 255 if mask is not 1
+
+\code
+pksetmask -i input.tif -m mask1.tif -m mask2.tif -o output.tif -ot Byte -t 0 -f 255
+\endcode
+copy pixel values from input.tif to output.tif, applying two masks, setting all values to 255 where either mask is 0.
+
+\code
+pksetmask -i input.tif -m mask.tif -o output.tif -ot Byte -t 0 -t 1 -f 255 -f 255
+\endcode
+copy pixel values from input.tif to output.tif, applying single masks, setting all values to 255 where mask is either 0 or 1.
+
+\code
+pksetmask -i input.tif -m mask.tif -o output.tif -ot Byte -t 0 -t 1 -f 255 -f 255
+\endcode
+copy pixel values from input.tif to output.tif, applying single masks, setting all values to 255 where mask is either 0 or 1.
+
diff --git a/doc/examples_pksieve.dox b/doc/examples_pksieve.dox
new file mode 100644
index 0000000..5eca036
--- /dev/null
+++ b/doc/examples_pksieve.dox
@@ -0,0 +1,5 @@
+\section examples_pkpolygonize Examples of pkpolygonize
+\code
+pksieve -i input.tif -c 8 -s 5 -o ouput.shp
+\endcode
+merge all patches smaller than 5 pixels into bigger classes, using 8 connectivity (horizontal, vertical and diagonal) 
\ No newline at end of file
diff --git a/doc/examples_pkstat.dox b/doc/examples_pkstat.dox
new file mode 100644
index 0000000..2b33448
--- /dev/null
+++ b/doc/examples_pkstat.dox
@@ -0,0 +1,16 @@
+\section examples_pkstat Examples of pkstat
+\code
+pkstat -i input.txt -n
+\endcode
+count number of records (same as wc -l input.txt)
+
+\code
+pkstat -i input.txt -hist -bin 100 -c 1 -rel
+\endcode
+report relative histogram in second column (starting from 0) using 100 bins.
+
+\code
+pkstat -i input.txt -m -c 0 -c 1
+\endcode
+report mean value of colums 0 and 1. 
+
diff --git a/doc/examples_pkstatogr.dox b/doc/examples_pkstatogr.dox
new file mode 100644
index 0000000..0e4ca4b
--- /dev/null
+++ b/doc/examples_pkstatogr.dox
@@ -0,0 +1,12 @@
+\section examples_pkstatogr Examples of pkstatogr
+\code
+pkstatogr -i input.shp -f FIELDID -n 100
+\endcode
+report histogram of values in FIELDID (to standard output)
+
+\code
+pkstatogr -i input.shp -f FIELDID -min -max -mean -stdev
+\endcode
+report min, max, mean and standard deviation of values in FIELDID (to standard output) 
+
+
diff --git a/doc/faq_pkmosaic.dox b/doc/faq_pkmosaic.dox
new file mode 100644
index 0000000..7996b71
--- /dev/null
+++ b/doc/faq_pkmosaic.dox
@@ -0,0 +1,29 @@
+\section faq_pkmosaic Frequently asked questions about pkmosaic
+
+ Q1. First questiona
+ A1. For individual invalid value(s) in input image, use -t (–invalid)
+
+ Usage: use unique value for each invalid bands set in -vb (–validBand) or use a single value that will be applied to all invalid bands
+
+ Example:
+
+\code
+pkmosaic -i input1.tif -i input2.tif -o output.tif -t 0 -t 255 -vb 0 -vb 1
+\endcode
+will consider 0 in band 0 and 255 in band 1 of input images as no value 
+
+\code
+pkmosaic -i input1.tif -i input2.tif -o output.tif -t 0 -vb 0 -vb 1
+\endcode
+will consider 0 in both bands 0 and 1 of input images as no value
+
+For range(s) of invalid values in input images: use -min (–min) and -max (–max) Usage: use unique range set for each invalid bands set in -vb (–validBand)
+
+Example: 
+\code
+pkmosaic -i input1.tif -i input2.tif -o output.tif -min 0 -max 200 -min 0 -max 2 -vb 0 -vb 1
+\endcode
+will consider all negative values in band 0 and 1 of input images as invalid. Values larger or equal to 200 in band 0 will be invalid, as well as values larger or equal to 2 in band 1
+
+ Q2. If I take the mean value as composit rule for multi-band input images, will the output image contain the mean value of overlapping images in each band?
+ A2. Yes
\ No newline at end of file
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index 8a7dde0..74c5b44 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
   Optionpk<string> ltype_opt("lt", "ltype", "Label type: In16 or String", "Integer");
   Optionpk<string> fieldname_opt("bn", "bname", "Field name of output shape file", "B");
   Optionpk<string> label_opt("cn", "cname", "name of the class label in the output vector file", "label");
-  Optionpk<bool> polygon_opt("l", "line", "create OGRPolygon as geometry instead of points. Only if sample option is also of polygon type. Use 0 for OGRPoint", false);
+  Optionpk<bool> polygon_opt("l", "line", "create OGRPolygon as geometry instead of OGRPoint. Only if sample option is also of polygon type.", false);
   Optionpk<int> band_opt("b", "band", "band index to crop. Use -1 to use all bands)", -1);
   Optionpk<short> rule_opt("r", "rule", "rule how to report image information per feature. 0: value at each point (or at centroid of the polygon if line is not set), 1: mean value (written to centroid of polygon if line is not set), 2: proportion classes, 3: custom, 4: minimum of polygon).", 0);
   Optionpk<short> verbose_opt("v", "verbose", "verbose mode if > 0", 0);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git



More information about the Pkg-grass-devel mailing list