vapour icon indicating copy to clipboard operation
vapour copied to clipboard

kernel Coefs garbled

Open mdsumner opened this issue 3 years ago • 0 comments

why does this happen when the VRT is written out via CreateCopy?

  int   nBand = 1;
  GDALDriver *poDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
  GDALDataset *poSrcDS, *poVRTDS;
  
  
  poSrcDS = (GDALDataset *) GDALOpenShared( dsn[0], GA_ReadOnly );
  
  poVRTDS = poDriver->CreateCopy( "", poSrcDS, FALSE, NULL, NULL, NULL );
    
  char szFilterSourceXML[10000];
    
    GDALRasterBand *poBand = poVRTDS->GetRasterBand( nBand );
    char* filename = dsn[0]; 
    sprintf( szFilterSourceXML,
             "<KernelFilteredSource>"
             "  <SourceFilename>%s</SourceFilename><SourceBand>%d</SourceBand>"
             "  <Kernel>"
             "    <Size>13</Size>"
             "    <Coefs>0.01111 0.04394 0.13534 0.32465 0.60653 0.8825 1.0 0.8825 0.60653 0.32465 0.13534 0.04394 0.01111</Coefs>"
             "  </Kernel>"
             "</KernelFilteredSource>",
             filename, nBand );
    Rprintf("\n\n%s\n\n", szFilterSourceXML); 
    poBand->SetMetadataItem( "source_0", szFilterSourceXML, "vrt_sources" );

    // just a hack to get the VRT text via tempfile (handle in R)
    GDALDriver *potempVRTDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
    GDALDataset *potempVRTDS;

    potempVRTDS = potempVRTDriver->CreateCopy( tempfile[0], poVRTDS, FALSE, NULL, NULL, NULL );
    GDALClose((GDALDatasetH) potempVRTDS);

  return tempfile; 

we get this:

<VRTDataset rasterXSize="13335" rasterYSize="13341">
  <SRS dataAxisToSRSAxisMapping="1,2">PROJCS["WGS_1984_Antarctic_Polar_Stereographic",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Polar_Stereographic"],PARAMETER["latitude_of_origin",-71],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1],AXIS["Easting",NORTH],AXIS["Northing",NORTH]]</SRS>
  <GeoTransform> -3.3335000000000014e+06,  5.0000000000000000e+02,  0.0000000000000000e+00,  3.3335000000000023e+06,  0.0000000000000000e+00, -5.0000000000000000e+02</GeoTransform>
  <Metadata>
    <MDI key="AREA_OR_POINT">Area</MDI>
  </Metadata>
  <Metadata domain="IMAGE_STRUCTURE">
    <MDI key="INTERLEAVE">BAND</MDI>
  </Metadata>
  <VRTRasterBand dataType="Float32" band="1">
    <Metadata>
      <MDI key="STATISTICS_MAXIMUM">4082,1091308594</MDI>
      <MDI key="STATISTICS_MEAN">-1370,4777909598</MDI>
      <MDI key="STATISTICS_MINIMUM">-7390,7299804688</MDI>
      <MDI key="STATISTICS_STDDEV">3002,5909061056</MDI>
    </Metadata>
    <NoDataValue>-3.4028234663852886e+38</NoDataValue>
    <ColorInterp>Gray</ColorInterp>
    <KernelFilteredSource>
      <SourceFilename relativeToVRT="0">.../hs.pangaea.de/Maps/bathy/IBCSO_v1/ibcso_v1_is.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <Kernel normalized="0">
        <Size>13</Size>
        <Coefs>0.01111 0.04394 0.13534 0.32465 0.60653 0.8825 1 0.8825 0.60653 0.32465 0.13534 0.04394 0.01111 3.2114267e-322 9.8813129e-324 4.6831798e-310 4.6831734e-310 4.6831798e-310 0 0 0 1.6304166e-322 0 0 4.6831794e-310 1.6304166e-322 6.9459994e-310 2.1219958e-314 4.6831798e-310 6.3734468e-322 6.9460034e-310 4.6831872e-310 5.5081593e-310 2.9643939e-322 0.017453293 9.8813129e-324 4.6831798e-310 1.9762626e-323 4.6718451e-310 4.6831798e-310 4.6831798e-310 1.9762626e-323 4.6718275e-310 6.9460034e-310 6.3240403e-322 5.5335352e-322 4.6831798e-310 4.6831581e-310 0.13534 0.32465 0.60653 0.8825 1 0.8825 0.60653 0.32465 0.13534 0.04394 0.01111 7.1639519e-322 4.6831809e-310 4.6831798e-310 4.6831798e-310 6.9459994e-310 4.6831825e-310 6.9459994e-310 6.9459994e-310 4.6831798e-310 4.6831581e-310 6.9459994e-310 4.6831798e-310 4.6831798e-310 4.6831794e-310 1.6304166e-322 4.6831797e-310 4.6831798e-310 7.1145453e-322 2.3715151e-322 1.5810101e-322 3.9838611e+252 5.285559e+180 4.6831798e-310 4.6831798e-310 2.4209217e-322 1.5810101e-322 6.8991026e-310 7.6851981e+170 5.9461409e-310 4.6831798e-310 2.4209217e-322 1.5810101e-322 6.8991242e-310 4.6831798e-310 1.9762626e-323 4.9008331e+252 2.4209217e-322 1.5810101e-322 7.6851981e+170 5.9461409e-310 1.2639023e-298 4.6831798e-310 3.2114267e-322 1.5810101e-322 4.7648476e+180 3.5006299e+151 2.2151179e-312 1.263895e-298 1.7557503e+189 3.1620201e-322 4.0019317e-322 4.9406565e-324 4.6831872e-310 0 4.6831798e-310 4.6831872e-310 5.5335352e-322 5.5335352e-322 4.6831809e-310 4.6831798e-310 2.4209217e-322 1.5810101e-322 7.6851981e+170 5.9461409e-310 4.6831798e-310 4.6831798e-310 2.4209217e-322 1.5810101e-322 3.8088198e+180 4.7448028e+170 5.9460447e-310 4.6831798e-310 2.4209217e-322 1.5810101e-322 1.4951718e+151 4.52687e-307 1.9762626e-323 4.2446354e-315 2.4209217e-322 1.5810101e-322 6.8991242e-310 2.9149873e-322 4.0562454e+228 4.6831798e-310 3.2114267e-322 1.5810101e-322 7.6851981e+170 5.9461409e-310 4.9406565e-324 1.9626515e+243 3.5076651e+151 3.1620201e-322 1.1906982e-321 0 6.9459994e-310 4.6831798e-310 4.6831798e-310 4.6831798e-310 0 0 0 0 4.6831798e-310 0 0 0 0 4.6831798e-310 0 0 </Coefs>
      </Kernel>
    </KernelFilteredSource>
  </VRTRasterBand>
</VRTDataset>

mdsumner avatar Feb 16 '22 01:02 mdsumner