spymicmac.register¶
spymicmac.register is a collection of tools for registering images and finding GCPs.
- spymicmac.register.get_imlist(im_subset)[source]¶
Given either a list of filenames or a regex match pattern, return a list of filenames and a pattern to provide to MicMac.
- Parameters
im_subset (list) – a list of filenames or a match pattern (e.g., [‘OIS.*tif’]) representing filenames
- Returns
imlist (list) – the list of filenames matching the provided pattern.
match_pattern (str) – the match pattern to be provided to MicMac.
- spymicmac.register.get_mask(footprints, img, imlist, landmask=None, glacmask=None)[source]¶
Create a mask for an image from different sources.
- Parameters
footprints (GeoDataFrame) – vector data representing image footprints
img (GeoImg) – the GeoImg to create a mask for
imlist (array-like) – a list of image names
landmask (str) – path to file of land outlines (i.e., an inclusion mask)
glacmask (str) – path to file of glacier outlines (i.e., an exclusion mask)
- Returns
mask (array-like) – the mask
fmask (GeoImg) – the georeferenced footprint mask
img (GeoImg) – the GeoImg, cropped to a 10 pixel buffer around the image footprints
- spymicmac.register.get_utm_str(epsg)[source]¶
Given a GeoImg, read the associated EPSG code and return a UTM zone.
- Examples:
get_utm_str(32608) -> ‘UTM Zone 8N’
get_utm_str(32708) -> ‘UTM Zone 8S’
- Parameters
epsg (int|str) – a str or int representing an EPSG Code
- Returns
utm_str (str) – the UTM string representation
- spymicmac.register.register_ortho(fn_ortho, fn_ref, fn_reldem, fn_dem, glacmask=None, landmask=None, footprints=None, im_subset=None, block_num=None, ori='Relative', ortho_res=8.0, imgsource='DECLASSII', density=200, out_dir=None, allfree=True)[source]¶
Register a relative orthoimage and DEM to a reference orthorectified image and DEM.
- Parameters
fn_ortho (str) – path to relative orthoimage
fn_ref (str) – path to reference orthorectified image
fn_reldem (str) – path to relative DEM
fn_dem (str) – path to reference DEM
glacmask (str) – path to file of glacier outlines (i.e., an exclusion mask)
landmask (str) – path to file of land outlines (i.e., an inclusion mask)
footprints (str) – path to shapefile of image outlines. If not set, will download from USGS.
im_subset (str) – subset of raw images to work with
block_num (str) – block number to use if processing multiple image blocks
ori (str) – name of orientation directory (after Ori-) (default: Relative)
ortho_res (float) – approx. ground sampling distance (pixel resolution) of ortho image (default: 8 m)
imgsource (str) – USGS dataset name for images (default: DECLASSII)
density (int) – pixel spacing to look for GCPs (default: 200)
out_dir (str) – output directory to save auto GCP files to (default: auto_gcps)
allfree (bool) – run Campari setting all parameters free (default: True)
- spymicmac.register.sliding_window_filter(img_shape, pts_df, winsize, stepsize=None, mindist=2000, how='residual', is_ascending=True)[source]¶
Given a DataFrame of indices representing points, use a sliding window filter to keep only the ‘best’ points within a given window and separation distance.
- Parameters
img_shape (array-like) – The shape of the image to filter indices from.
pts_df (DataFrame) – A DataFrame that contains the pixel locations of points (column: orig_j, row: orig_i)
winsize (int) – the size of the window to use for the filter.
stepsize (int) – how large of a step size to use for the sliding window (default: winsize/2)
mindist (int) – the minimum distance (in pixels) to use between points (default: 2000)
how (str) – how to sort pts_df to determine the ‘best’ points to keep (default: ‘residual’)
is_ascending (bool) – whether the column named in ‘how’ should be sorted ascending or descending (default: True)
- Returns
out_inds (array-like) – an array with the filtered indices
- spymicmac.register.transform_centers(img_gt, ref, imlist, footprints, ori)[source]¶
Use the camera centers in relative space provided by MicMac Orientation files, along with camera footprints, to estimate a transformation between the relative coordinate system and the absolute coordinate system.
- Parameters
img_gt (array-like) – the image GeoTransform (as read from a TFW file)
ref (GeoImg) – the reference image to use to determine the output image shape
imlist (list) – a list of of the images that were used for the relative orthophoto
footprints (GeoDataFrame) – the (approximate) image footprints - the centroid will be used for the absolute camera positions.
ori (str) – name of orientation directory
- Returns
model (AffineTransform) – the estimated Affine Transformation between relative and absolute space
inliers (array-like) – a list of the inliers returned by skimage.measure.ransac
join (GeoDataFrame) – the joined image footprints and relative orientation files