[Gdal-dev] OGR Performance Intersection, Union

Jean Michel PIERRET jmp at geosys.com
Mon Jul 23 05:42:42 EDT 2007


Hi,
    I have a problem with the performance of OGR (Intersection, Union, ...),
it seem to be slower than the library GPC (Generic Polygon Clipper) which i
used before.     

Is it normal ?
Do you have solutions or answers ?

Jean-michel PIERRET - Poste  376
Tel : +33 (0)5 62 47 80 76
Mail : jmp at geosys.com
GEOSYS SA



-----Message d'origine-----
De : gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org] De la part de Jean Michel
PIERRET
Envoyé : mardi 17 juillet 2007 18:55
À : gdal-dev at lists.maptools.org
Objet : [Gdal-dev] OGR Performance Rasterize Contains Overlaps


Hi,
	
	I would like to get a matrix like with gdal_rasterize in c#, but
with the difference between pixels that are on polygon boundaries and pixels
that are completely inside polygon. It works with the following code but
it's very slow.

Thanks for your help.
Regards.

public void test()
{
	int [, ] mat = new int[width, height];
	Geometry geometry = Geometry.CreateFromWkt("...");

	//Browse each pixel of a raster
	for (i = 0, x = XUL; i < width; x += pixelsizeX, i++)	
      {
  	  for (j = 0, y = YUL; j < height; y += pixelsizeY, j++)
        {
		//x, y are the upper left corner of pixel
		double x1, y1, x2, y2, x3, y3, x4, y4;

		x1 = x;
		y1 = y;

		x2 = x1 + pixelsizeX; 
		y2 = y1;

		x3 = x1 + pixelsizeX; 
		y3 = y1 + pixelsizeY;

		x4 = x1; 
		y4 = y1 + pixelsizeY;

		Geometry geompixel =
Geometry.CreateFromWkt(string.Format("POLYGON(({0} {1}, {2} {3}, {4} {5},
{6} {7}, {0} {1}))", x1, y1, x2, y2, x3, y3, x4, y4));

		//get if pixel is overlap, contains or none by polygon
		if (geometry.Contains(geompixel))
			mat[i, j] = 2;	
		else if (geometry.Overlaps(geompixel))
			mat[i, j] = 1;
		else
			mat[i, j] = 0;

		geompixel.Dispose();
        }
	}

	geometry.Dispose();
}

Jean-michel PIERRET - Poste  376
Tel : +33 (0)5 62 47 80 76
Mail : jmp at geosys.com
GEOSYS SA


_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev





More information about the Gdal-dev mailing list