[gdal-dev] Reading an OSM file

Gökçen Eraslan gokcen.eraslan at gmail.com
Sun Jun 21 05:07:28 PDT 2015


Hi everyone,

I am trying to read an OSM file which I downloaded from geofabrik.
Although I can get the OSM driver by name (readonly), I get nothing when
I try to open the data source in which several .osm and osm.bz2 files
present:

----
#include "ogrsf_frmts.h"

int main()

{
    OGRRegisterAll();

    OGRDataSource       *poDS;
    OGRSFDriverRegistrar *reg = OGRSFDriverRegistrar::GetRegistrar();
    OGRSFDriver *osmdrv = reg->GetDriverByName("OSM");

    if( osmdrv == NULL )
    {
        printf( "OSM driver open failed.\n" );
        exit( 1 );
    }

    poDS = OGRSFDriverRegistrar::Open( ".", FALSE );
    if( poDS == NULL )
    {
        printf( "Open failed.\n" );
        exit( 1 );
    }
    return 0;
}
----

Program only prints the message "Open failed". I can also see OSM
(readonly) in "ogrinfo --formats" output. I would appreciate if someone
could help me out.

PS: I am using gdal 1.11.2. Actually, what I would like to do is to read
the file from within R through rgdal but it seems I cannot even read the
file at C level via libgdal.

Thanks in advance.

Best regards.
Gokcen.


More information about the gdal-dev mailing list