tifftools
tifftools copied to clipboard
Convenience functions to set projection and GCPs
This PR creates the functions set_projection and set_gcps in commands.py. These functions can be called directly, invoked through tiff_set, or invoked via the command line. Resolves #101.
Note: pyproj is required for the set_projection function. Running pip install tifftools[geo] will install pyproj.
Usage examples:
tifftools.commands.set_gcps(output_path, gcps, overwrite=True)
tifftools.commands.set_projection(output_path, projection, overwrite=True)
tifftools.tiff_set(str(output_path), overwrite=True, setlist=[
('projection', projection),
('gcps', gcps),
])
subprocess.run([
'tifftools', 'set', str(output_path), '--overwrite',
'--set', 'projection', projection,
'--set', 'gcps', ' '.join(' '.join(str(g) for g in gcp) for gcp in gcps)
])
Example values for projection and gcps:
projection = 'epsg:4326`
gcps = [(-77.05, 38.88, 0, 0), (-77.04, 38.89, 100, 100)]
projection = '+proj=aea +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'
gcps = [(1979142.78, 2368597.47, 0, 0), (2055086.35, 2449556.39, 100, 100)]