Skip to content

Instantly share code, notes, and snippets.

@mdsumner
Last active October 22, 2025 13:31
Show Gist options
  • Save mdsumner/8dd5dc309452855d5b726df41459c4c3 to your computer and use it in GitHub Desktop.
Save mdsumner/8dd5dc309452855d5b726df41459c4c3 to your computer and use it in GitHub Desktop.

minute check on this PR in GDAL for GetRawBlockInfo

OSGeo/gdal#13260

from osgeo import gdal
gdal.UseExceptions()
ds = gdal.OpenEx("/vsicurl/https://thredds.nci.org.au/thredds/fileServer/gb6/BRAN/BRAN2023/daily/ocean_temp_2010_01.nc", gdal.OF_MULTIDIM_RASTER)
info  = temp.GetRawBlockInfo([0,0,0,0])
info.GetOffset()
#46353
info.GetSize()
#74186
info.GetFilename()
#'/vsicurl/https://thredds.nci.org.au/thredds/fileServer/gb6/BRAN/BRAN2023/daily/ocean_temp_2010_01.nc'
info.GetInfo()
#['COMPRESSION=DEFLATE', 'FILTER=SHUFFLE', 'ENDIANNESS=LITTLE']


from osgeo import ogr
v = ogr.Open("/vsicurl/https://github.com/mdsumner/virtualized/raw/refs/heads/main/ocean_temp_2023.parq/temp/refs.0.parq")
l = v.GetLayer(0)
f = l.GetNextFeature()
f.GetFieldAsString("offset")
#'46353'
f.GetFieldAsString("size")
#'74186'
@mdsumner
Copy link
Author

obvsly we need batch conversion of this

block_size = temp.GetBlockSize()
from osgeo import gdal
gdal.UseExceptions()
ds = gdal.OpenEx("/vsicurl/https://thredds.nci.org.au/thredds/fileServer/gb6/BRAN/BRAN2023/daily/ocean_temp_2010_01.nc", gdal.OF_MULTIDIM_RASTER)
info  = temp.GetRawBlockInfo([0,0,0,0])
sizes = temp.shape
import numpy
lens = numpy.array(sizes) // numpy.array(block_size)
n = numpy.prod(lens)
l = [None] *n
ii = -1 
for k in range(lens[0]): 
 for j in range(lens[1]): 
   for i in range(lens[2]):
     for h in range(lens[3]):
            info = temp.GetRawBlockInfo([k, j, i, h])
            ii = ii + 1
            l[ii] = info.GetOffset()
          

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment