Tag Info

Hot answers tagged

9

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 wirte the MapBasic statements required. You can now copy these into ...


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 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


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

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 ...


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

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

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

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 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

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

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

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

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 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

Alan, You could create a MapBasic application that has this functionality, but if just a single user enters data without this application, the values might no longer match your valid data. MapInfo Pro is very basic when it comes to constraints. Another solution would be to use a (spatial) database to store you data. Here you can add constraints and so make ...


3

MapInfo doesn't support field validation in the native TAB file. There are no built-in tools like Domains in ArcGIS. However, if you store your data in a database, you may be able to enforce some data validation. MapInfo does support a different type of TAB file which stores the data in an Access Database. When you save a copy of your TAB file, you'll be ...


3

Your dialog has at least three controls: A Edit text control with an ID A Button with the title "Browse" A OKButton with the title "Upload" When you click the Browse button you should call a handler (a sub procedure) where you use the FileOpenDlg() function to ask the user to pick a file of a certain type. Then you should add the selected file name to ...


3

When doing a group-by you need to do it this way: select field1, field2, aggregate(field3), aggregate(field4), count(*) from .. group by field1, field2 This means fields NOT listed in the group by, needs to be aggregated in some way such as sum, avg etc. Alternatively they should not be in the select at all. In your case you have both area(obj,"sq km"), ...


2

Ten years ago I wanted exactly the same functionality in Avenue in Arcview 3.x but there was not to much to do about it. A few years ago I started using PostGIS and since it is Open Source there were new possibilities. Now PostGIS has this functionality in ST_Shortestline since version 1.5. Here is a shortversion how to make it (In 2D): There is two ...


2

To copy the objects from the layout onto the clipboard you can do the following: dim strLayWinName As String strLayWinName = WindowInfo(FrontWindow(), 10) ' assuming layout window is front window Select * From strLayWinNAme Run Menu Command 203 You will then need to work out how to switch instances of MapInfo (or just open a new one). Then you need to set ...


2

I have done this but as far as I know you have to select the text object using the text that is in that object. Here is some example code which finds an object by looking for the the text in the variable searchText: Dim searchText, newText as String Dim oLayout As Object strLayWinName = WindowInfo(WindowID(FrontWindow()), WIN_INFO_TABLE) searchText = "@01" ...


2

If I understand you correctly, I think you want to be able to find out in MapBasic what table a query is based on. In your queries I would advise adding the into clause to the end of the select statement so you know what the table name is you are dealing with. For eg. Select * from earth where population >100 into qryName To determine whether a table ...


2

This should help with creating custom buttons. http://twiav.nl/files/TWIAV_TIP_MB001.pdf Also try the MapInfo-L mailing list: http://groups.google.com/group/mapinfo-l


2

Well that wasn't so hard. Declare Sub Main Declare Function RemoveSpecialChars(byval str as string) as String Sub Main Dim t as string t = "this is a string with spaces and ' ! * & ^ % $ £ punctuation" Print Chr$(12) + "Original String: " + t Print "Tidy string: " + RemoveSpecialChars(t) End Program End Sub Function ...



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