[gdal-dev] reading/writing geometries using GDAL's MDA API

Even Rouault even.rouault at spatialys.com
Tue Aug 16 12:57:33 PDT 2022


Edzer,

The currently support data types for variables (including indexing 
variables of dimensions) or attributes are either numeric (byte, int, 
float, etc.), strings or compound data types of previous types. From a 
quick thinking, I can't think of strong reasons why OGRGeometry couldn't 
be added, baring some changes in GDAL core (looking for specificities of 
string support should give good hints where to make changes).

That said, it would probably only used by the netCDF driver, so it is a 
bit hard to justify to add a new abstraction for just one user 
(user=driver). And implementing that in the netCDF driver wouldn't 
necessarily be easy as it is already quite complicated and I'm not sure 
how reusable the part that deal with SG geometries is. On your examples, 
it is not immediately obvious to me how the driver would expose a 
OGRGeometry data type. In the first one, it would have to synthesize a 
t2_coord variable from t2_coordX and t2_coordY ? And on the second one a 
xy pseudo variable from x and y ? But it would be a bit convoluted for 
the users of the multi-dimensional indexed Precipitation to figure out 
that stations has a variable indexed by stations that has geometries.

So all in all, I believe it should be doable but the ratio 
benefit/effort doesn't seem to me to be super favorable.

Even

Le 16/08/2022 à 12:47, Edzer Pebesma a écrit :
> I've been using GDAL's C++ multidimensional array (MDA) API lately to 
> read and write data cubes from R - excellent work! I was looking into 
> support for vector data cubes, multidimensional arrays with a single 
> dimension associated with a set of geometries.
>
> What we can do is read and write dimensions, variables, and 
> attributes, but what (as far as I can tell) is missing is to read and 
> write OGRGeometry variables, using the CF specification for geometry 
> [1], which is supported by the NetCDF vector driver. Would it be 
> feasible to read and write CF-compliant geometries from 
> multidimensional arrays through the MDA API? Right now software 
> writers have to sort this out themselves, which is straightforward for 
> points but cludgy for polygons. Another issue is crs handling which I 
> think could be done gracefully using the OGRGeometry interface.
>
> As a minimal data example: I added two ncdump files below for two time 
> instances and two POINT geometries. The first can be read and written 
> by the OGR API, but is a one-dimensional array that lacks the time 
> information of time series (time distributed over attributes/columns). 
> The second is a 2 x 2 multidimensional array with the time 
> information. GDAL's MDA API can read it but doesn't recognize 
> geometries, GDAL's OGR API cannot read it (obviously). I'd like to be 
> able to read (and write) the station dimension of the second one as an 
> OGRGeometry, for points, lines or polygons.
>
> [1] 
> https://cfconventions.org/Data/cf-conventions/cf-conventions-1.9/cf-conventions.html#geometries

-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list