asp_plot.mapproject#
Reconstruct mapproject commands from ASP-mapprojected GeoTIFF metadata.
ASP’s mapproject tool does not write a log file the way bundle_adjust /
stereo / point2dem do, so asp_plot.asp_log (which parses those
logs) has nothing to read for the mapprojection step (issue #96).
Fortunately mapproject stamps everything we need into the output GeoTIFF
header, so the command can be reconstructed from the output data alone – no new
ASP --log flag required. The fields written by ASP are:
INPUT_IMAGE_FILE– the image that was mapprojectedCAMERA_FILE– the camera modelDEM_FILE– the DEM used as the projection surfaceCAMERA_MODEL_TYPE– the resolved--session-type/-tBUNDLE_ADJUST_PREFIX– the--bundle-adjust-prefix("NONE"if unset)
combined with the raster’s own CRS (--t_srs), resolution (--tr), and
bounds (--t_projwin).
The reconstruction is faithful but not byte-for-byte re-runnable: the session
type is the resolved value (not necessarily what the user typed), an input
--mpp shows up resolved as --tr, and the output name is read from the
file itself. Callers that surface this to users (e.g. the PDF report) should say
so. See reconstruct_mapproject_command for the exact argv order.
Attributes#
Functions#
|
Find ASP-mapprojected outputs across |
|
Reconstruct the |
Module Contents#
- asp_plot.mapproject.find_mapproject_commands(directories, stereo_command=None)#
Find ASP-mapprojected outputs across
directoriesand reconstruct them.Scans each directory (non-recursively) for GeoTIFFs and keeps those carrying the ASP mapproject metadata signature (see
REQUIRED_TAGS) – identity is decided entirely by the file’s own metadata, not by its name, so the result is robust to ASP/asp_plot filename conventions. Each kept output is reconstructed into a command; results are deduplicated (the same scene can be reached via more than one of the passed directories) and returned sorted for stable report output.- Parameters:
directories (iterable of str or None) – Directories to scan (e.g. the processing root, stereo dir, BA dir).
Noneentries are skipped.stereo_command (str, optional) – The stereo command line for the run being reported. When given, a mapprojected output is kept only if its filename appears among the stereo inputs (i.e. this run actually consumed it). This scopes the result to the run at hand: a non-mapprojected stereo run that shares a directory with leftover mapprojected scenes (e.g.
stereo/andstereo_no_mapproj/under one parent) no longer picks them up. A mapprojected run’sstereocommand lists the*_map.tifinputs; a non-mapprojected run lists the raw images instead, so the gate is a plain filename-membership test – no fragile positional parsing. WhenNone(or empty), no gating is applied and every discovered output is returned.
- Returns:
Reconstructed
mapprojectcommand lines, sorted; empty if none found.- Return type:
- asp_plot.mapproject.reconstruct_mapproject_command(raster_path)#
Reconstruct the
mapprojectcommand for an ASP-mapprojected GeoTIFF.- Parameters:
raster_path (str) – Path to a GeoTIFF that may be an ASP
mapprojectoutput.- Returns:
The reconstructed
mapproject ...command line, orNoneif the file is missing the ASP mapproject metadata signature (i.e. it is not a mapproject output, or was written by a tool that did not stamp the header).- Return type:
str or None
Notes
The reconstructed argv order mirrors the ASP CLI:
mapproject [-t SESSION] [--t_srs SRS] --tr TR \ --t_projwin XMIN YMIN XMAX YMAX \ [--bundle-adjust-prefix PREFIX] \ DEM_FILE INPUT_IMAGE CAMERA OUTPUT
--t_srsis emitted asEPSG:XXXXwhen the CRS has an exact EPSG code, otherwise as the PROJ string (quoted), so custom planetary/local projections (e.g. the stereographic frames used in jitter solving) still round-trip.
- asp_plot.mapproject.RASTER_EXTENSIONS = ('*.tif', '*.tiff')#
- asp_plot.mapproject.REQUIRED_TAGS = ('INPUT_IMAGE_FILE', 'CAMERA_FILE', 'DEM_FILE')#
- asp_plot.mapproject.logger#