[gdal-dev] Gdal Mapinfo driver write access
Norman Vine
nhv at cape.com
Sat Feb 22 05:03:40 PST 2014
see http://www.gdal.org/ogr/drv_mitab.html
MapInfo datasets in native (TAB) format and in interchange (MIF/MID) format are supported for reading and writing.
Update of existing files is not currently supported.
On Feb 22, 2014, at 7:51 AM, HappyFrasse <fdr at cartesia.se> wrote:
>
> Hi
>
> I am trying to use the latest ogr/gdal library in my dotnet projekt. I do
> ref. to ogr_csharp, gdal_csharp.
> My problem is that I can read my Mapinfo tab-file but I can’t write (append)
> features to it and I don’t understand why?
>
> If I open the mapinfo file with Ogr.Open(_FileName, 0) I got write access
> error when using “CreateFeature”.
> If I change the second parameter to 1 (in open) then I won’t get any
> datasource. Why? Does ogr/gdal not support write /append to some existing
> mapinfo file?
>
> My code goes like:
>
> *****Code start ***
> Ogr.RegisterAll()
>
> 'Open data source.
> Dim dsTab As DataSource = Ogr.Open(_FileName, 0)
> 'Dim dsTab As DataSource = Ogr.Open(_FileName, 1)
> If dsTab Is Nothing Then
> System.Diagnostics.Debug.WriteLine("Can't open " + _FileName)
> End If
>
> 'Get driver
> Dim drvTab As Driver = dsTab.GetDriver()
> If drvTab Is Nothing Then
> System.Diagnostics.Debug.WriteLine("Can't get driver.")
> End If
> System.Diagnostics.Debug.WriteLine("Using driver " + drvTab.name)
>
> Dim layerTab As Layer = Nothing
> Dim i As Integer = 0
> Dim iLayers As Integer = dsTab.GetLayerCount
>
> layerTab = dsTab.GetLayerByIndex(0)
> Dim layerName As String = layerTab.GetName
> System.Diagnostics.Debug.WriteLine("Layername " + layerName)
>
> Dim feature As Feature = New Feature(layerTab.GetLayerDefn())
> feature.SetFID(Ogr.OGRNullFID)
>
> feature.SetField("TraktId", "Mytest_TraktId")
>
> Dim geom As Geometry = Geometry.CreateFromWkt("POINT(47.0 19.2)")
> If feature.SetGeometry(geom) <> 0 Then
> System.Diagnostics.Debug.WriteLine("Failed add geometry to the
> feature.")
> End If
>
> If layerTab.CreateFeature(feature) <> 0 Then
> System.Diagnostics.Debug.WriteLine("Failed to create feature in file.")
> End If
> *** code end ***
>
> Is my code wrong or do I missunderstood something?
>
> Regards/Frasse
>
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Gdal-Mapinfo-driver-write-access-tp5105252.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20140222/42442c34/attachment.html>
More information about the gdal-dev
mailing list