MapWindow 4 - Plugins : MapWindow Discussion Forum
Is there a cheap way to get unique grid values? I've tried to cheat in Script editor with something like Dim lyr as Layer lyr=m_MapWin.Layers.Item(m_MapWin.Layers.CurrentLayer) Dim cs as MapWinGIS.ShapefileColorScheme cs=lyr.ColoringScheme MsgBox(&quo
How to get unique grid values?
Posted by: mlt ()
Date: February 24, 2010 01:02PM

Is there a cheap way to get unique grid values?
I've tried to cheat in Script editor with something like

Dim lyr as Layer
lyr=m_MapWin.Layers.Item(m_MapWin.Layers.CurrentLayer)
Dim cs as MapWinGIS.ShapefileColorScheme
cs=lyr.ColoringScheme
MsgBox("Hello")

to get unique values through coloring. It would be enough for my task. However I haven't even got message box.

Any suggestions?

P.S. It would be nice if there was an option to get unique values for Shapefile's attribute.
P.P.S. Script shouldn't just unpredictably terminate without any message.

Options: ReplyQuote
Re: How to get unique grid values?
Posted by: pmeems ()
Date: February 24, 2010 01:20PM

Could you post the complete script? Normally scripts not terminate without any message.

If your layer is a grid, you can't use ShapefileColorScheme
You should use GridColorScheme

But I don't know if it will provide you the data your looking for.

--
Paul

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: How to get unique grid values?
Posted by: mlt ()
Date: February 24, 2010 04:04PM

Thanks! Works like a charm!
I didn't try on all versions of MW I have. I tried on one I built a while ago from SVN. It would be nice also to have an option to ignore warnings like unused variables etc.

Imports MapWindow.Interfaces
Imports MapWinGIS
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports System

Public Module Ksat
  Public Sub ScriptMain(ByRef m_MapWin As IMapWin)
  	Dim lyr as Layer
        
  	If -1=m_MapWin.Layers.CurrentLayer Then
  		MsgBox("Select layer first!")
  		return
  	End if
  	lyr=m_MapWin.Layers.Item(m_MapWin.Layers.CurrentLayer)
  	Dim old As Grid
  	old = lyr.GetGridObject
  	If IsNothing(old)
  		MsgBox("Select raster layer first!")
  		Return
  	End if
  	
  	Dim s as string
  	Dim cs as MapWinGIS.ShapefileColorScheme
  	'Dim cs as MapWinGIS.GridColorScheme
  	cs=lyr.ColoringScheme
  	MsgBox("Hello")
  	s=cs.NumBreaks
  	MsgBox(s)
  	'Dim cb as GridColorBreak
  	'cb=cs.Break(0)
  	's=cb.Caption
  	'MsgBox(s)

  	'Dim connectionString As String
  	'Dim dbConnection As System.Data.IDbConnection
  End Sub
End Module

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: