Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active May 27, 2024 00:02
Show Gist options
  • Save mdsumner/4cdd7b5c92e7c69fe766e1fc19ac16b5 to your computer and use it in GitHub Desktop.
Save mdsumner/4cdd7b5c92e7c69fe766e1fc19ac16b5 to your computer and use it in GitHub Desktop.

Reset the bounds, drop dataset and band level metadata, assign the crs, and set scale/offset to Celsisus, note the '{ghrsstsource}' for sprintf use from local netcdf file or url (will need subdataset via vrt:// or DRIVER:{src}:sds syntax):

<VRTDataset rasterXSize="36000" rasterYSize="17999">
  <SRS dataAxisToSRSAxisMapping="2,1">GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]</SRS>
  <GeoTransform> -1.8000000000000000e+02,  1.0000000000000000e-02,  0.0000000000000000e+00,  8.9990499999999997e+01,  0.0000000000000000e+00, -9.9994999722206792e-03</GeoTransform>
  <Metadata>
    <MDI key="AREA_OR_POINT">Area</MDI>
  </Metadata>
  <Metadata domain="IMAGE_STRUCTURE">
    <MDI key="INTERLEAVE">BAND</MDI>
    <MDI key="COMPRESSION">ZSTD</MDI>
  </Metadata>
  <VRTRasterBand dataType="Int16" band="1" blockXSize="1024" blockYSize="1024">
    <NoDataValue>-32768</NoDataValue>
    <Offset>25</Offset>
    <Scale>0.001</Scale>
    <ColorInterp>Gray</ColorInterp>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">{ghrsstsource}</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="36000" RasterYSize="17999" DataType="Int16" BlockXSize="1024" BlockYSize="1024" />
      <SrcRect xOff="0" yOff="0" xSize="36000" ySize="17999" />
      <DstRect xOff="0" yOff="0" xSize="36000" ySize="17999" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment