### Install viewtif Packages Source: https://context7.com/nkeikon/tifviewer/llms.txt Installs the viewtif package with optional support for shapefile overlays or NetCDF and cartopy visualization. Dependencies are managed via pip. ```bash pip install viewtif pip install "viewtif[geo]" pip install "viewtif[netcdf]" ``` -------------------------------- ### Install GDAL for HDF/HDF5 Support Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Installs the GDAL library, a prerequisite for viewtif to open HDF, HDF5, and other complex raster formats. Installation commands vary by operating system. ```bash brew install gdal # macOS sudo apt install gdal-bin python3-gdal # Linux pip install GDAL ``` -------------------------------- ### Install viewtif with NetCDF Support Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Installs viewtif with NetCDF support, enabling visualization of .nc files. For advanced geographic features like map projections, install with the 'netcdf' extra, which includes cartopy. ```bash pip install "viewtif[netcdf]" ``` -------------------------------- ### Install viewtif Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Installs the base viewtif package for command-line GeoTIFF visualization. Ensure Python 3.9+ is available. On Linux, additional GUI libraries might be needed. ```bash pip install viewtif ``` -------------------------------- ### View Single-Band TIFF with viewtif Source: https://github.com/nkeikon/tifviewer/blob/main/examples/README.md Displays a single-band TIFF image using the viewtif command. This is the most basic usage for visualizing raster data. ```bash viewtif examples/sample_data/ECOSTRESS_LST.tif ``` -------------------------------- ### View TIFF with Shapefile Overlay using viewtif Source: https://github.com/nkeikon/tifviewer/blob/main/examples/README.md Displays a single-band TIFF image and overlays a shapefile. This is useful for visualizing raster data in the context of vector features. ```bash viewtif examples/sample_data/ECOSTRESS_LST.tif --shapefile examples/Zip_Codes.shp ``` -------------------------------- ### Install viewtif with Shapefile Overlay Support Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Installs viewtif with extra dependencies for shapefile overlay functionality. This enables combining vector data with raster visualizations. Quotes are recommended for zsh users. ```bash pip install "viewtif[geo]" ``` -------------------------------- ### View RGB Composite TIFF with viewtif Source: https://github.com/nkeikon/tifviewer/blob/main/examples/README.md Displays a multi-band TIFF image as an RGB composite using specified band files. This is used for visualizing color imagery. ```bash viewtif --rgbfiles examples/sample_data/HLS_B4.tif examples/sample_data/HLS_B3.tif examples/sample_data/HLS_B2.tif ``` -------------------------------- ### Programmatic viewtif API Usage Source: https://context7.com/nkeikon/tifviewer/llms.txt Demonstrates how to use the viewtif viewer programmatically via its Python API. Shows examples for viewing single files, RGB composites, shapefile overlays, HDF subdatasets, and NetCDF variables. ```python from viewtif.tif_viewer import run_viewer # View single file run_viewer( tif_path="ECOSTRESS_LST.tif", band=1, scale=1 ) # View RGB composite from separate files run_viewer( tif_path=None, rgbfiles=["HLS_B04.tif", "HLS_B03.tif", "HLS_B02.tif"], scale=1 ) # View with shapefile overlay run_viewer( tif_path="temperature.tif", band=1, shapefile=["coastline.shp", "borders.shp"], shp_color="yellow", shp_width=2.0 ) # View HDF subdataset run_viewer( tif_path="AG100.v003.33.-107.0001.h5", subset=2, band=1, scale=5 ) # View NetCDF variable run_viewer( tif_path="climate_data.nc", subset=0, scale=2 ) ``` -------------------------------- ### View NetCDF Files Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Displays NetCDF (.nc) files using xarray. Supports navigation through time steps or other dimensions using '[' and ']'. Optional cartopy installation enhances geographic visualization. ```bash viewtif data.nc ``` -------------------------------- ### NetCDF Visualization with Cartopy in TiffViewer Source: https://context7.com/nkeikon/tifviewer/llms.txt Describes how TiffViewer automatically integrates with Cartopy for NetCDF files containing geographic coordinates, adding map features like coastlines, country borders, and a color bar. Installation of Cartopy support is required. ```bash # Install cartopy support # pip install "viewtif[netcdf]" # Open NetCDF - automatically uses cartopy if available # viewtif climate_model.nc --subset 0 # Features added automatically when using cartopy: # - Coastlines at 50m resolution # - Country borders (dotted lines) # - State boundaries (semi-transparent) # - Grid lines with labels # - Color bar showing data range ``` -------------------------------- ### Initialize TiffViewer with Parameters Source: https://context7.com/nkeikon/tifviewer/llms.txt Demonstrates how to initialize the TiffViewer with various parameters including file path, scale, band selection, shapefile overlays, and subsetting for HDF/NetCDF files. Requires PySide6 and viewtif libraries. ```python from viewtif.tif_viewer import TiffViewer from PySide6.QtWidgets import QApplication import sys # Create Qt application app = QApplication(sys.argv) # Initialize viewer with parameters viewer = TiffViewer( tif_path="multiband.tif", scale=1, # Downsampling factor (1 = full resolution) band=1, # Initial band to display rgb=None, # RGB band indices [R, G, B] rgbfiles=None, # List of three file paths for RGB shapefiles=["overlay1.shp", "overlay2.shp"], shp_color="white", # Overlay color shp_width=2.0, # Overlay line width subset=None # HDF/NetCDF subdataset index ) viewer.show() sys.exit(app.exec()) ``` -------------------------------- ### View a GeoTIFF from Command Line Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Basic usage of viewtif to display a single-band GeoTIFF file. This command opens a Qt window showing the raster data. ```bash viewtif ECOSTRESS_LST.tif ``` -------------------------------- ### Interactive Viewer Controls Source: https://context7.com/nkeikon/tifviewer/llms.txt Lists keyboard shortcuts for interactive control of the viewtif viewer. Includes zoom, pan, contrast/gamma adjustments, colormap toggling, and band/time step navigation. ```python # Controls are automatically available when viewer window is open: # Zoom and Pan # + / - : Zoom in/out # Arrow keys or WASD : Pan in any direction # Mouse wheel or trackpad : Zoom centered at cursor # Visual Adjustments # C : Increase contrast # V : Decrease contrast # G : Increase gamma # H : Decrease gamma # M : Toggle colormap (viridis ↔ magma for single-band, or cycle through RdBu_r/viridis/magma for NetCDF) # Band/Time Navigation # [ : Previous band or time step # ] : Next band or time step # Reset # R : Reset view (contrast, gamma, zoom) ``` -------------------------------- ### Control Rendering and Colormap in TiffViewer Source: https://context7.com/nkeikon/tifviewer/llms.txt Shows how to programmatically adjust contrast, gamma, and change the colormap of the TiffViewer after initialization. Requires PySide6 and viewtif libraries. ```python from viewtif.tif_viewer import TiffViewer from PySide6.QtWidgets import QApplication import sys app = QApplication(sys.argv) # Open viewer viewer = TiffViewer(tif_path="temperature.tif", band=1) # Adjust contrast and gamma programmatically viewer.contrast = 1.5 viewer.gamma = 1.2 # Change colormap viewer.cmap_name = "plasma" # Available: viridis, magma, plasma, inferno, etc. # Update display viewer.update_pixmap() viewer.show() sys.exit(app.exec()) ``` -------------------------------- ### View NetCDF Files with Time Series Source: https://context7.com/nkeikon/tifviewer/llms.txt Visualizes NetCDF files, automatically selecting a single variable or allowing specific variable selection via the --subset argument. Supports time series navigation and optional Cartopy visualization. ```bash viewtif temperature.nc viewtif climate_model.nc --subset 0 viewtif tasmax_mon_ACCESS-CM2_ssp370_r1i1p1f1_gn_2021.nc ``` -------------------------------- ### TiffViewer Safeguard for Large Rasters Source: https://context7.com/nkeikon/tifviewer/llms.txt Illustrates the command-line safeguard for loading very large raster files. The tool warns users about potential performance issues and suggests using the --scale option for downsampling. Requires the viewtif command-line tool. ```bash # viewtif automatically checks file size before loading viewtif huge_satellite_image.tif # If file is very large (>20M pixels), you'll see: # [WARN] Large raster detected (50000×40000, ~2000.0M effective pixels, ~15234.5 MB). # Loading may freeze. Consider rerunning with --scale (e.g. --scale 10). # Proceed anyway? [y/N]: # Use --scale to load downsampled version viewtif huge_satellite_image.tif --scale 10 ``` -------------------------------- ### View GeoTIFF Files Source: https://context7.com/nkeikon/tifviewer/llms.txt Commands to view single-band or multi-band GeoTIFF files. Supports specifying a band, downsampling for large files, and creating RGB composites from multi-band files. ```bash viewtif ECOSTRESS_LST.tif viewtif multiband.tif --band 3 viewtif large_raster.tif --scale 10 viewtif HLS_multiband.tif --rgb 4 3 2 ``` -------------------------------- ### Create RGB Composite from Separate Files Source: https://context7.com/nkeikon/tifviewer/llms.txt Combines three single-band GeoTIFF files into an RGB composite image. Input files are specified using the --rgbfiles argument. ```bash viewtif --rgbfiles HLS_B04.tif HLS_B03.tif HLS_B02.tif ``` -------------------------------- ### View GeoTIFF with Shapefile Overlay Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Visualizes a GeoTIFF along with a shapefile overlay. Ensure the shapefile is in a compatible format and has appropriate spatial referencing for accurate alignment. ```bash viewtif ECOSTRESS_LST.tif \ --shapefile Zip_Codes.shp ``` -------------------------------- ### View HDF/HDF5 Files and Subdatasets Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Opens HDF/HDF5 files, listing available subdatasets. Users can select a specific subdataset by index and optionally a particular band for visualization. Requires GDAL. ```bash # List subdatasets viewtif AG100.v003.33.-107.0001.h5 # View a specific subdataset viewtif AG100.v003.33.-107.0001.h5 --subset 1 # View a specific subdataset and band viewtif AG100.v003.33.-107.0001.h5 --subset 1 --band 3 ``` -------------------------------- ### Access HDF/HDF5 Subdatasets Source: https://context7.com/nkeikon/tifviewer/llms.txt Opens HDF/HDF5 files and allows selection of specific subdatasets for viewing. Lists available subdatasets and enables opening a chosen one with an optional band selection. ```bash viewtif AG100.v003.33.-107.0001.h5 viewtif AG100.v003.33.-107.0001.h5 --subset 1 viewtif AG100.v003.33.-107.0001.h5 --subset 1 --band 3 ``` -------------------------------- ### Open Raster Datasets in File Geodatabases (.gdb) Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Allows viewtif to open raster data stored within Esri File Geodatabases. It lists available rasters and provides a specific syntax to open a chosen dataset. GDAL with OpenFileGDB driver is typically required. ```bash # List available raster datasets viewtif /path/to/geodatabase.gdb # Open a specific raster viewtif "OpenFileGDB:/path/to/geodatabase.gdb:RasterName" ``` -------------------------------- ### View RGB Composite GeoTIFFs Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Displays an RGB composite image by specifying multiple GeoTIFF files corresponding to Red, Green, and Blue bands. The order of files determines the color channels. ```bash viewtif --rgbfiles \ HLS_B04.tif \ HLS_B03.tif \ HLS_B02.tif ``` -------------------------------- ### TiffViewer Handles No-Data Values Source: https://context7.com/nkeikon/tifviewer/llms.txt Explains that TiffViewer automatically detects and handles no-data values specified in the raster's metadata, converting them to NaN for correct visualization. Demonstrates checking no-data values using rasterio. ```python # viewtif automatically handles nodata values from raster metadata # nodata values are converted to NaN for proper visualization import numpy as np from viewtif.tif_viewer import TiffViewer # viewtif reads nodata from file metadata # and masks those values in the display # Example with rasterio: import rasterio with rasterio.open("has_nodata.tif") as src: print(f"NoData value: {src.nodata}") # e.g., -9999 # viewtif will mask this automatically ``` -------------------------------- ### View Large Rasters with Scaling Source: https://github.com/nkeikon/tifviewer/blob/main/README.md Safeguard against freezing on very large rasters (over 20 million pixels). Use the `--scale` option for a smaller, faster preview of the data. This helps manage memory and performance. ```bash # Example: Proceed manually or rerun with --scale # viewtif --scale 0.5 large_raster.tif ``` -------------------------------- ### Open Esri File Geodatabase Rasters Source: https://context7.com/nkeikon/tifviewer/llms.txt Accesses raster datasets stored within Esri File Geodatabases (.gdb). Lists available rasters and allows opening a specific raster using a formatted path. ```bash viewtif /path/to/geodatabase.gdb viewtif "OpenFileGDB:/path/to/geodatabase.gdb:elevation_raster" ``` -------------------------------- ### Overlay Shapefiles on Rasters Source: https://context7.com/nkeikon/tifviewer/llms.txt Overlays vector data from shapefiles onto raster visualizations. Supports single or multiple shapefiles with options for custom styling like color and line width. ```bash viewtif ECOSTRESS_LST.tif --shapefile Zip_Codes.shp viewtif temperature.tif \ --shapefile coastline.shp \ --shapefile counties.shp \ --shp-color cyan \ --shp-width 1.8 viewtif elevation.tif \ --shapefile rivers.shp \ --shp-color "#FF5733" \ --shp-width 2.5 ``` -------------------------------- ### TiffViewer Handles CRS Transformations for Overlays Source: https://context7.com/nkeikon/tifviewer/llms.txt Explains that TiffViewer automatically handles Coordinate Reference System (CRS) transformations for shapefile overlays, ensuring they are reprojected to match the raster's CRS. Requires viewtif and rasterio libraries. ```python from viewtif.tif_viewer import TiffViewer import rasterio # viewtif automatically handles CRS transformations for overlays # Shapefiles are reprojected to match raster CRS automatically # Example: overlay will be reprojected to match raster viewer = TiffViewer( tif_path="raster_utm_zone_12.tif", # UTM Zone 12N shapefiles=["boundaries_wgs84.shp"] # WGS84 - automatically reprojected ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.