MapInfo Pro Developers User Group

 View Only
Expand all | Collapse all

MapBasic function to retrieve MRR-GridCellValue

  • 1.  MapBasic function to retrieve MRR-GridCellValue

    Posted 12-03-2018 07:56
    Hi,

    Is there currently really no mapbasic function to query a raster cell value in a mrr-file?
    Tried it with GetGridCellValue but do only get error Messages.
    RasterTableInfo seems to work with mrr-Tables.

    In the mapbasic help file i couldn't find a hint to such a function.

    Many thanks in Advance
    and
    Cheers

    Stefan


  • 2.  RE: MapBasic function to retrieve MRR-GridCellValue

    Employee
    Posted 12-04-2018 12:50
    ​I have asked a member of our raster dev team to answer with details on how to do this.
    You can do it using our raster sdk (which I think requires an advanced Pro license).

    ------------------------------
    Bob Fortin

    ------------------------------



  • 3.  RE: MapBasic function to retrieve MRR-GridCellValue

    Posted 12-07-2018 07:10
    Hi Bob,

    yes, using the raster sdk is an Option, but an expensive one.
    You can open mrr files with Standard MiPro 17 and you can query other raster cell values with mapbasic out of the box, so it would be consequent, - my opinion -,  if querying a mrr-cell value would also be possible, without obtaining an expensive advanced License.

    If the raster Team Comes up with an answer, it would be nice, if you share it.

    Thanks and regards

    Stefan


  • 4.  RE: MapBasic function to retrieve MRR-GridCellValue

    Employee
    Posted 12-10-2018 02:34
    I agree with you, Stefan, we need to improve the current process.

    There is an historic explanation for this behavior, maybe that's of interest to you, but we really should find a way to work around this.

    We do not support GridCellValue for all raster file types. We only support this for Grids, formats like MIG (MapInfo Grid), GRD (Vertical Mapper Grid) etc. We do not support it for typical raster formats like BMP, PNG and similar.

    Now when we introduced MapInfo Raster, the technology that you find in MapInfo Pro Advanced, we decided to switch from having two types of raster in MapInfo Pro; Raster and Grid. Now we treat all as Raster.

    Unfortunately, that had some other side effects. The GridCellValue feature is basically embedded in our Grid Handlers and as we now treat all raster files as rasters and not as grids, they no longer get opened using the Grid Handler but using the Raster Handler which doesn't yet support the GridCellValue.

    But of course this doesn't really solve your request right now.

    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------



  • 5.  RE: MapBasic function to retrieve MRR-GridCellValue

    Posted 12-14-2018 04:18
    Edited by Stefan Hausmann 12-14-2018 04:18
    Hello Peter,

    thank you anyway for your detailed Explanation. It's allways good to know some Background especially when one is thinking about diving into the new raster api and wants to understand behaviour & object model.

    I'm Looking forward to having a free "RasterCellValue"-Function in MapBasic ;-)

    Kind regards
    Stefan




  • 6.  RE: MapBasic function to retrieve MRR-GridCellValue

    Employee
    Posted 12-18-2018 02:18
    Me too :-)

    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------



  • 7.  RE: MapBasic function to retrieve MRR-GridCellValue

    Posted 12-17-2018 01:52
      |   view attached
    Hi,

    If you are running the MapInfo Pro without Advance license, and want to get the cell value from raster SDK. you can use the attached sample C# code.

    Thanks
    Upendra Patel



    ------------------------------
    Upendra Patel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------

    Attachment(s)

    zip
    Program.zip   1 KB 1 version


  • 8.  RE: MapBasic function to retrieve MRR-GridCellValue

    Employee
    Posted 12-17-2018 02:56
    Thanks Upendra,

    This will be very helpful.
    It looks like you use a reference to a cell row and cell column in the grid. Is that correct?

    If yes, is there an easy way to convert a spatial coordinate, or a point, to a cell row/cell column reference?

    Thanks

    ------------------------------
    Peter Horsbøll Møller
    Pitney Bowes
    ------------------------------



  • 9.  RE: MapBasic function to retrieve MRR-GridCellValue

    Posted 12-17-2018 03:33
    Hi Peter,

    You are right. i have used the reference to a cell row and column in the grid. 
    There is a ConvertWorldToCell method in SDK that can be used on RasterDataset object to convert a spatial coordinate, point to cell row/column reference. Please refer the following snippet.

    // Point coordinate should be in grid projection.
    double pointX = -114.944043;
    double pointY = 52.459101;
    double dCellX = 0;
    double dCellY = 0;
    uint nField = 0;
    string inputFilePath = System.IO.Path.GetFullPath(@"..\..\..\Input\12_ClassTable_AllDataType.mrr");
    IRasterDataset dataset = RasterDatasetFactory.Open(inputFilePath);

    //Convert World coordinate to cell coordinate.
    dataset.ConvertWorldToCell(pointX,pointY,out dCellX,out dCellY,nField);

    //Make cell coordinate to left- bottom coordinate of cell
    long lCellX = (long)Math.Floor(dCellX);
    long lCellY = (long)Math.Floor(dCellX);

    Thanks
    Upendra Patel



    ------------------------------
    Upendra Patel
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------



  • 10.  RE: MapBasic function to retrieve MRR-GridCellValue

    Posted 12-17-2018 03:44
    Good morning Upendra,

    Thanks a lot for this information and sample code, i'll have to try that the next days.

    So it should also be possible to create a mapbasic visible .net class from this code, if a customer doesn't want to dive into .net programing.

    Great and best regards

    Stefan


  • 11.  RE: MapBasic function to retrieve MRR-GridCellValue

    Employee
    Posted 12-18-2018 09:54
    Thanks Upendra​.

    What assemblies do we need to reference? Is it the same for advanced and non-advanced license?

    -Bob

    ------------------------------
    Bob Fortin
    Knowledge Community Shared Account
    ------------------------------



  • 12.  RE: MapBasic function to retrieve MRR-GridCellValue

    Posted 12-18-2018 23:36
    Hi Bob,

    The following two assemblies are required to reference.
    1. MapInfo.RasterEngine.Common.dll
    2. MapInfo.RasterEngine.IO.dll

    Yes. The assemblies remain same for advance and non-advance license.

    Thanks
    Upendra Patel

    ------------------------------
    Upendra Patel
    Knowledge Community Shared Account
    Noida
    ------------------------------