[Gdal-dev] seg fault with ogr2ogr

palmerj at xtra.co.nz palmerj at xtra.co.nz
Wed Jan 11 17:30:10 EST 2006


Hi,

I recently upgraded postgresql 8.1.0/postgis 1.04 and gdal 1.3.1 from 7.4.2/0.9/1.2.6 on a redhat 9.0 box. I have been using pg and postgres with no problems for the last 3 months or so, but I have not used ogr2ogr until now. 

Under 1.2.6 I used to be able to run a command like this with no problems:

ogr2ogr -f "Mapinfo File" testgis PG:dbname=testgis \
-sql "SELECT id,
             getappspecific(id,'SURV', 'Y') AS appellation, 
             transform(translate(shape, 160,0,0),27200) 
      FROM   crs_parcel 
      WHERE  status = 'CURR' 
      AND    toc_code ='PRIM' 
      AND    parcel_intent <> 'ROAD' 
      AND    parcel_intent <> 'HYDR'" \
-nln parcel \
-a_srs 'EPSG:27200'

However under postgis 1.0 and gdal 1.3.1 this now segfaults.

I think it seems to be the way ogr2ogr is running the specified sql statement, because I tried an alternative of creating a view in the database and populating the geometry_column table. 

i.e.

CREATE OR REPLACE VIEW hydro_parcel 
    AS
SELECT id, 
       transform(translate(shape, 160,0,0),27200) as shape
FROM   crs_parcel 
WHERE  status = 'CURR' 
AND    toc_code ='PRIM' 
AND    parcel_intent <> 'ROAD' 
AND    parcel_intent <> 'HYDR';

INSERT INTO geometry_columns (f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, type) VALUES ('', 'public', 'hydro_parcel', 'shape', 2, 27200, 'MULTIPOLYGON');


I then using the following ogr2gr  layer creation command:

ogr2ogr -f "MapInfo File" -a_srs EPSG:27200 testgis PG:dbname=testgis hydro_parcel

It and works!

Note when using the -sql option I tried simpler queries like 'SELECT id, shape FROM crs_parcel' But I still get a seg fault. I have also tried different postgis layers with different geometry type and have had interesting results. One postgis layer that had both geometry types of “point” and “linestring” seemed to get into an infinite loop (so it did not seg fault like the others) when creating the .map file. The command I used was:

ogr2ogr -f "MapInfo File" testgis PG: dbname=testgis -sql "SELECT id, shape FROM crs_vector" -nln crs_vector -s_srs EPSG:4326

 I stopped the creation of the mapinfo dataset once the .map file reach 1.5gb

I again used the layer selection creation approach not using the –sql switch:

ogr2ogr -f "MapInfo File" testgis PG: dbname=testgis crs_vector

and everything worked ok and a correct dataset of about 300mb was created

Any ideas on what is causing these issues with the ogr2ogr?

Thanks

Jeremy Palmer





More information about the Gdal-dev mailing list