<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">The Julia wrapper (ArchGDAL.jl) for `getfield` calls `OGR_FD_GetFieldDefn` and several related function (to get the type of the field etc.). Are these possibly expensive operations in GDAL?<div><br></div><div>Any C function in GDAL can easily be called from Julia. Which C function would get all fields at once? I assume that e.g. `OGR_F_GetFieldAsDoubleList` would not work; this would be for values that are themselves lists?</div><div><br></div><div>The Julia code for `getfield` spends quite a bit of work to find out the type of the field. This includes a bit of reference counting, allocating small structures on the heap, registering finalizers for them etc. This could be avoided by adding a Julia wrapper that calls `getfield` repeatedly (even from Julia, calling C has no overhead by itself) for a range of integers. This would avoid the additional overhead having to do with handling types, and the Julia/GDAL reference counting. Even, is that what you had in mind?</div><div><br></div><div>-erik</div><div><br></div><div><div><div><div><div><blockquote type="cite"><div>On Jun 24, 2025, at 11:01, Even Rouault via gdal-dev <gdal-dev@lists.osgeo.org> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">Hi,</p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">I don't know anything about Julia but I'd suspect that there must be something particularly slow in the way it interacts with C. For comparison,  "time python3 swig/python/gdal-utils/osgeo_utils/samples/ogrinfo.py  /vsigzip//vsicurl/<a class="moz-txt-link-freetext" href="https://bulk.meteostat.net/v2/hourly/2022/08554.csv.gz" style="color: rgb(70, 120, 134); text-decoration: underline;">https://bulk.meteostat.net/v2/hourly/2022/08554.csv.gz</a>  -al > /dev/null" that does essentially your loop, and also prints on stdout, runs in 1.5 seconds (compared to native ogrinfo that runs in 0.7 s). Perhaps you could write a Julia wrapper to get all fields of feature at once and return whatever dictionary or equivalent data structure is idiomatic (and efficient )in Julia ? Also are you sure your Julia wrapper is built with optimization enabled?<br></p><p style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">Even<br></p><div class="moz-cite-prefix" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">Le 24/06/2025 à 16:33, Joaquim Manuel Freire Luís via gdal-dev a écrit :<br></div><blockquote type="cite" cite="mid:AM6PR04MB6440E6D2A5A0C9EE48B5B050A678A@AM6PR04MB6440.eurprd04.prod.outlook.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div class="WordSection1" style="page: WordSection1;"><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span lang="PT">Hi,<o:p></o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><span lang="PT"><o:p> </o:p></span></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Im trying to read files like<span class="Apple-converted-space"> </span><o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><a href="https://bulk.meteostat.net/v2/hourly/2022/08554.csv.gz" moz-do-not-send="true" class="moz-txt-link-freetext" style="color: rgb(70, 120, 134); text-decoration: underline;">https://bulk.meteostat.net/v2/hourly/2022/08554.csv.gz</a><o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">in my Julia wrapper. The point is that, although I’m kind off succeeding, the hole operation is very slow.<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">What I’m doing (code not committed yet so can’t post a link) is to read like this<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">layer = getlayer(dataset, 0)<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">for f in layer<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">               for k = 1: Gdal.nfield(f)<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">                              Gdal.getfield(f, k-1)<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">…<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">This works but it’s extremely slow because each “getfield” takes about 1e-4 seconds and the file has ~8 k rows, each with 13 fields. That amounts to > 10 sec.<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">I’ve searched but couldn’t find a way to read the entire file at once (which takes 1e-2 seconds if I read it, locally, with a gzip wrapper) and return it as a single string array that I could parse later.<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Is that possible?<span class="Apple-converted-space"> </span><o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Thanks<o:p></o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;"><o:p> </o:p></div><div style="margin: 0in; font-size: 11pt; font-family: Aptos, sans-serif;">Joaquim<o:p></o:p></div></div><br><fieldset class="moz-mime-attachment-header"></fieldset><pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org" style="color: rgb(70, 120, 134); text-decoration: underline;">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" style="color: rgb(70, 120, 134); text-decoration: underline;">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre></blockquote><pre class="moz-signature" cols="72" style="caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com/" style="color: rgb(70, 120, 134); text-decoration: underline;">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">_______________________________________________</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">gdal-dev mailing list</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="mailto:gdal-dev@lists.osgeo.org" style="color: rgb(70, 120, 134); text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">gdal-dev@lists.osgeo.org</a><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" style="color: rgb(70, 120, 134); text-decoration: underline; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></div></blockquote></div><br></div></div></div></div></body></html>