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 πŸ’…

  • -i filename, --input filename β€” the input image file. the thing you're sieving. your raw material πŸ“
  • -s size, --size size β€” raster polygons with sizes smaller than this get merged into their largest neighbour. and listen, important: no sieve is performed if size = 0. so don't be out here passing 0 and wondering why nothing happened, bestie 😭
  • -o filename, --output filename β€” Output image file Output image file. yes it says it twice in the source and honestly? it ate. it's the output image file πŸ’€
  • -c 4|8, --connect 4|8* β€” the connectedness. 4 directions or 8 directions. choose wisely ✨
  • -b band, --band band β€” the band to be used from the input file. just the one, boo πŸŽ€
  • -m filename, --mask filename β€” 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 🫢
  • -ot type, --otype type β€” 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 πŸ¦‹
  • -of format, --oformat format β€” the output image format (see also gdal_translate(1)). empty string means inherit from the input image 🌸
  • -co option, --co option β€” creation option for the output file. multiple options can be specified, so go off, stack them, slay πŸ’…
  • -ct filename, --ct filename β€” a colour table in ASCII format having 5 columns: id R G B ALFA (0: transparent, 255: solid). note it's spelled ALFA in the source and we respect the source's spelling choices ✨
  • -v level, --verbose level β€” 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