Global Mapper v25.0

External Palette in GTiff Script

Rich_Viz
Rich_Viz Purveyor of Data
edited May 2012 in GM Script Language
I have a group of 8 bit res grayscale GeoTifs that I am trying to script or batch assign a saved 8-bit .PAL file to.If I select Raster Options and Palette manually for one of them loaded in GM12, the palette maps properly and can be saved one at a time.If I attempt batch or use a script to try to do the same thing, it looks like it seems to invert the palette color assignments in the mapping. All things being equal shouldn't this do the same?thxGLOBAL_MAPPER_SCRIPT VERSION=1.00UNLOAD_ALL// Loop over all TIF files in a folder and convert themDIR_LOOP_START DIRECTORY="E:\Don\MOD02QKM\h10v05\V005\ndvi\fused_filtered\tif\" FILENAME_MASKS="*.TIF" RECURSE_DIR=NOIMPORT FILENAME="%FNAME_W_DIR%"EXPORT_RASTER FILENAME="J:\NDVI_data\TIFtoTIF_scripted\%%FNAME_WO_EXT%_script.TIF" TYPE=GEOTIFF SPATIAL_RES=250,250 GEN_WORLD_FILE=YES PALETTE="J:\NDVI_data\rainbow_mod13_2.pal" COMPRESSION=NONE FORCE_SQUARE_PIXELS=YES UNLOAD_ALLDIR_LOOP_END

Comments

  • global_mapper
    global_mapper Administrator
    edited May 2012
    Is the GeoTIFF being created with the palette specified in the .pal file, but in the reverse order of the .pal file or something like that? Which version and build date of Global Mapper do you have? Can you provide the sample .pal file?

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Yes I am using the same palette as in the script "rainbow_mod13_2.pal.
  • global_mapper
    global_mapper Administrator
    edited May 2012
    I just tried using that palette in a script (export line below) and the resulting TIFF used that palette in that order (i.e. a bunch of 5,28,80 at the start, then different shades of green ending in 0,56,0). I was using v13.1, but I don't think it would be different in v12. Can you provide the TIFF that was generated by your script, or at least a screenshot of the palette dialog for the layer?

    EXPORT_RASTER FILENAME="c:\temp\export test\palette.TIF" TYPE=GEOTIFF PALETTE="c:\temp\export test\rainbow_mod13_2.txt"

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Thanks Mike,

    Here's two files that show what the palette application looks like done manually (manual_pal.tif) and done with the script (script.pal).

    Well....I'm trying to. The Uploader keeps telling me the TIffs are invalid files. ? Should I email direct instead?

    thx
    Rich
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Rich,

    Try zipping them up and posting them, or else email to gmsupport@bluemarblegeo.com.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Here's the two files zipped.

    Thx
    Rich
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Rich,

    I definitely see what you mean, although I can't reproduce it from a script either in v13.2 or v12.02. Can you try getting the latest v12 build and see if that makes a difference? I have placed a new build at http://www.globalmapper.com/global_mapper12.zip with the latest changes for you to try. Simply download that file and extract the contents into your existing v12.xx installation folder to give it a try. If you are using the 64-bit v12 version there is a new build at http://www.globalmapper.com/global_mapper12_64bit.zip .

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Mike,

    Gave it a shot. No dice with either my Tif to Tif re-palette script or my original BSQ to Tif re-palette script.
    And then I load one into GM, use Control Center to select and apply the external palette and it does so nicely.

    Any other thoughts? Appreciate you looking into it.

    I do wish that GM wouldn't default to thinking my BSQ is elevation when I load one.

    Thanks

    rich
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Rich,

    Can you provide the original BSQ and script so that I can try exactly from where you are starting? I can also check out the default elevation thing too and see if I can make that smarter somehow.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Sure. Here they are.

    Thx again.

    rich
  • global_mapper
    global_mapper Administrator
    edited May 2012
    What shader do you have selected for the data? Because the data has a single band of floating point samples it is treated as a grid layer (i.e. elevation) and shaded with the current elevation shader. I presume this is actually want you want otherwise you would just get a grayscale display which wouldn't be very useful in your palette. You can setup the shader to use on the toolbar, including creating a custom one to get your desired mapping of reflectance values to colors.

    When I run your script on your BSQ file with the default Atlas Shader active I get the attached TIFF file, which looks ok.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.comMCDN2TQK.A2005230.H10V05.005.2011017212935.NDVI_Fused_Filtered_script.zip
  • global_mapper
    global_mapper Administrator
    edited May 2012
    As a follow-up, what the script is generating actually looks more correct than the manual generation, at least in terms of mapping the colors of the Atlas Shader to the palette file. If you were using a different shader that would make all the difference though.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Thanks for looking into this.

    So what good is the palette call in the script then? Is it not enabled because GM is seeing "elevation" and defaults to the GUI Shader selected?

    Yes, the colors in the test image you ran are exactly what I was getting, but the green should be inland and the brown along the waterline (marsh) so the assignments are inverted vs manual mode. I had tried loading the palette as a shader before but was looking for a scripted way to do it. I'll test with my "palette shader" enabled and see what I get.

    Appreciate your time.

    rich
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Rich,

    The PALETTE specifies that the raster GeoTIFF that you are exporting should use that palette. So however your loaded data is rendered as a 24-bit color image, it is then mapped to that palette in the GeoTIFF file. You can see the original full color image that is being exported by just leaving the PALETTE parameter off to create a 24-bit RGB GeoTIFF instead.

    To change the original display you would need to choose an appropriate shader to get the coloring that you want, such as a shader based on your palette. Then you can have the original rendered with that, then the colors mapped to your palette on export.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Rich,

    The PALETTE specifies that the raster GeoTIFF that you are exporting should use that palette. So however your loaded data is rendered as a 24-bit color image, it is then mapped to that palette in the GeoTIFF file. You can see the original full color image that is being exported by just leaving the PALETTE parameter off to create a 24-bit RGB GeoTIFF instead.

    To change the original display you would need to choose an appropriate shader to get the coloring that you want, such as a shader based on your palette. Then you can have the original rendered with that, then the colors mapped to your palette on export.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Thanks Mike,

    But how would you call the palette as a shader in a script through export? I actually imported the palette as a shader and manually tried to apply and it did not work. Also tried having that palette loaded into a shader manually before running the script and that did not produce the desired result. I'll keep permutating. :-)

    thx

    rich
  • global_mapper
    global_mapper Administrator
    edited May 2012
    Rich,

    There isn't any way to create a custom shader from a palette in a script, you would need to have the shader already created, then select it in the script using the SET_VERT_DISP_OPTS command.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Rich_Viz
    Rich_Viz Purveyor of Data
    edited May 2012
    Ok gotcha. But we are still doing elevation rendering functions on non-elevation data... :-)
    Maybe BSQs can one day join the ranks of those files that illicit the famed GM popup box of whether to treat the file being opened as elevation or raster.