Tag Info

Hot answers tagged

10

Also if you are looking for a way to learn MapBasic more than a way to learn programming, there is a huge help in MapInfo Pro thru the MapBasic window. Open the MapBasic window (Options > Show MapBasic Window) and do the task you want to code in MapBasic in MapInfo Pro. MapInfo Pro will now write the MapBasic statements required. You can now copy these into ...


7

MapInfo Pro does not support the Distinct keywork, unfortunately. However you can get to the same result just be grouping your result by the column Select some_column from table_name into temp_table Group By some_column


7

A Function always returns a value where as a Sub does not. All methods in MAPBASIC can have side effects in the true term because it's not a functional language. If you are expecting a return value you should use a Function that is what they are there for. Can you modify the value of myParameter inside a Sub and then just use it after. Yes. But this ...


6

Query For Selecting row(s) without object : Select * from 'MYTABLE' where not obj into MYTABLE_NO_MAP_OBJECT Browse * From MYTABLE_NO_MAP_OBJECT Query For Selecting row(s) with object : Select * from MYTABLE where obj into MYTABLE_MAP_OBJECT Browse * From MYTABLE_MAP_OBJECT


6

Just sue the CreateCircle method in the MapBasic window, or just put it behind a quick and dirty dialogue with all the maths worked out behind the scene Create circle in MapBasic CreateCircle( x, y, radius ) x is a float value of the circle's center. y is a float value of the circle's center. radius is a float value, indicating the circle radius. ...


5

You can add NOSELECT to the end of the query. Example from the user guide: Select * From World Into EarthQuery NoSelect


5

I was lucky enough to learn MapBasic from some other colleagues. I have not found many resources for MapBasic other than what Pitney Bowes offers on the site. I spotted this tutorial that looks fairly good for new starters. Online Forum Knowledge Base MapBasic Product Documentation v9 link. There is currently only a handful of MapBasic questions on ...


5

You can use the Mapping Wizard Tool to load in your text file of latitude and longitude coordinates. Just set the correct datum (usually World WGS84) to overlay them correctly. Guide to using the Mapping Wizard Tool: http://www.oocities.org/mapinfotutorial/wizard.html


5

The last few versions of MapInfo Professional can read KML files directly thru File > Open Universal Data.


4

Have a look at this MapBasic function: ConnectObjects( ) function Purpose Returns an object representing the shortest or longest distance between two objects. You can call this function from the MapBasic Window in MapInfo Professional.


4

What about just using the command line ogr2ogr, or installing FWTools to access it's pre-configured ogr2ogr command line? The core ogr2ogr appears to support bi-directional conversion from MapInfo to GeoJSON. Here are a couple of cheat sheets that might help: ogr_cheatsheet; data loading


4

If you only have to do it once and there is only two points I would just do it by hand, else you can use a tool called ConnectTheDots.MBX which can be found here: http://www.mapinfotools.com/index.php?option=com_sobi2&sobi2Task=sobi2Details&catid=10&sobi2Id=35&Itemid=53


4

This will close all layers except one using a layer name to check what to keep open: Dim i as Integer Dim tables as Integer Dim tableName as String tables = NumTables() For i = 0 To tables tableName = TableInfo(i,TAB_INFO_NAME) '' Check to see if the table is anything but the one we are looking for. If Not tableName = "{Your table name to ...


4

Try this in stead: Dim count As Integer Select count(*) "mycount" from some_table into temp_table Fetch First From temp_table count = temp_table.mycount


4

I wonder if it's because the output.shp hasn't been constructed properly? Check to see that the output is formatted fully - ie; ends in output.shp Try changing: OGR2OGR -f "ESRI Shapefile" "S:\000 GIS Files\TEST WORKSPACE 2\convert test\Converted\SHP\" "S:\000 GIS Files\TEST WORKSPACE\SiteForm.TAB" -overwrite -skiperrors to... OGR2OGR -f "ESRI ...


4

