ThinkGeo.com    |     Documentation    |     Premium Support

Getting value under the mouse position in a Raster map

How can I find out what is the grid value when the user clicks on the Raster Map?
I have seen the examples of how to achieve this for a shapefiles but don’t seem to find any examples of raster files.

In my case, there would be only one layer loaded in the map control, the raster map.

Thanks,
Daniel

Hi Daniel,

I think the raster layer cannot save the grid value, so you should have another layer which can read grid data from your grid layer, and you can choose don’t show it on map but only query on it.

Wish that’s helpful.

Regards,

Ethan

Ethan,
What you are saying makes sense, but I have no idea how to achieve that. I am new to TG and very rusty on my GIS as well. I there any chance you could elaborate a bit more on how to do this. I am using winforms with C#

Hi Daniel,

Thanks to let us know your question, I want to double check with your scenario.

  1. You have a raster layer, which can be rendered on our map, it’s your base map.
    Q: Whether we can get grid data from this layer in target coordinate?
    A: No, because the raster layer don’t contains the data we want.

  2. You have another file(for example a grid file), which can be covered above the raster layer.
    Q: Whether we can get the data from grid file when you click on target coordinate on map?
    A: If the file is supported by our map we can, but we still need to add the file as a standalone layer, that’s not related with the raster layer, and the file should tell map its coordinate, so we can make it works together with the map click event.

If I misunderstand your requirement please let me know, and wish that’s helpful.

BTW, you can view our online sample http://wiki.thinkgeo.com/wiki/map_suite_desktop_for_winforms_all_samples to understand how our map works.

Regards,

Ethan

Ethan,
Thanks for the reply. Maybe I was not clear on the question. When I said, “How can I find out what is the grid value” I meant the color or value of the cell under the mouse. I don’t care for coordinates and such. Would this be easier to accomplish?

Hi Daniel,

It looks you only need render the grid layer on map, when you click on map, you want to show the grid cell value.

But please notice, you still need to make sure your grid file can be plotted on correct coordinate on map, everything on our map need have its coordinates, if your grid file only contains the value, you need assign the position to it yourself.

Here we have a sample I think it helpful for your scenario:

And you can refer the other samples, all of them is about grid file.

Any question please let us know.

Regards,

Ethan

Ethan,
Thanks for the reply. I took a look at the example and I see that the EditGridLayerSample is a static iteration thought the grid features. What I am looking for a bit different. I would like to obtain the cell value or color under the mouse as the mouse moves over the grid or the user clicks on the map. i.e ThinkGeo has a function call MapClick that looks promising but I am not sure how to make it work.

This is what I have

I only have a single GridFeatureLayer loaded in the form
protected void Map1_Click(object sender, MapClickedEventArgs e)
{
var overlayIndex = 0;
LayerOverlay staticOverlay = (LayerOverlay)wfmFile.Overlays[overlayIndex];
GridFeatureLayer gridFeatureLayer = (GridFeatureLayer)staticOverlay.Layers[“Grid View”];

Collection selectedFeatures = wfmFile.QueryTools.GetFeaturesNearestTo(e.Position, GeographyUnit.Meter, 1, ReturningColumnsType.AllColumns);
}

Hi Daniel,

It looks we are close to your target. If you can get the selectedFeatures you can get it’s value from the ColumnValue of the feature, but that’;s based your grid layer is valid.

Please try to build a sample and upload the sample with your test data, we can see whether our developer can help you to make it works.

Regards,

Ethan