[gdal-dev] Fields of type List to simple fields with N times the feature?

Even Rouault even.rouault at spatialys.com
Fri Jan 19 08:09:16 PST 2024


Le 19/01/2024 à 16:54, Abel Pau via gdal-dev a écrit :
>
> Hello,
>
> we have tried to generate some layers from MiraMon to SHP, KML, or 
> GPKG, and we have noticed that they do not support "List" field cases. 
> They give a warning like: "The output driver does not seem to natively 
> support IntegerList type for field “XX”.
>
> It could be interesting if a driver could output a feature with "List" 
> type fields as the same feature repeated as many times as the elements 
> in the List, if the user requests it (via –lco). This would be 
> beneficial to avoid losing elements from fields that are of type List.
>
> The current implementation generates an IntegerList, but this 
> modification could be done.
>
> As we want to export the information somehow, even if it's not 
> perfect, we are wondering which of these solutions we can apply:
>
> 1. (preferable) export N objects, each with a single attribute, not as 
> an "IntegerList" but as N "Integer/Float, etc" objects.
>
> 2. export a single object with a single attribute (which could be 
> chosen with a -lco).
>
> However, we are wondering how we should handle the GetFeatureCount() 
> function in case 1 (from the above).
>
> And we also wonder how to handle the GetNextRawFeature() function. 
> Since this function can indicate that it has returned more than one 
> element (in case 1).
>
Don't complicate your driver. This is just a usage issue of ogr2ogr. As 
hinted by it, you need to pass for example -mapFieldType 
IntegerList=String to ask ogr2ogr to transform IntegerLst fields into string


$ cat test.json
{
"type": "FeatureCollection",
"name": "test",
"features": [
{ "type": "Feature", "properties": { "id": 1, "attr": [2,3] }, 
"geometry": null }
]
}

$ ogr2ogr out.shp test.json -mapFieldType IntegerList=String

$ ogrinfo out.shp -al -q

Layer name: out
Metadata:
   DBF_DATE_LAST_UPDATE=2024-01-19
OGRFeature(out):0
   id (Integer) = 1
   attr (String) = (2:2,3)

Even

> Thanks for taking it in consideration.
>
> *Abel Pau Garcia*
>
> *GIS developer*
>
> 	
>
> https://www.creaf.cat/sites/default/files/creaf-signature.png
>
> *a.pau at creaf.uab.cat* <mailto:a.pau at creaf.uab.cat>
>
> *Let's chat on Teams!* 
> <https://teams.microsoft.com/l/chat/0/0?users=a.pau@creaf.uab.cat>
>
> *Tel. +34 934814277*
>
> 	
>
> https://www.creaf.cat/sites/default/files/so-en-signature.png
>
> https://www.creaf.cat/sites/default/files/twitter-icon-signature.png 
> <https://twitter.com/CREAF_ecologia>https://www.creaf.cat/sites/default/files/linkedin-icon-signature.png 
> <https://www.linkedin.com/company/1363052?trk=tyah&trkInfo=clickedVertical:company,clickedEntityId:1363052,idx:2-1-2,tarId:1465807877789,tas:creaf>https://www.creaf.cat/sites/default/files/youtube-icon-signature.png 
> <https://www.youtube.com/c/creafecologia>https://www.creaf.cat/sites/default/files/instagram-icon-signature.png 
> <https://www.instagram.com/CREAF_ecologia/>
>
> *www.creaf.cat* <http://www.creaf.cat>*| **http://blog.creaf.cat* 
> <http://blog.creaf.cat>
>
> 	
>
> https://www.creaf.cat/sites/default/files/uab_logo_signatura.png
>
> CREAF. Campus UAB. Edifici C. 08193 Bellaterra (Barcelona)
>
>
> Before printing this electronic message, think about the environment.
>
> http://www.creaf.uab.cat/_signatura/line.gif
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3657 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 2547 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 505 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 446 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0009.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 553 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0010.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.png
Type: image/png
Size: 582 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0011.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image007.jpg
Type: image/jpeg
Size: 2208 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image008.jpg
Type: image/jpeg
Size: 1111 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240119/72d8f55b/attachment-0003.jpg>


More information about the gdal-dev mailing list