[gdal-dev] Writing Shapefiles

Mateusz Loskot mateusz at loskot.net
Tue Feb 5 05:18:40 EST 2008


Romain Garrigues wrote:
> Now i'm trying to write data contained in an OGRDataSource pointer.
> Is there an easy way to do that ? (a Write() similar to Open() method ?)
> Tutorial just show how to write a shapefile from scratch, that's not my 
> case, and i don't see atm how to do this "easily" if i already have data 
> in an OGRDataSource.

Romain,

Could you be more specific what you mean as "write data contained in 
OGRDataSource" ?

The tutorial (http://gdal.org/ogr/ogr_apitut.html) presents all 
necessary steps to:
- create datasource and layer for shapefile
- create schema
- write attributes data
- write geometry

If you want to add features to existing shapefile, then open it in 
update mode [1] and create [2] and write [3] new features into it.

[1]
http://gdal.org/ogr/classOGRSFDriverRegistrar.html#5ee13e09d55d146f45bb5417fa524f54

[2]
http://gdal.org/ogr/classOGRFeature.html#0ef4455f24cfbec6cf37110f9116cf15

[3]
http://gdal.org/ogr/classOGRLayer.html#aa1e32016f481596a55e1d988a15a067

Regards
-- 
Mateusz Loskot
http://mateusz.loskot.net


More information about the gdal-dev mailing list