ExecuteIntersectionQuery return only the Polygon Geometry cenroid when using with GDalRasterLayer

Topics: Data Access
Mar 24, 2015 at 7:35 AM
Edited Mar 24, 2015 at 8:23 AM
I'm using the GDalRasterLayer to open an elevation image with .tif extension it contains a 1 band with the elevation in 30m accuracy.

It only return one row value which is the centroid of the polygon but what i need is the whole points elevation which contained by the polygon from the raster layer.

In other words How to Intersecting a raster elevation image with a polygon with many points.

Here is the code i used
Private m_GDalRasterLayer As GdalRasterLayer

m_GDalRasterLayer = New GdalRasterLayer("Elevation Layer", "C:\testimage.tif")

Dim points As List(Of GeoAPI.Geometries.Coordinate) = New List(Of Coordinate)

        points.Add(New Coordinate(X1, Y1))
        points.Add(New Coordinate(X2, Y2))
        points.Add(New Coordinate(X3, Y3))
        points.Add(New Coordinate(X4, Y4))
        points.Add(New Coordinate(X5, Y5))

Dim mLinearRing As New NetTopologySuite.Geometries.LinearRing(points.ToArray())

Dim mPolygon As New Geometries.Polygon(mLinearRing)

Dim ds As New SharpMap.Data.FeatureDataSet

Call m_GDalRasterLayer.ExecuteIntersectionQuery(mPolygon, ds)

Dim fdt = CType(ds.Tables(0), SharpMap.Data.FeatureDataTable)

Dim fdr = CType(fdt.Rows(0), SharpMap.Data.FeatureDataRow)

MessageBox.Show(fdt.Rows.Count)
Thanks
Coordinator
Mar 24, 2015 at 9:08 AM
You cannot do that with SharpMap itself, you have to use GDAL to do that.
Mar 24, 2015 at 8:28 PM
Edited Mar 24, 2015 at 8:33 PM
FObermaier wrote:
You cannot do that with SharpMap itself, you have to use GDAL to do that.
Thanks for reply

I'm already using GDAL by using (GdalRasterLayer), it uses the GDAL functions.

So what is the purpose of the ExecuteIntersectionQuery function? is it just to get the centroid elevation? i don't think so because its summary said that : (Returns the data associated with all the geometries that are intersected by 'geom')
/// <summary>
        /// __Returns the data associated with all the geometries that are intersected by 'geom'__
        /// </summary>
        /// <param name="geometry">__Geometry to intersect with__</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(Geometry geometry, IFeatureCollectionSet ds)
        {
            ExecuteIntersectionQuery(geometry.EnvelopeInternal, ds);
        }
Coordinator
Mar 25, 2015 at 8:22 AM
It seems that the code documentation was copied from the ICanQueryLayer interface without adapting it to the specifics of the GdalRasterLayer.
What I described is the way it is implemented. If you need it differently, you need to raise an issue or code it yourself.
The problem is that there is no concept of Raster in SharpMap.