On Thu, 7 Jan 2016 11:09:10 AM Even Rouault wrote: > gdal_translate -of VRT -a_nodata will not remap values, but just change the > declared nodata value. That is in the docs, but was still a little unexpected :-)
I did the gdalwarp solution, but as the source data gets larger, then the resource cost of duplicating all the data goes up. > You can though manually post-edit the VRT to make the SimpleSource a > ComplexSource and add a NODATA node, as below: > > <VRTDataset rasterXSize="2" rasterYSize="2"> > <GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, > 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, > -6.0000000000000000e+01</GeoTransform> > <Metadata> > <MDI key="AREA_OR_POINT">Area</MDI> > </Metadata> > <VRTRasterBand dataType="Float32" band="1"> > <NoDataValue>99999</NoDataValue> > <ColorInterp>Gray</ColorInterp> > <ComplexSource> > <SourceFilename relativeToVRT="1">in.asc</SourceFilename> > <SourceBand>1</SourceBand> > <SourceProperties RasterXSize="2" RasterYSize="2" DataType="Float32" > BlockXSize="2" BlockYSize="1" /> > <SrcRect xOff="0" yOff="0" xSize="2" ySize="2" /> > <DstRect xOff="0" yOff="0" xSize="2" ySize="2" /> > <NODATA>nan</NODATA> > </ComplexSource> > </VRTRasterBand> > </VRTDataset> > > > Which can also be accomplished with gdalbuildvrt and the -vrtnodata switch > without any manual editing: > > $ gdalbuildvrt out2.vrt in.asc -vrtnodata 0 > > $ cat out2.vrt > <VRTDataset rasterXSize="2" rasterYSize="2"> > <GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, > 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, > -6.0000000000000000e+01</GeoTransform> > <VRTRasterBand dataType="Float32" band="1"> > <NoDataValue>0</NoDataValue> > <ColorInterp>Gray</ColorInterp> > <ComplexSource> > <SourceFilename relativeToVRT="1">in.asc</SourceFilename> > <SourceBand>1</SourceBand> > <SourceProperties RasterXSize="2" RasterYSize="2" DataType="Float32" > BlockXSize="2" BlockYSize="1" /> > <SrcRect xOff="0" yOff="0" xSize="2" ySize="2" /> > <DstRect xOff="0" yOff="0" xSize="2" ySize="2" /> > <NODATA>nan</NODATA> > </ComplexSource> > </VRTRasterBand> > </VRTDataset> > > $ gdal_translate out2.vrt /vsistdout/ -of aaigrid > ncols 2 > nrows 2 > xllcorner 440720.000000000000 > yllcorner 3751200.000000000000 > cellsize 60.000000000000 > NODATA_value 0 > 0.0 123 > 115 132 Thanks - very nice solution. Brad _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
