MapInfo Pro

 View Only
  • 1.  Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 04-29-2018 15:21

    With an investment in MapInfo Pro Advanced, I thought I delve into the types of raster analysis I could do with the MRR format in my own software. One thing that was a bit a disappointment was to see that there doesn’t seem to be any MapBasic support (in the form of new statements or functions) for Advanced rasters. In my Pro installation folder, I found a Raster\Documentation folder and a Windows help CHM file with some documentation on the API. I presume/hope it’s possible to create MapBasic declare statements to call these functions.

     

    My immediate interest is how I can perform polygon-over-raster analysis… extracting min/max/avg/sum (or some other function that distils an aggregate) for cells that fall (partly/wholly… ideally I get to choose) inside region objects held in MapBasic variables. I found a function called GetPolygonStatistics in the API documentation but this only seems to enrich a whole table by adding a new field and populating in one operation. I was looking for something for single region operations under my own MapBasic program control. Is that possible?

     

    Anyone had any success with writing their own code to utilise MapInfo Pro Advanced’s raster capabilities? I’m wonder if this powerful functionality is not being fully utilised because it’s not been made very accessible?

     

    Regards,

    Warren Vick



  • 2.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 04-29-2018 11:22

    P.S. Also posted on MapInfo-L... old habits die hard. 😊 Sorry if you see the question twice.



  • 3.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Employee
    Posted 04-30-2018 02:54

    Hi Warren,

    I have worked a bit with the MapInfo Pro Raster API. As you have learned yourself it's a .NET API. Sofar we haven't created declarations for the API to be used from MapBasic.

    That could very well be done. I'm not sure if we have that on our product backlog. You would probably loose a bit of the power of the API if you called the method directly from MapBasic. I'm not sure we would support things like processing threads running in the background for example.

    You can find a sample application of mine showing how you could take advantage of the MapInfo Pro Raster API by calling custom .NET methods from MapBasic on github. The tool is called mbMapInfoRasterTool: https://github.com/PeterHorsbollMoller/mbMapInfoRasterTool

    One of the sample does show how to use the Regions Stats. I'd think you woul dhave to save your polygon to a new temporary table, run it thru the Region Stats process and then read the values from the added columns.



  • 4.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 14 days ago
    Hi Peter,

    So it is possible to utilize MapBasic to access any of the MapInfo Pro Raster API functions? If so, how would you go around doing this for using the "RasterAnalysis.Polygonise" function?

    Thanks

    ------------------------------
    Luke Lynx
    Knowledge Community Shared Account
    ------------------------------



  • 5.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Employee
    Posted 13 days ago
    Hi Luke

    I'm using a mixture of MapBasic and an assembly developed through .NET.
    I have shared some examples here on github: https://github.com/PeterHorsbollMoller/mbMapInfoRasterTool

    There might actually be an option to use the Raster API directly from MapBasic but I haven't tried that yet
    @Mitesh Patel, @Anshul Goel, do you have examples of calling the Raster API directly from MapBasic and by-passing the creation of the assembly?​​

    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------



  • 6.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 11 days ago
    Edited by Luke Lynx 11 days ago
    Hi Peter,

    Thanks for the response, that is great, I will have a look through the examples.

    It is much appreciated,
    Thanks :)

    ------------------------------
    Luke Lynx
    Knowledge Community Shared Account
    ------------------------------



  • 7.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 04-30-2018 04:47

    Hi Warren 

    You can perform polygon-over-raster analysis for a single polygon from MapInfo Pro Advanced (Raster) user interface itself by following these steps: 

    1. Open the input region TAB and raster file in MapInfo Pro.

    2. Select any region in mapper window.

    3. Access the Region statistics Tool from Raster Tab-> Raster Operations-> Region Stats.

    4. Now, select the raster in Input File field.

    5. Select "Selection” in Select Region Layer field.

    6. Set the output TAB file path in Output File field.

    7. Click on Process button.

     

    MapInfo Pro Advance Raster APIs are designed to be consume in C# program, so you cannot use them directly in MapBasic.

     

    We have added MDAL (MapInfo Data Access Library) C# library in MapInfo 17.0. You can write a C# program for selecting and writing the single region TAB file (temporary) from input regions TAB file, using MDAL and feed it to GetPolygonStatistics raster API.

     

    You can find and refer the sample code for using MDAL at <MapBasic-x64 Installation directory>\Samples\RIBBONINTERFACE\DotNet\MapInfoDataAccessLibraryExamples.

     

    Thanks

    Upendra Patel



  • 8.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 04-30-2018 04:51

    Many thanks, Peter. I'll take a look at your mbMapInfoRasterTool.

    I think the new (OK, not so new now) raster support is very powerful and a massive step up from the Vertical Mapper era. I do, however, hope that PB doesn't neglect/forget about MapBasic as a platform to utilise these features. These things are a great reason for the reluctant to switch to 64bit Pro, but the lack of integration is a counteraction. Ditto for other things like lack of ribbon support (replacing buttons pads) in MapBasic. I do understand that there may be some inherent limitations in MapBasic, but some degree of access should be possible. While BASIC is far from my favorite language, it's convenient for quick tool development.

    In terms of alternatives to MapBasic, would PB consider providing Python bindings and some for of integration into Pro? You'd then have a modern, popular scripting language which can handle multi-threading, etc.

    /Warren



  • 9.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Posted 04-30-2018 05:05

    Thanks, Upendra, but using the Pro UI is not what I want to do. Also, I think the method you outlined with writing a single region TAB and then call GetPolygonStatistics would be horribly inefficient at scale.

    Looks like I'm sticking to Python/GDAL/OGR for now. 😐

    /Warren



  • 10.  RE: Can I access the MapInfo Pro Advanced Raster API from MapBasic?

    Employee
    Posted 05-02-2018 07:53

    Hi Warren,

    Nothing is ruled out but at the moment I'd say focus is more on .NET (and MapBasic).

    For v17.0 we added a new MapXtreme based Data Access Library (MapInfo Data Access Library or just MDAL) that allows you to access data in MapInfo tables directly from your .NET application instead of having to go thru MapInfo Pro/MapBasic.