pkascii2ogr(1)

πŸ’… NAME πŸ’…

okay bestie, meet pkascii2ogr β€” the icon, the moment, the little program that makes vector points or polygons out of a plain text file. literally that's the whole job. it's giving ✨glow-up for your .txt✨.


🌸 SYNOPSIS 🌸

pkascii2ogr [-i input] [-o output] [-f OGRformat] [-x col] [-y col]
            [-line] [-n fieldname] [-ot type] [-fs separator]

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: pkascii2ogr takes an ASCII textfile and builds a vector dataset out of it β€” either points or one single polygon. πŸŽ€

ngl, a better alternative is to use virtual vector datasets at http://www.gdal.org/drv_vrt.html. just saying. the manpage said it first, not me. 🫢

you tell it where the vertices live by naming which columns hold the x and y β€” that's the -x and -y options, and columns start counting from 0, no cap. the default vibe is: first column (-dx 0) for x and second column (-dx 1) for y, respectively. πŸ’«

then for all the leftover columns in your input file, you declare their names and types with the option pairs -n and -ot. matching sets, bestie, keep them paired. πŸ’ž

default field separator? a plain old space. iconic, simple, we love her.


✨ OPTIONS ✨

  • -i filename, --input filename β€” the input ASCII file, your raw material, the before picture πŸ“Έ
  • -o filename, --output filename β€” the output file, the after picture πŸ’–
  • -f OGRformat, --f OGRformat β€” the output sample file format 🎨
  • -x col, --x col β€” which column number holds x (default 0)
  • -y col, --y col β€” which column number holds y (default 1)
  • -l, --line β€” makes an OGRPolygon as the geometry instead of points. the fields get taken from the first point, and the polygon is automatically closed, so you do not need to repeat the first point on the last line (default is false: use OGRPoint) πŸ”Ί
  • -n fieldname, --name fieldname β€” field names for the columns in your input ascii file 🏷️
  • -ot type, --otype type β€” the field type (Real, Integer, String) for each of the fields as defined by name πŸ”€
  • -a_srs EPSG:number, --a_srs EPSG:number β€” override the projection for the output file; use an epsg: code or a Wkt string 🌍
  • -fs separator, --fs separator β€” the field separator πŸ”ͺ
  • -v n, --verbose n β€” verbose, default 0 πŸ—£οΈ

🌈 EXAMPLE 🌈

ok so picture this: you wanna make a vector shape file (output.shp) out of an input ASCII file (input.txt). πŸ—ΊοΈ

the coordinates β€” x (longitude) and y (latitude) β€” live in input.txt as columns 3 and 2 respectively (and yes, columns start counting from 0, we said what we said).

the remaining 2 columns in input.txt become fields (attributes) of type integer: id (column 0) and label (column 3). 🏷️

and the projection is set to lat lon (epsg:4326). slay. πŸ’…

pkascii2ogr -i input.txt -o output.shp -x 2 -x 1 -n id -ot Integer -n label -ot Integer -a_srs epsg:4326

πŸ‘‘ SEE ALSO πŸ‘‘


that's the whole page, bestie, you ate it up. πŸ’œ

this masterpiece is from the pkascii2ogr(1) manual page, dated 01 January 2025, and yes β€” pkascii2ogr(1) is right there in the corner being the main character it is. go forth and vectorize. ⭐πŸ”₯

πŸ“¦ where this page comes from