-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VRT: add a NoDataFromMaskSource source #9128
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rouault
force-pushed
the
NoDataFromMaskSource
branch
from
January 24, 2024 02:43
1c66e40
to
21a5024
Compare
rouault
force-pushed
the
NoDataFromMaskSource
branch
6 times, most recently
from
January 24, 2024 16:57
16409c3
to
c1a0a89
Compare
hobu
approved these changes
Jan 26, 2024
The NoDataFromMaskSource is derived from the SimpleSource and shares the same properties except that it replaces the value of the source with the value of the NODATA child element when the value of the mask band of the source is less or equal to the MaskValueThreshold child element. Also add a -nodata_if_mask_less_or_equal <threshol> option to gdalbuildvrt Example: ``` $ gdal_translate autotest/gcore/data/stefan_full_rgba.tif in.tif -a_srs EPSG:4326 -a_ullr -180 90 180 -90 $ gdalbuildvrt nodatafrommask.vrt in.tif -nodata_if_mask_less_or_equal 128 -vrtnodata 0 $ cat nodatafrommask.vrt <VRTDataset rasterXSize="162" rasterYSize="150"> <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, 2.2222222222222223e+00, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -1.2000000000000000e+00</GeoTransform> <VRTRasterBand dataType="Byte" band="1"> <NoDataValue>0</NoDataValue> <ColorInterp>Red</ColorInterp> <NoDataFromMaskSource> <SourceFilename relativeToVRT="1">in.tif</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="162" RasterYSize="150" DataType="Byte" BlockXSize="162" BlockYSize="12" /> <SrcRect xOff="0" yOff="0" xSize="162" ySize="150" /> <DstRect xOff="0" yOff="0" xSize="162" ySize="150" /> <MaskValueThreshold>128</MaskValueThreshold> <NODATA>0</NODATA> </NoDataFromMaskSource> </VRTRasterBand> <VRTRasterBand dataType="Byte" band="2"> <NoDataValue>0</NoDataValue> <ColorInterp>Green</ColorInterp> <NoDataFromMaskSource> <SourceFilename relativeToVRT="1">in.tif</SourceFilename> <SourceBand>2</SourceBand> <SourceProperties RasterXSize="162" RasterYSize="150" DataType="Byte" BlockXSize="162" BlockYSize="12" /> <SrcRect xOff="0" yOff="0" xSize="162" ySize="150" /> <DstRect xOff="0" yOff="0" xSize="162" ySize="150" /> <MaskValueThreshold>128</MaskValueThreshold> <NODATA>0</NODATA> </NoDataFromMaskSource> </VRTRasterBand> <VRTRasterBand dataType="Byte" band="3"> <NoDataValue>0</NoDataValue> <ColorInterp>Blue</ColorInterp> <NoDataFromMaskSource> <SourceFilename relativeToVRT="1">in.tif</SourceFilename> <SourceBand>3</SourceBand> <SourceProperties RasterXSize="162" RasterYSize="150" DataType="Byte" BlockXSize="162" BlockYSize="12" /> <SrcRect xOff="0" yOff="0" xSize="162" ySize="150" /> <DstRect xOff="0" yOff="0" xSize="162" ySize="150" /> <MaskValueThreshold>128</MaskValueThreshold> <NODATA>0</NODATA> </NoDataFromMaskSource> </VRTRasterBand> </VRTDataset> ```
rouault
force-pushed
the
NoDataFromMaskSource
branch
from
January 29, 2024 11:20
f72d17b
to
e2eaaf9
Compare
@rcoup did you get a chance to test this PR? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The NoDataFromMaskSource is derived from the SimpleSource and shares the same properties except that it replaces the value of the source with the value of the NODATA child element when the value of the mask band of the source is less or equal to the MaskValueThreshold child element.
Also add a --nodata_max_mask_threshold option to gdalbuildvrt
Example: