pksieve(1)
β¨ pksieve(1) β¨
okay bestie, welcome to the pksieve corner of the manual pages π
this is section 1, so it's a user command, and it's literally here to clean up your raster images. let's get into it π«Ά
πΈ NAME πΈ
pksieve β a program that sieve-filters raster images. yes that's the whole name. short, sweet, iconic π
π SYNOPSIS π
pksieve -i input [-s size] -o output [options]
that's the shape of it, babe. input goes in, output comes out, and -s is optional but very much the main character when you want it π
π¦ DESCRIPTION π¦
okay so here's the vibe. pksieve filters out the little baby objects in your raster β and by "little baby" we mean maximum size defined with the option -s β and it does this by replacing them with their largest neighbor object. so the tiny speckly bits get absorbed into the big cool object next door. periodt β¨
now, what even is an "object" here? an object is pixels of the same value that are also connected. and "connected" is a choice you get to make, bestie:
- four directions β that's N-S and W-E, and you get it by setting
-c 4 - eight directions β that's N-S, W-E and the diagonals NW-SE and NE-SW, and you get it by setting
-c 8
pick your fighter π
π OPTIONS π
-ifilename,--inputfilename β the input image file. the thing you're sieving. your raw material π-ssize,--sizesize β raster polygons with sizes smaller than this get merged into their largest neighbour. and listen, important: no sieve is performed ifsize= 0. so don't be out here passing 0 and wondering why nothing happened, bestie π-ofilename,--outputfilename β Output image file Output image file. yes it says it twice in the source and honestly? it ate. it's the output image file π-c4|8,--connect4|8* β the connectedness.4directions or8directions. choose wisely β¨-bband,--bandband β the band to be used from the input file. just the one, boo π-mfilename,--maskfilename β use the first band of the specified file as a validity mask. zero is invalid, non-zero is valid. so 0 = not invited to the party, anything else = you're on the list π«Ά-ottype,--otypetype β the data type for the output image. your options are literally:{Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}. and if you pass an empty string, it inherits the type from the input image π¦-offormat,--oformatformat β the output image format (see alsogdal_translate(1)). empty string means inherit from the input image πΈ-cooption,--cooption β creation option for the output file. multiple options can be specified, so go off, stack them, slay π-ctfilename,--ctfilename β a colour table in ASCII format having 5 columns:id R G B ALFA(0: transparent,255: solid). note it's spelledALFAin the source and we respect the source's spelling choices β¨-vlevel,--verboselevel β verbose mode if> 0. so like, talk to me when you're above zero π₯
π EXAMPLE π
merge all patches smaller than 5 pixels into bigger classes, using 8 connectivity (horizontal, vertical and diagonal):
pksieve -i input.tif -c 8 -c 5 -o output.shp
go off, she ate, no crumbs π
sign-off time, my love π«Ά this page is from 01 January 2025, and it lives under the name pksieve(1) in the manual. now go sieve something cute πβ¨π
π¦ where this page comes from
- ubuntu questing: pktools 2.6.7.6+ds-6build4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms