This project is read-only.

problem with Fill color to depth Area in MapwinGIS 4.8

Feb 20, 2013 at 4:29 AM
Edited Feb 20, 2013 at 4:30 AM
Hi all
I have problem with Fill color to depth Area in MapwinGIS 4.8
When I use MapwinGIS 4.7 , I can do and it's work for me (see my code below).
But now I use MapwinGIS 4.8 , I can't do .
How to write code in 4.8, pleas help me !!!

thank you for your advise.

sfAreaPolygon.Open("c:\map\area_polygon.shp")
hndsfAreaPolygon = .mapMain.AddLayer(sfAreaPolygon, True)

'''' set line color
mapMain.set_ShapeLayerLineColor(hndsfAreaPolygon, Convert.ToUInt32(RGB(174, 180, 172)))

' extract color polygon
For i = 0 To sfAreaPolygon.NumShapes - 1
          ' extract depth area value
 depth = sfAreaPolygon.CellValue(7, i)

 If depth <= -0.9 Then
     mapMain.set_ShapeFillColor(hndsfAreaPolygon, i, Convert.ToUInt32(RGB(165, 203, 160)))
 ElseIf depth > -0.9 And depth <= 4.9 Then
     mapMain.set_ShapeFillColor(hndsfAreaPolygon, i, Convert.ToUInt32(RGB(162, 206, 243)))
 ElseIf depth > 4.9 And depth <= 9.9 Then
     mapMain.set_ShapeFillColor(hndsfAreaPolygon, i, Convert.ToUInt32(RGB(194, 221, 246)))
 ElseIf depth > 9.9 And depth <= 29.9 Then
     mapMain.set_ShapeFillColor(hndsfAreaPolygon, i, Convert.ToUInt32(RGB(221, 237, 230)))
 ElseIf depth > 29.9 Then
     mapMain.set_ShapeFillColor(hndsfAreaPolygon, i, Convert.ToUInt32(RGB(245, 255, 242)))
 Else
 End If
Next

Feb 20, 2013 at 3:36 PM
Leave this type behind and use symbology categories. see the documentation and samples here http://mapwingis.codeplex.com/documentation. much easier to use categories with M4.8+.

AGP
Feb 21, 2013 at 2:04 AM
Thanks sindizzy, I am newbie for MW4.8 .
Please point me to my target or tell about sample code.
Feb 21, 2013 at 5:47 AM
I just did. please re-read my response.
Feb 21, 2013 at 9:42 AM
To make it even easier for you. Look at this page: http://www.mapwindow.org/documentation/mapwingis4.8/class_shapefile_categories.html

Paul
Feb 21, 2013 at 1:11 PM
Edited Feb 22, 2013 at 1:35 AM
Sorry I still can't do that.
Can I ask again ?

I would like to fill 5 color in 5 groups(Categories)
  1. cellvalue -100 - 1 Give Red
  2. cellvalue 1 - 5 Give blue
  3. cellvalue 6 - 10 Give brown
  4. cellvalue 11 - 30 Give black
  5. cellvalue 31 - 100 Give white
How can I add into 5 Categories <-------------------------- Question 1

Then I add to Categories already
I have to use code below to fill color, right ? <-------------------------- Question 2

sfDepth.Categories.Item(0).DrawingOptions.FillColor = Convert.ToUInt32(RGB(65, 23, 160))
sfDepth.Categories.Item(1).DrawingOptions.FillColor = Convert.ToUInt32(RGB(12, 26, 243))
sfDepth.Categories.Item(2).DrawingOptions.FillColor = Convert.ToUInt32(RGB(14, 21, 246))
sfDepth.Categories.Item(3).DrawingOptions.FillColor = Convert.ToUInt32(RGB(21, 27, 230))
sfDepth.Categories.Item(4).DrawingOptions.FillColor = Convert.ToUInt32(RGB(45, 25, 242))

Thank you very much.
Jacky
Feb 22, 2013 at 1:34 AM
Hi Paul, Sindizzy
Thank you for your advise

Now I can do that (see my code below) But I have last one question.
I would like to know my code is corect in syntax or not , if not please advise me .

MY CODE
sfDepth.Categories.AddRange(7, MapWinGIS.tkClassificationType.ctEqualIntervals, 1, -1000, -0.9)
sfDepth.Categories.AddRange(7, MapWinGIS.tkClassificationType.ctEqualIntervals, 1, -0.89, 4.9)
sfDepth.Categories.AddRange(7, MapWinGIS.tkClassificationType.ctEqualIntervals, 1, 4.91, 9.9)
sfDepth.Categories.AddRange(7, MapWinGIS.tkClassificationType.ctEqualIntervals, 1, 9.91, 29.9)
sfDepth.Categories.AddRange(7, MapWinGIS.tkClassificationType.ctEqualIntervals, 1, 29.91, 90000)

sfDepth.Categories.ApplyExpressions()

sfDepth.Categories.Item(0).DrawingOptions.FillColor = Convert.ToUInt32(RGB(65, 23, 160))
sfDepth.Categories.Item(1).DrawingOptions.FillColor = Convert.ToUInt32(RGB(12, 26, 243))
sfDepth.Categories.Item(2).DrawingOptions.FillColor = Convert.ToUInt32(RGB(14, 21, 246))
sfDepth.Categories.Item(3).DrawingOptions.FillColor = Convert.ToUInt32(RGB(21, 27, 230))
sfDepth.Categories.Item(4).DrawingOptions.FillColor = Convert.ToUInt32(RGB(45, 25, 242))
.Label1.Text = sfDepth.Categories.Count

Thank you.