[gdal-dev] Open source API to convert raster to polygons?

Ari Jolma ari.jolma at tkk.fi
Wed Jan 9 14:19:28 EST 2008


Ricardo Scachetti Pereira kirjoitti:
>    Hi all,
>      Does anyone know of any open source geoprocessing APIs that I can 
> use to convert raster maps into polygons (as a shapefile or SQL for 
> PostGIS)? Does QGIS do that?
>
>    I know that GDAL (via gdal_contour utility) can turn a raster into 
> lines, but that's not good enough for me. I need closed polygons that 
> I later intend to import into PostGIS. Gdal_contour would give usable 
> intermediate results (i.e, it produces lines that I think can be 
> turned into closed polygons), if it wasn't for the open polygons that 
> are created where the grid values touch NODATA values.
>
>    I have considered using GRASS (r.poly) but I need to embed the 
> geoprocessing library on an research application that I will deploy to 
> Windows desktop computers. To be completely honest, I can't even 
> install  GRASS on my Windows workstation, so I have no hopes of 
> deploying it via a neat installer :(( . That's probably due to the 
> lack of intelligence and patience, and is another story.
>
>    Any help with this would be greatly appreciated.

Dear Ricardo,

I've written a raster to polygon converter, which produces closed 
polygons from raster images. The algorithm is not speed optimized nor 
proven correct but quite ok. The polygons are OGR features and can thus 
be saved to PostGIS. This is, however, a method that I've written in 
Perl for the Geo::Raster class, which is a Perl interface to an 
in-memory libral raster. On the other hand, the Geo::Raster class 
contains methods to make or clip the raster from a raster opened with 
GDAL. These tools are available as Windows versions (the latest zip from 
http://map.hut.fi/files/Geoinformatica/snapshots/ which contains DLLs of 
the libraries and perl.exe and lots of Perl code).

A neat installer is possible, but the Geoinformatica distribution 
contains _a lot_ of files and is not very small. As a plus, 
Geoinformatica contains a GUI toolkit (GTK+ based)

If you're interested to try it out, I'll be glad to help as my time permits.

Regards,

Ari

>
>    Cheers,
>
> Ricardo Pereira
> Software Engineer and GIS Application Developer
>
>  
>   _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


-- 
Prof. Ari Jolma
Geoinformatiikka / Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




More information about the gdal-dev mailing list