changeset 10:1944acce0e6f

Add --output= option.
author David Barts <n5jrn@me.com>
date Thu, 26 Aug 2021 08:37:46 -0700
parents a56d3d3b5efd
children 6e4a8ddacf61
files Readme.rst gdalwarp.txt make-tile
diffstat 3 files changed, 50 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Readme.rst	Wed Aug 25 08:45:36 2021 -0700
+++ b/Readme.rst	Thu Aug 26 08:37:46 2021 -0700
@@ -38,7 +38,7 @@
    on the need for TopoTiler in the first place. If this program proves useful
    to a lot of people, and the consensus among its user base is that a GUI
    would be beneficial, I will probably add one.
-   
+
 Prerequisites
 -------------
 
@@ -65,9 +65,12 @@
 
 -l/--layers
         Comma-separated list of layers to include. See below for default.
+-o/--output
+        Specify output file. Defaults to input file with extention changed
+        to .tiff.
 -r/--resolution
         Output resolution in DPI. Default is 300.
-        
+
 Environment
 ^^^^^^^^^^^
 
@@ -85,5 +88,30 @@
 By default, all ``Map_Frame`` layers, except for
 ``Map_Frame.Projection_and_Grids`` and
 ``Map_Frame.Terrain.Shaded_Relief``, will be included. This behavior can be
-changed with the ``--layers`` option. 
+changed with the ``--layers`` option.
+
+MakeWaypoints
+-------------
+
+Synopsis
+^^^^^^^^
+
+``kotlin MakeWaypointsKt`` [``-latfirst``] *file*
 
+Prompt for long, lat (or, with ``-latfirst``, lat, long) pairs and names and
+create a file containing the specified waypoints. Coordinates are expected to
+be two comma-separated floating-point numbers, with negative values indicating
+locations in the southern or western hemispheres (i.e. the standard way of
+representing coordinates in computer storage).
+
+Basic sanity checks are performed on the coordinates entered.
+
+Notes
+^^^^^
+
+This program is in Kotlin, despite my starting this project in Python, because
+the JVM has a much more concise and simple way (i.e. ``XMLStreamWriter``) for
+producing XML output.
+
+Longitude, not latitude, is first by default because that is the way QGIS
+exports coordinates.
--- a/gdalwarp.txt	Wed Aug 25 08:45:36 2021 -0700
+++ b/gdalwarp.txt	Thu Aug 26 08:37:46 2021 -0700
@@ -6,3 +6,10 @@
 There does not seem to be a good, easy way to tell it to preserve
 resolution.  You must play with -tr. Anything higher than 1x1 is nasty
 and coarse. Anything less gobbles disk space exponentially.
+
+Another alternative: just drop gdalwarp and for each raster layer, set
+Properties... Additional no data value to 0. Import via the following
+procedure:
+
+http://www.qgistutorials.com/en/docs/raster_mosaicing_and_clipping.html
+http://www.qgistutorials.com/en/docs/3/raster_mosaicing_and_clipping.html
--- a/make-tile	Wed Aug 25 08:45:36 2021 -0700
+++ b/make-tile	Thu Aug 26 08:37:46 2021 -0700
@@ -214,6 +214,8 @@
 parser = argparse.ArgumentParser(description='Render GeoPDF into GeoTIFF suitable for tiling.')
 parser.add_argument('--layers', '-l', type=str,
     help='List of layers to include (see documentation for default).')
+parser.add_argument('--output', '-o', type=str,
+    help='Name of output file (default: *.tiff).')
 parser.add_argument('--resolution', '-r', type=positive_int, default=300,
     help='Resolution to render at in DPI (default: 300).')
 parser.add_argument('file', nargs=1,
@@ -228,12 +230,20 @@
     # How silly, it gave us a list or a tuple, despite only one of them!
     args.file = args.file[0]
 if not args.file.lower().endswith('.pdf'):
-    sys.steder.write("{0}: input file must end with .pdf (case insensitive)\n".format(MYNAME))
+    sys.stderr.write("{0}: input file must end with .pdf (case insensitive)\n".format(MYNAME))
+    sys.exit(2)
 
 # Default the set of layers to delete, if necessary
 if args.layers is None:
     args.layers = get_default_layers(args.file)
 
+# Default the output file, if necessary
+if args.output is None:
+    args.output = os.path.splitext(args.file)[0] + ".tiff"
+elif os.path.splitext(args.output)[1].lower() not in set([".tif", ".tiff"]):
+    sys.stderr.write("{0}: output file must end with .tif or .tiff (case insensitive)\n".format(MYNAME))
+    sys.exit(2)
+
 with TemporaryDirectory() as td:
     # Get scratch file name. This goes under TMPDIR; if the default temporary
     # area is too small, set that environment variable accordingly!
@@ -256,12 +266,9 @@
         miny = find_edge(im, Orientation.HORIZONTAL, Direction.ASCENDING)
         maxy = find_edge(im, Orientation.HORIZONTAL, Direction.DESCENDING)
 
-    # Determine output file name.
-    outf = os.path.splitext(args.file)[0] + ".tiff"
-
     # Crop.
     proc = subprocess.Popen(
-        gdalcmd("gdal_translate", "-q", tf, outf, "-of", "GTiff", "-srcwin", str(minx), str(miny), str(maxx-minx+1), str(maxy-miny+1)),
+        gdalcmd("gdal_translate", "-q", tf, args.output, "-of", "GTiff", "-srcwin", str(minx), str(miny), str(maxx-minx+1), str(maxy-miny+1)),
         stdout=subprocess.DEVNULL, stderr=sys.stderr)
     waitfor(proc)