Thanks for the response Kyle. I do use the CreateDataSource() to create a new KML. But am unable to open an existing KML for editing using the Open() code I specified below.
Chris From: Kyle Shannon [mailto:kshan...@gcs-research.com] Sent: Monday, December 05, 2011 9:54 AM To: Pouliot, Christopher (DNR); gdal-dev@lists.osgeo.org Subject: RE: Editing KML files using ogr_csharp.dll Chris, I don' know OGR very well, but I see a few issues. I also am not sure about the c# bindings, I believe they are pretty complete though. '''OSGeo.OGR.Driver drv = Ogr.GetDriverByName("KML"); DataSource ds = drv.Open("c:\\temp\\mykml.kml", 1);''' Open() opens existing files, you need to use driver->CreateDatasource() to create datasets. Open() opens files for editing. If mykml.kml exists, use Open(). see http://gdal.org/ogr/ogr_apitut.html for information on using OGR to read/write data '''Also, when creating a KML file from scratch is there a way to map the Name and Description fields to my existing fields so that the Name and Description appear in Google Earth?''' See http://gdal.org/ogr/drv_kml.html for this, it appears to be possible. There is also the libkml driver: http://gdal.org/ogr/drv_libkml.html kss From: gdal-dev-boun...@lists.osgeo.org [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of Pouliot, Christopher (DNR) Sent: Monday, December 05, 2011 7:51 AM To: gdal-dev@lists.osgeo.org Subject: [gdal-dev] Editing KML files using ogr_csharp.dll Hello All, I have a C# application that uses OGR_CSHARP.DLL to read/write KML files. I'm able to read from KML files fine. I'm able to create a new KML file and write to it fine. I am unable, however, to open a KML file to edit. I'd like to be able to append a new layer (folder) onto an existing KML file. I've tried both of the following code snippets: //This returns NULL OSGeo.OGR.Driver drv = Ogr.GetDriverByName("KML"); DataSource ds = drv.Open("c:\\temp\\mykml.kml", 1); //This returns NULL DataSource ds = Ogr.Open("c:\\temp\\mykml.kml", 1); I'm able to use this code to edit File Geodatabases and Shapefiles but not KML. Also, when creating a KML file from scratch is there a way to map the Name and Description fields to my existing fields so that the Name and Description appear in Google Earth? Thanks, Chris Chris Pouliot GIS Application Developer Minnesota Department of Natural Resources christopher.poul...@state.mn.us<mailto:christopher.poul...@state.mn.us> (651) 259-5491 This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and delete the original message.
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev