Skip to content

Commit

Permalink
Merge pull request #8534 from rouault/vrt_arraysource
Browse files Browse the repository at this point in the history
VRT: allow a <ArraySource> element containing a 2D multidimensional array as a VRTRasterBand source
  • Loading branch information
rouault authored Oct 18, 2023
2 parents 0de49a3 + 2b26a15 commit d26783d
Show file tree
Hide file tree
Showing 20 changed files with 1,606 additions and 4 deletions.
Binary file added autotest/gdrivers/data/netcdf/byte.nc
Binary file not shown.
Binary file added autotest/gdrivers/data/netcdf/test_gridded.nc
Binary file not shown.
18 changes: 18 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_array.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<Array name="foo">
<DataType>Byte</DataType>
<Dimension name="Y" size="20"/>
<Dimension name="X" size="20"/>
<Source>
<SourceFilename relativeToVRT="1">../netcdf/byte.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</Source>
</Array>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_derivedarray_getmask.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<GetMask/>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<GetUnscaled/>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
35 changes: 35 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_derivedarray_grid.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/test_gridded.nc</SourceFilename>
<SourceArray>/ar</SourceArray>
</SingleSourceArray>
<Step>
<Grid>
<GridOptions>invdist</GridOptions>
<XArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/test_gridded.nc</SourceFilename>
<SourceArray>/varX</SourceArray>
</SingleSourceArray>
</XArray>
<YArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/test_gridded.nc</SourceFilename>
<SourceArray>/varY</SourceArray>
</SingleSourceArray>
</YArray>
</Grid>
</Step>
<Step>
<View expr="[0,...]"/>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
15 changes: 15 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_derivedarray_no_step.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_derivedarray_resample.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<Resample/>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<VRTDataset rasterXSize="40" rasterYSize="40">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<Resample>
<Dimension name="Y" size="40"/>
<Dimension name="X" size="40"/>
<ResampleAlg>Bilinear</ResampleAlg>
<SRS>EPSG:4267</SRS>
<Option name="IGNORED">YES</Option>
</Resample>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_derivedarray_transpose.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<Transpose newOrder="1,0"/>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
18 changes: 18 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_derivedarray_view.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<View expr="[::-1,...]"/>
</Step>
</DerivedArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
13 changes: 13 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_singlesourcearray.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
20 changes: 20 additions & 0 deletions autotest/gdrivers/data/vrt/arraysource_srcrect_dstrect.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<VRTDataset rasterXSize="20" rasterYSize="20">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD27 / UTM zone 11N",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","26711"]]</SRS>
<GeoTransform> 4.4072000000000000e+05, 6.0000000000000000e+01, 0.0000000000000000e+00, 3.7513200000000000e+06, 0.0000000000000000e+00, -6.0000000000000000e+01</GeoTransform>
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Gray</ColorInterp>
<ArraySource>
<DerivedArray>
<SingleSourceArray>
<SourceFilename relativeToVRT="1">../netcdf/byte_no_cf.nc</SourceFilename>
<SourceArray>/Band1</SourceArray>
</SingleSourceArray>
<Step>
<View expr="[::-1,...]"/>
</Step>
</DerivedArray>
<SrcRect xOff="0" yOff="0" xSize="10" ySize="10"/>
<DstRect xOff="10" yOff="10" xSize="10" ySize="10"/>
</ArraySource>
</VRTRasterBand>
</VRTDataset>
Loading

0 comments on commit d26783d

Please sign in to comment.