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

Joaquim Luis jluis at ualg.pt
Wed Jan 9 15:11:07 EST 2008


Ari Jolma wrote:
> 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).

Hi,
I am sorry but I have some difficulties in understanding this discussion.
What is a raster to polygon conversion?
I know, and have played with, vectorizing edge detected images, shape 
detection of simple forms like ellipses, lines, ridge crests on DTMs etc...
but for each of these goals the tools/algorithms used are different. 
What I do not understand is what is a generic "raster to polygon 
conversion".

Joaquim Luis



More information about the gdal-dev mailing list