Export GeoTiff and preserve the Pal Idx

RobertRRobertR GlobalMapper Fan!Posts: 284Trusted User
edited June 2013 in Raster Data
Hello,

I used a script to crop a raster file into pieces, but the output does not contain the initial format, the pal idx code.
Before:
Band 1 Block=128x128 Type=Byte, ColorInterp=Palette
Min=0.000 Max=95.000
Minimum=0.000, Maximum=95.000, Mean=30.261, StdDev=32.473
NoData Value=255
Metadata:
RepresentationType=THEMATIC
STATISTICS_COVARIANCES=1054.51245173011
STATISTICS_MAXIMUM=95
STATISTICS_MEAN=30.260543032059
STATISTICS_MINIMUM=0
STATISTICS_STDDEV=32.473257485662
Color Table (RGB with 256 entries)
0: 0,0,0,255
1: 0,250,0,255
2: 0,0,0,255
3: 0,0,0,255
4: 0,0,0,255
5: 0,0,0,255
6: 0,0,0,255
7: 0,0,0,255
8: 0,0,0,255
9: 0,0,0,255
10: 0,0,0,255
11: 71,107,161,255
12: 209,222,250,255

After:
Image Structure Metadata:
COMPRESSION=LZW
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 122656.347, 1510471.824) ( 94d36'55.70"W, 36d37'56.89"N)
Lower Left ( 122656.347, 1107301.824) ( 94d40'43.46"W, 33d 1'41.78"N)
Upper Right ( 568156.347, 1510471.824) ( 89d35'45.55"W, 36d28'10.18"N)
Lower Right ( 568156.347, 1107301.824) ( 89d53'16.22"W, 32d52'19.67"N)
Center ( 345406.347, 1308886.824) ( 92d11'38.56"W, 34d46'40.94"N)
Band 1 Block=14850x32 Type=Byte, ColorInterp=Red
Band 2 Block=14850x32 Type=Byte, ColorInterp=Green
Band 3 Block=14850x32 Type=Byte, ColorInterp=Blue


The idea was to crop the raster image to smaller ones in order to generate area features from equal values for a few pal idx codes (I tried it on the entire file but it crashed). I must have done something wrong as the create areas process takes way too much.

I used EXPORT_RASTER FILENAME="C:\Downloads\Export\.tif" TYPE="GEOTIFF" /
GEN_PRJ_FILE="YES" COMPRESSION="LZW" POLYGON_CROP_FILE="%USASTATES%" /
POLYGON_CROP_USE_EACH="YES" POLYGON_CROP_NAME_ATTR="NAME"

The exported files now have only the RGB color. Is it possible to somehow add the pal idx back? I would really need it in the vector attribute table. Is it even possible to have the pal idx code in the attribute table?

Global Mapper creates the RGB column, gdal_polygonize.py some type of the pixel value of that polygon (but I did not recognize it to be RGB or PalIDx).

Comments

  • RobertRRobertR GlobalMapper Fan! Posts: 284Trusted User
    edited June 2013
    I will answer my own question..

    I added the PALETTE="KEEP_SOURCE" BG_TRANSPARENT=YES params and I guess it will do the job. Then, using gdal_polygonize.py I get exactly what I need in my vector attribute column.
Sign In or Register to comment.