Functionally this code does the same thing (in QGIS 2.0): vl = QgsVectorLayer("LineString", "lines", "memory") vl.startEditing() dp = vl.dataProvider() layer = QgsMapLayerRegistry.instance().mapLayersByName("points")[0] dp.addAttributes(layer.pendingFields()) for feature in layer.getFeatures(): x1, y1, x2, y2 = (feature["x1"].toFloat()[0], ...


3

You first need to add a ID to your custom button when you create it: Create ButtonPad "Utils" As PushButton HelpMsg "Choose this button to display query dialog" Calling button_sub_proc ID 5000 '' This is the ID for the button Then you can alter the button using: Alter Button ID 5000 You can also do: Alter Button ...


3

How about running an SQL join: select tab1.attr1, tab1.attr2 from tab2, tab1 where Tab1.Site_ref = Tab2.Site_ref into q_ToSave commit table q_ToSave as "C:\NewTable.tab" This works. If Tab1 doesn't have objects in it then the order of the tables in the from clause is not important, but if there are objects in tab1 to be replaced, then specifying tab2 ...


3

Not a tutorial but something I found very useful is this site: http://www.twiav.nl/php/mapbasic.php I would highly recommend setting up Notepad++ (or something similar). Syntax highlighting, bulk indenting and bulk commenting can speed things up massively.


3

A region in MapInfo (MapBasic) can match a Polygon or a MultiPolygon in GeoJSON. For the region to be a polygon it must: a) only have one polygon or b) only have one "main" polygon and one or more number of holes If the region has multiple polygons with zero, one or more holes, I would consider this to be a MultiPolygon. The GeoJSON describing is quite ...


3

Select * from 'table' Where RowID = n If you want it into a selection table of your choice, put the selection into somename, then browse * from somename If not, just Browse from selection edit This is all from memory, so please play about and also read the online reference manual: MapBasic Ref MapInfo -L


3

You could choose the "Expression..." at the end of the list of columns when choosing the table/layer and field to use for your thematic map. This would allow you to combine these two columns using the Expression dialog with a statement like this: name_of_place + " " + some_date_column It is alse possible to create Bivariate Thematic Mapping - have a look ...


3

It isn't possible unless you write your own function, which keeps track of the index internally. MapBasic simply doesn't offer any modern container classes. Or any classes for that matter.


3

Shouldn't be that hard to write your own procedure for doing that: Sub ARRAddItem(arrValues() As String, ByVal sNewValue As String) Dim nItem As Integer nItem = Ubound(arrValues) + 1 Redim arrValues(nItem) arrValues(nItem) = sNewValue End Sub Note that it will resize the array with one and insert the value at this index


3

You can just run the SQL command right in the MapBasic code: Select * from some_table into mySelection If you do need to store the SQL query in a string (dynmic SQL string etc) you can execute it using RunCommand Dim query As String query = "Select * from some_table into mySelection" Run Command query In order to get the values from the table you need ...


3

Perhaps you can use the MapCAD tool Circle from Center and Radius/Diameter for this. For programmatically retrieving coordinates you can use the CommandInfo() function in MapBasic.


3

Compiled MapBasic should run with any version of MapInfo Pro equal or higher. Strictly speaking it depends on what features you use in the MapBasic. The compiled code is compatible but a version number is compiled in and this is checked against the MapInfo Pro version. There is a utility floating around which scans the compiled MapBasic and resets the ...


3

You can use the TableInfo() function to query a table for a number of attributes, one is whether it is mappable. Try: If TableInfo(TableName, TAB_INFO_MAPPABLE) Then Select * From TableName Where Obj Into TempTable End if


3

You have to use Mapinfo.Eval and MapInfo.Do and wrap the other requests. You can't simply call MapBasic functions in Integrated mapping, you need to do them through these two methods, if I remember correctly. So, something like this: If mapinfo.Eval("TableInfo(" & tabName & "," & 5 & ")") = "F" Then MsgBox "Cannot open table!" ...


3

Let's say we have two tables: Tab1 with field Field1, Tab2 with field Field2. We want to select records from Tab1 which Field1 values is not present in Field2 of Tab2. In MapInfo: menu Query->SQL Select... Columns: * from Tables: Tab1 where Condition: not Field1 in (select Field2 from Tab2) In MapBasic window it will be: Select * from Tab1 where not ...



Only top voted, non community-wiki answers of a minimum length are eligible