Skip to content

Conversation

@juanrmn
Copy link
Member

@juanrmn juanrmn commented Jul 8, 2025

Issue

Fixes #

Proposed Changes

Adding new metadata field by band as valuelabels dict of value-labels pairs. i.e:

{
  "band_1": {
    "colorinterp": "palette",
    "nodata": 0,
    "valuelabels": {
      "1": "Corn",
      "5": "Soybeans",
      "21": "Barley",
      "121": "Developed/Open Space"
    },
    "colortable": {
      "1": [255, 211, 0, 255],
      "5": [37, 111, 0, 255],
      "21": [226, 0, 124, 255],
      "121": [153, 153, 153, 255]
    }
  }
}

This dictionary will be obtained from the command line parameter. It can be by adding the --band-valuelabels:

$ carto bigquery upload --help
[...]
 --band-valuelabels TEXT      Custom data for valuelabels in JSON format, or
                               'None'. i.e: '{<value_1>: <label_1>, <value_2>:
                               <label_2>, ...}'. Could repeat --band-
                               valuelabels to specify multiple bands data.
                               They will be considered in the order they
                               appear in the file. Note that you can set any
                               value to 'None' to omit valuelabels for that
                               band.
  -h, --help                   Show this message and exit.

For example (Note the Using the provided valuelabels for band 1 in the output:

carto bigquery upload --file_path Annual_NLCD_LndCov_2023_CU_C1V0-dbf/Annual_NLCD_LndCov_2023_CU_C1V0.tif --project cartodb-on-gcp-backend-team --dataset juanra --table Annual_NLCD_LndCov_2023_CU_C1V0_Custom --overwrite --token ya29.XXX --band-valuelabels '{"90": "Woody Wetlands", "52": "Shrub/Scrub", "12": "Perennial Ice/Snow", "81": "Pasture/Hay", "11": "Open Water", "43": "Mixed Forest", "71": "Grassland/Herbaceous", "42": "Evergreen Forest", "21": "Developed, Open Space", "23": "Developed, Medium Intensity", "22": "Developed, Low Intensity", "24": "Developed High Intensity", "41": "Deciduous Forest", "82": "Cultivated Crops", "31": "Barren Land (Rock/Sand/Clay)"}'

Preparing to upload raster file to BigQuery...
File Path: Annual_NLCD_LndCov_2023_CU_C1V0-dbf/Annual_NLCD_LndCov_2023_CU_C1V0.tif
File Size: 0.04869270324707031 MB
Number of bands: 1
Band types: ('uint8',)
Band sizes (MB): [1.5]
Source Band: (1,)
Band Name: [None]
Number of Blocks: 6
Block Dims: (512, 512)
Project: cartodb-on-gcp-backend-team
Dataset: juanra
Table: Annual_NLCD_LndCov_2023_CU_C1V0_Custom
Number of Records Per BigQuery Append: 10000
Compress: False
Uploading Raster to BigQuery
Loading raster file to BigQuery...
Sampling raster...
Computing approximate stats...
Computing quantiles...
Computing most common values...
Using the provided valuelabels for band 1
Writing 6 blocks and 3 overview tiles to BigQuery...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:07<00:00,  1.16it/s]
Number of empty blocks:  0
Writing metadata to BigQuery...
Updating labels...
Done.
Raster file uploaded to Google BigQuery
image

@juanrmn juanrmn marked this pull request as ready for review July 8, 2025 11:25
@juanrmn juanrmn requested review from cayetanobv and migurski July 8, 2025 11:25
Copy link
Member

@cayetanobv cayetanobv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@juanrmn juanrmn merged commit 9060dfd into main Jul 10, 2025
4 checks passed
@juanrmn juanrmn deleted the feature/sc-488704/support-labeldescription-in-raster-loader-only-param branch July 10, 2025 06:30
@juanrmn juanrmn mentioned this pull request Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants