Reading Value from Vertical Mapper GRD programatically(MapBasic)

314 views
Skip to first unread message

college.atlas

unread,
Apr 16, 2008, 9:08:10 PM4/16/08
to MapInfo-L
I have a VM GRD supplied by a client. The GRD represents a weighting
factor. I need to apply this weighting factor to a series of point
attributes to obtain a final (weighted) result.

Is there a way to obtain a value from a VM GRD at a discrete
point(X.Y) using MapBasic?

I am aware of a MapBasic program written by Andy Dressel for doing
this with a Mapinfo MIG.

The Mapinfo Grid conversion tools can't or wont convert the GRD to a
MIG.

I would be OK if I could convert each interpolated cell(1.0m in my
case) into a polygon with the value as an attribute.

Obviously there is a DLL with this functionality in Mapinfo otherwise
the standard 'Info' Tool wouldn't return a value.

Advice appreciated.

Jakob Lanstorp

unread,
Apr 23, 2008, 7:19:26 AM4/23/08
to MapInfo-L
There is a Vertical Mapper SDK available from you MapInfo dealer. It
is composed of samples in different languages and a reference book
with a description and MapBasic reference of all the functions placed
in the VM DLL's. I have used it before. Not a very user friendly API
or documentation.

HTH,
Jakob

Glen

unread,
Apr 23, 2008, 9:06:27 AM4/23/08
to MapInfo-L

page 308 of MapXtreme developer guide I am not sure if this will help
you


Code Sample: Retrieving Data from a Grid Map
This example shows how to open and read information from a grid file.
VB example:
Public Shared Sub MapInfo_Raster_GridRead(ByVal strGridFilename _
As String)
Dim strHillshadeFilename As String = _
MapInfo.Raster.GridRead.DefaultHillshadeFilename(strGridFilename)
Dim session As ISession
session = MapInfo.Engine.Session.Current
Dim gridread As GridRead = New GridRead(strGridFilename,_
strHillshadeFilename)
Console.WriteLine(gridread)
End Sub
This example shows how to open and read cell values from a grid file.
VB example:
Public Shared Sub MapInfo_Raster_GridReadStartRead(ByVal _
gridread As GridRead, ByVal strGridFilename As String)
Dim strHillshadeFilename As String = _
gridread.DefaultHillshadeFilename(strGridFilename)
If gridread.StartRead() Then
Dim x As Integer = 0 ' TODO - set to a pixel column value
Dim y As Integer = 0 ' TODO - set to a pixel row value
Dim bIsNull As Boolean
Dim dValue As Double
If gridread.GetValue(x, y, bIsNull, dValue) Then
If bIsNull Then
' read a null cell
Console.Write("{0,20}", "NULL")
Else
' read a non-null cell, with value == dValue
Console.Write("{0,20}", dValue)
End If
End If
gridread.EndRead()
End If
End Sub

Jakob Lanstorp

unread,
Apr 23, 2008, 3:38:42 PM4/23/08
to MapInfo-L
You right the MapXtreme MapInfo.Raster namespace does give access to a
wide range of raster format including Vertical Mapper numeric grids.
But until MapInfo Corp. gets MapXtreme API available inside MapInfo
Pro I guess that college.atlas is using MapInfo/MapBasic.

Take a look at the VM SDK with samples in MapBasic. I quess one of the
VM DLL function you need is: Declare Function vmReadGRDBlock Lib
"vmApi.dll" (ByVal GridID As Integer, ByVal uwRowStart As SmallInt,
ByVal uwColStart As SmallInt, ByVal uwNumRows As SmallInt, ByVal
uwNumCols As SmallInt, iZVals() As Integer) As Integer. As you can see
this declareation does not look nice. The OOP encapsulation in
MapXtreme is a lot easier. Also the documentation is better. If you
are into .NET already you can get a 60 day trial af MapXtreme from
http://extranet.mapinfo.com/products/Overview.cfm?productid=1849

HTH,
Jakob

college.atlas

unread,
Apr 27, 2008, 6:51:43 PM4/27/08
to MapInfo-L
Thanks for your help.

The VM SDK is the way I'll have to go.

You have both been very helpful.

regards
Andrew

college.atlas

unread,
Apr 29, 2008, 1:52:43 AM4/29/08
to MapInfo-L
Contrary to my previous response, the cost of the SDK means this
project will not be proceeding.
It's been a while since I had to pay for an SDK.

The annoying part is the function exists somewhere in the Mapinfo
application files.

This must have been added in 8.0 or 8.5. Just using the standard
Mapinfo "info" tool on a VM Grid will return the value of the cell.

That's all I want and the US$700 price tag is too much for me and the
client to bear.

I'm not against anyone making a buck, but the cost benefit here
doesn't add up.
> > Jakob- Hide quoted text -
>
> - Show quoted text -

Uffe Kousgaard

unread,
Apr 29, 2008, 2:02:41 AM4/29/08
to mapinfo-l
From: "college.atlas" <colleg...@gmail.com>

> I'm not against anyone making a buck, but the cost benefit here
> doesn't add up.

Maybe it is rather your benefit than the suppliers cost that is the problem
in the equation. See it from the positive side: If the possible benefit is
small, so is the loss from not proceeding with the project.

Regards
Uffe Kousgaard

college.atlas

unread,
Apr 29, 2008, 3:52:06 AM4/29/08
to MapInfo-L
Good point Uffe,

Perspective is always the modifier.

Having the SDK would be quicker but not so quick that we won't go back
and export the grid in a more directly Mapinfo usable format.

If I was developing tools that had more general appeal or I was using
more functionality then the financial justification becomes more
reasonable.

I never object to people making money, that's what I try to do
everyday. I was simply stating that given my requirements and the cost
of the SDK I can't justify the expenditure.(Considering there are
other less expensive alternatives, just not as immediate.)

All it's done is made me try harder to work around it the VM
application rather than embrace it.

Again we're only talking about, maybe an hour's effort? I'm not going
to lose too much sleep over it.

On Apr 29, 4:02 pm, "Uffe Kousgaard" <u...@routeware.dk> wrote:
> From: "college.atlas" <college.at...@gmail.com>
Reply all
Reply to author
Forward
0 new messages