do you want some examples? I'm happy to work on several of the cases - rasterio, odc-geo, rioxarray, and maybe the raster_tools and geoutils.
I'm interested to show how I would go about this, and discuss the various idioms available for GDAL (and how those are seen via various downstream packages).
At any rate I'm keen to discuss so I hope this is welcome.
osgeo.gdal
Here I'm using GDAL syntax for "vrt://" which saves us from some more awkward changes on Open() or via VRT otherwise.
## the file is here
#srcurl = "https://archive.podaac.earthdata.nasa.gov/podaac-ops-cumulus-protected/MUR-JPL-L4-GLOB-v4.1/20020601090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc"
## and it's best to fix the extent, else the warper goes a less efficient pathway (from the imprecise lon,lat arrays)
## https://discourse.pangeo.io/t/fixing-ghrsst-seeking-opinions/3833/6?u=michael_sumner
#dsn = f'vrt:///vsicurl/{srcurl}?a_ullr=-179.995,89.995,180.005,-89.995&sd_name=analysed_sst'
## we need earthdata creds, which I have in a file so
#import os
#os.environ["GDAL_HTTP_HEADER_FILE"] = "/home/mdsumner/earthdata"
## if we don't want to stream, we can ignore everything above (maybe this is in our earthaccess_data/)
dsn = f'vrt://20020601090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.nc?a_ullr=-179.995,89.995,180.005,-89.995&sd_name=analysed_sst'
## what's our target tile? (we want native res I expect so we won't supply any other args)
te = [100, -60, 100 + 256/100, -60 + 256/100] ## probably I need to be more careful to align to source pixel edges
from osgeo import gdal
gdal.UseExceptions()
ds = gdal.Open(dsn)
## we can get a "live" dataset or virtual one "/vsimem" or an actual file
wds = gdal.Warp("/tmp/tile.tif", ds, outputBounds = te)
wds.RasterXSize
#256
wds.RasterYSize
#256
wds.GetDescription()
#'/tmp/tile.tif'
wds.GetGeoTransform()
# (100.0, 0.010000000000000009, 0.0, -57.44, 0.0, -0.010000000000000009)
do you want some examples? I'm happy to work on several of the cases - rasterio, odc-geo, rioxarray, and maybe the raster_tools and geoutils.
I'm interested to show how I would go about this, and discuss the various idioms available for GDAL (and how those are seen via various downstream packages).
At any rate I'm keen to discuss so I hope this is welcome.
osgeo.gdal
Here I'm using GDAL syntax for "vrt://" which saves us from some more awkward changes on Open() or via VRT otherwise.