2

I have a SQLite database containing a GGA sentence in one of its fields. I'd like to display this information as a POINT layer.
I've looked at OGR Virtual Format solution as suggested here but I cannot define the Geometry field like in that solution as I do not have lat, lon readily available. I can create these 2 fields as computed fields but I can't get them to display.

If I do this:

<OGRVRTDataSource>
    <OGRVRTLayer name="test">
        <SrcDataSource>C:/Temp/SQLite/test.db</SrcDataSource> 
        <SrcLayer>table_test</SrcLayer>
        <Field name="GPGGA" />
        <GeometryType>wkbPoint</GeometryType>
            <LayerSRS>WGS84</LayerSRS>
    </OGRVRTLayer>
</OGRVRTDataSource>

The GPGGA field is available and I can compute the lat and lon fields (using the Field Calculator from the layer's properties' Fields section).
However, if I add the <GeometryField> definition below to my .vrt file :

<OGRVRTDataSource>
    <OGRVRTLayer name="test">
        <SrcDataSource>C:/Temp/SQLite/test.db</SrcDataSource> 
        <SrcLayer>table_test</SrcLayer>
        <Field name="GPGGA" />
        <GeometryType>wkbPoint</GeometryType>
            <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

The GPGGA field disappear from the available fields and consequently, the lat and lon fields do not compute properly.

I have looked at the GDAL help section but couldn't find the solution.

3
  • If you have only one field with all information in one string, than you'll have to split this string into fields somewhere. You can do it on import into the db, or via SQL altering the tabke structure or with query SQL/VRT-based. Another problem is the notation of your coordinates, the must be in the form of decimal degrees, but that needs to be calculated using N,S;E,W letters as well, because they determine if the coordinate value is positiv or negativ... Commented Mar 23, 2020 at 10:55
  • yes indeed, I can process the info and create fields in the db, but I was wondering if there is a way to do this step in the VRT Layer definition as I'd like to avoid touching the db at all if possible
    – YeO
    Commented Mar 23, 2020 at 11:02
  • gdal.org/drivers/vector/vrt.html#example-renaming-attributes could be a starting example, using SQL-Functions. But i fear, that will result in a rather complex expression. Commented Mar 23, 2020 at 11:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.