Hello folks,
I’m attempting to draw some isolines on my map with little success. I haven’t been able to get it working in our existing software (which used version 4 of MapSuite), so I’ve created an example project which behaves the same way.
I’ve created the GridIsolineLayer and added it to the main map control’s overlay. I also then added a ShapeFileFeatureLayer from a world map shapefile (from your example code). I’ve basically followed the method in the “Getting Started” page on your Wiki, and the “IsoLines with Kriging” sample code from the Product Center.
The code generates a .grid file which seems to have reasonable values in it, and while the world map layer displays perfectly well, the isolines layer does not. I notice that all of your isolines examples use the Server Edition, and the MapEngine class, but I assume that as long as I add the isoline layer to the WinformsMap control Overlay.Layers collection, it should otherwise behave the same.
If my assumptions are incorrect, or I’m obviously missing something important, please let me know. I’ve attached the sample application should anyone be sufficiently curious.
Regards,
Scott D.
002_001_MapTest.zip (1.58 MB)
GridIsoLineLayer not appearing
Hi Scott,
You forget to set the levels to layer:
layer.IsoLineLevels = levels;
Regards,
Don
Hello Don,
Many thanks for the reply. That fixed it, of course! I’m so relieved (and faintly ashamed).
I appreciate very much you looking at the code for me.
Regards,
Scott D.
One further question, following on from the above.
I now have the map and contours drawn as show here:
What would you suggest as the best way to draw filled contours so that the background of the contour layer be coloured according to the enclosing contour line? I’m thinking to use the grid layer that I’ve generated for the contours in some way, but I’m not sure. A heat map doesn’t look appropriate, but the effect is similar.
Many thanks again for your help.
Regards,
Scott D.
Hi Scott,
Here we have a sample, please visit this sample and let me know whether that’s helpful for your scenario.
wiki.thinkgeo.com/wiki/Map_Suite_Desktop_Edition_All_Samples#Isolines
Regards,
Don
Hello Don, Thanks for the suggestion.
I had looked into those samples, and while they do colour the background using a GridFeatureLayer with appropriate AreaStyles, when I tried that, the effect wasn’t so great:
I’m trying to fill the contours with the same colour as the contour lines, but without the jagged edges created by the interpolation grid. Something more akin to this, from our existing solution (whereby we generate polygon shapes manually, but it sometimes goes wrong):
We are hoping to use MapSuite to achieve the effect rather than the somewhat fallible filled polygons we currently employ.
If you (or anyone!) have any suggestions, that would be great.
Many thanks,
Scott D.
Hi Soctt,
I think you’re right, it looks for GridFeatureLayer, we draw the color for each small cell. So if you set different style it will looks like Jagged edge. Only set gradient color can shows like our sample.
I think we have two way for solve it:
1. Use smaller grid cell, so the curve will looks more smooth, but the performance should be a problem.
2. Get the iso lines by GetIsoLineFeatures, then build polygon based on the ContourValue value of the feature. The question is we don’t have a algorithm here, so you need code for it.
Wish that’s helpful.
Regards,
Don
Hello again,
In the end I solved this issue by creating the high-resolution grid and then using GetBitMap to render it out as a png file. We do this in advance, and the png is later displayed in a raster layer by the client underneath the contour lines. It works well and the performance is not degraded.
The contour lines themselves are set to a particular thickness in the CustomStyles of the GridIsoLineLayer, and look good at certain zoom levels, but not so much if you zoom to other levels. I can’t see any way to change the line style at different zoom levels. Other layers allow you to set different CustomStyles for each of the ZoomLevelSet, but that does not seem to be the case here.
Can GridIsoLineLayer not be styled in the same way?
Many thanks for any information.
Regards,
Scott D.
Hi Scott,
Your solution is what I hadn’t thought, I think that’s should be helpful if anyone else met same issue.
For your question about style of IsoLineLayer, I think IsoLineLayer is a special class so you cannot set style for zoomlevel like other layer.
But you can implement that by override DrawCore function.
As below is a simple sample, you can set different style for different scale.
protected override void DrawCore(GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers)
{
double currentScale = ExtentHelper.GetStandardDPIScale(canvas.CurrentWorldExtent, canvas.Width, canvas.MapUnit, canvas.Dpi);
if (currentScale <= UpperScale && currentScale >= LowerScale)
{
System.Collections.ObjectModel.Collection<Feature> features = GetFeaturesForDrawingCore(canvas, labelsInAllLayers);
Style yourStyle; // Set your style here
ZoomLevelSet zoom = new ZoomLevelSet();
if (currentScale <= zoom.ZoomLevel01.Scale + 1 && currentScale > zoom.ZoomLevel02.Scale) // You can set your logic here
{
yourStyle.Draw(features, canvas, new System.Collections.ObjectModel.Collection<SimpleCandidate>(), labelsInAllLayers);
}
}
}
Regards,
Don