On May 21, 2009, at 2:32 PM, Frank Warmerdam wrote:

Jeff Hamann wrote:
Frank,
I was trying to use the las2ogr tool, and wanted to export the results to a PostGIS database I have developed and noticed that the las2ogr tool only exported shapefiles. I've had some experience adding additional tags (timestamps) into the KML outputs for OGR, but haven't worked with much of the gdal/ogr code beyond that. I think I've got the chops to wire it up, but have no time (read cash) to pay for it and so I've decided I have to do it myself. I know I can export the las files to shapefiles, and import the shapefiles that way, but would like to read the las files directly into my database. Any suggestions would be great and I would like to contribute to gdal/ogr very much.

Jeff,

I have taken the liberty of cc:ing Howard Butler who I presume is the author
of las2ogr.

In *theory* it should be pretty straight forward to alter the las2ogr
code a bit to use the PG driver instead of the "ESRI Shapefile" driver.

Actually, looking at the code:

 http://liblas.org/browser/trunk/apps/las2ogr.cpp

It seems it already supports selecting alternate output drivers. However, it assumes it will always be creating the target datasource object while in the case of PostGIS we will want to open an existing database and just
create a new layer.

Try altering:

       OGRSFDriverH drv = OGRGetDriverByName(out_frmt.c_str());
       if (0 == drv)
       {
throw std::runtime_error(out_frmt + " driver not available");
       }

ogr_wrapper<OGRDataSourceH> ds(OGR_Dr_CreateDataSource(drv, out_file.c_str(), 0), OGR_DS_Destroy);


To something like:

ogr_wrapper<OGRDataSourceH> ds( OGROpen( out_file.c_str(), TRUE, NULL ));

Assuming out_file is the name of a postgres database - something like
"PG:dbname=warmerda ...", then it should be opened in update mode. Then
(hopefully) all the rest of the stuff will just work.

Mateusz was actually the author of las2ogr.

These types of questions would best be asked on the liblas-devel mailing list http://lists.osgeo.org/mailman/listinfo/liblas-devel , which I have cc'd here in case other wonder about such an issue.

We would gladly take a patch that would notices the user attempting to use the PostGIS driver and switch from doing a CreateDataSource to an OGROpen as appropriate.

Thanks,

Howard
_______________________________________________
Liblas-devel mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/liblas-devel

Reply via email to