Skip to content

Commit

Permalink
upgrade version, add a license ('MIT'), added some keywords, add some…
Browse files Browse the repository at this point in the history
… documentation, and add ability to not write lut's to file
  • Loading branch information
burningsage committed Apr 17, 2024
1 parent 21c168b commit 496db27
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 48 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# History

## 0.0.2 (2024-04-17)

* up date a bunch of stuff so that it works as a licensed, stand alone library.


## 0.0.1 (2024-04-17)

* Initial Release.
54 changes: 34 additions & 20 deletions disco_tif/process_sb_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def make_rgba_tiff_from_single_Band(single_band_tiff_path,
color_palette_name=None,
cmap_method='pseudo_hist_norm',
output_tif=False,
generate_lookup_tables=False,
plot_rgba_raster=False,
):
'''Function to take a single band geotiff file, apply a colormap to the data, and write a rgba geotiff to file
Expand All @@ -264,16 +265,16 @@ def make_rgba_tiff_from_single_Band(single_band_tiff_path,
- data_min_max:
default = None
Can take a list of lenth: 2, ex: [0, 500]
This function will automatically apply min/max values based on the 1 and 99 percentiles of the data values (excluding no-data values).
if not spcified, this function will automatically apply min/max values based on the clip_perc values
- min_max_method:
default = 'percentile'
default = 'percentile'; only relevant if data_min_max==None.
Also accepts 'data_absolute'.
'percentile' uses the percentiles used in clip_perc.
'data_absolute' uses the minimum and maximum values of the data
- clip_perc
default = [1, 99]
default = [1, 99]; only relevant if data_min_max==None.
Percentile values to clip the data values to if no data_min_max is specified.
- color_palette_name
Expand All @@ -287,6 +288,18 @@ def make_rgba_tiff_from_single_Band(single_band_tiff_path,
Method to determine where the color breaks should be. Also accepts 'pseudo_linear'
'pseudo_hist_norm' will produce a linear colormap for data values below 0 and a histogram normalized colormap for the positive values
'pseudo_linear' will produce a linear colormap for data values below 0 and a separate linear colormap for the positive values.
- output_tif:
default = False
If new geotiff are desired as outputs this must be set to True
- generate_lookup_tables:
defaule = False
If set to True look up tables will be generated and written to file. This includes a look up table that can be applied to the single-band geotiff in QGIS and maybe other GIS software.
- plot_rgba_raster
default=False
If set to True this will generate new matplotlib figures.
'''

if data_min_max is not None:
Expand Down Expand Up @@ -359,24 +372,25 @@ def make_rgba_tiff_from_single_Band(single_band_tiff_path,
)
plt.tight_layout()
plt.show()

if generate_lookup_tables:
outfilepaths = build_1_component_color_tables(cmap=EMerald_custom_colors_hexcolorcodes,
data_breaks=data_breaks,
data=data,
no_data_value=no_data_value,
new_multiband_lut_path=new_multiband_lut_path )
for fp in outfilepaths:
print(f"Wrote 1component LUT files to: '{fp}'")

outfilepaths = build_1_component_color_tables(cmap=EMerald_custom_colors_hexcolorcodes,
data_breaks=data_breaks,
data=data,
no_data_value=no_data_value,
new_multiband_lut_path=new_multiband_lut_path )
for fp in outfilepaths:
print(f"Wrote 1component LUT files to: '{fp}'")

outfilepaths = build_4_component_color_tables(single_band_tiff_path=single_band_tiff_path,
cmap=EMeraldCustomColormap,
data=data,
no_data_value=no_data_value,
percentile_breaks=percentile_breaks,
data_breaks=data_breaks,
outfile=new_multiband_tiff_path)
for fp in outfilepaths:
print(f"wrote 4component Lut files to: '{fp}''")
outfilepaths = build_4_component_color_tables(single_band_tiff_path=single_band_tiff_path,
cmap=EMeraldCustomColormap,
data=data,
no_data_value=no_data_value,
percentile_breaks=percentile_breaks,
data_breaks=data_breaks,
outfile=new_multiband_tiff_path)
for fp in outfilepaths:
print(f"wrote 4component Lut files to: '{fp}''")

if output_tif:
# apply EMeraldCustomColormap to data
Expand Down
56 changes: 30 additions & 26 deletions example_notebooks/process_tiff_from_functions.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions example_notebooks/streamlined_example_usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@
"ph_colormap, ph_data_breaks, ph_percentile_breaks = disco_tif.process_sb_tiff.make_rgba_tiff_from_single_Band(single_band_tiff_path,\n",
" #data_min_max=datarange,\n",
" cmap_method='pseudo_hist_norm',\n",
" generate_lookup_tables=True\n",
" output_tif=True)\n",
"pl_colormap, pl_data_breaks, pl_percentile_breaks = disco_tif.process_sb_tiff.make_rgba_tiff_from_single_Band(single_band_tiff_path,\n",
" #data_min_max=datarange,\n",
" cmap_method='pseudo_linear',\n",
" generate_lookup_tables=True\n",
" output_tif=True)"
]
},
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup, find_packages

setup(name = 'disco-tif',
version = "0.0.1",
version = "0.0.2",
url = 'https://github.com/emerald-geomodelling/disco-tif',
author = "Benjamin Bloss",
author_email = '[email protected]',
Expand All @@ -19,6 +19,7 @@
],
long_description = "Geotiff processing utilities",
include_package_data = True,
keywords = 'raster_processing',
keywords = ['raster_processing', 'EMerald_custom_colormap', 'hillshade', 'pca'],
license = 'MIT',
packages = find_packages(),
)

0 comments on commit 496db27

Please sign in to comment.