MapBasic - CreatePoint using UTM coordinates

315 views
Skip to first unread message

Michael Jenne

unread,
Jun 2, 2009, 12:29:06 PM6/2/09
to mapi...@googlegroups.com

Hello All,

I have a quick question concerning MapBasic, specifically using the CreatePoint function to create objects with UTM coordinates.

 

In this instance, I have a table that contains UTM coordinates for UTM 1983, Zone 16.

 

I have used the following code:

 

Create Map For POINT_X CoordSys Earth Projection 8, 74, "m",-81, 0, 0.9996, 500000, 0 Bounds (-7745844.29605, -9997964.94315) (8745844.29605, 9997964.94315)

Map From POINT_X

Update POINT_X set Obj = CreatePoint(UTM_EAST,UTM_NORTH)

Commit Table POINT_X

 

For whatever reason, the code doesn’t work correctly, and the points end up plotting on top of each other far removed from where they should be.  To make matters worse, I can open the same table into MapInfo and manually use the Create Points menu item (using the UTM 1983 Zone 16 projection) and they plot out just fine.

 

Any ideas on this?  Has anyone experienced a similar dilemma?

 

Thanks.

 

Mike Jenne

JCSI (Mapping/GIS/Site Intelligence for Wireless Telecommunications)

Trussville, Alabama

205-243-7571

 

Uffe Kousgaard

unread,
Jun 2, 2009, 4:26:37 PM6/2/09
to mapi...@googlegroups.com
Add:
 
Set coordsys table point_x
 
before the update statement.
 
Yes, this question is being asked at least every month so you are not the first to run into the issue. Search the archieves for "set coordsys" and you should be able to find a more detailed explanation.
 
Regards
Uffe Kousgaard

Michael Jenne

unread,
Jun 2, 2009, 4:43:56 PM6/2/09
to mapi...@googlegroups.com

Uffe,

Thank you.  I apologize for not checking the archives before posting.  I will follow up on the archives now.  Thanks again.  I hope all is well with you.

 

Mike Jenne

<BR

Uffe Kousgaard

unread,
Jun 2, 2009, 5:13:11 PM6/2/09
to mapi...@googlegroups.com
Hi,
 
In fact it is difficult to search the archieves for the solution until you know to search for "set coordsys". The problem relates to much more than just createpoint or update statement. It is about setting the coordsys in mapbasic in general - something that involves reading a lot of the mapbasic documentation in more detail (which nobody seems to like....)

Michael Jenne

unread,
Jun 2, 2009, 5:25:06 PM6/2/09
to mapi...@googlegroups.com

Correct.  I really enjoy the program, but I’m not a huge fan of the documentation.

 

Again, thank you for your kind and very timely assistance.

<BR

Andrew Hare

unread,
Jun 2, 2009, 6:48:58 PM6/2/09
to mapi...@googlegroups.com

Here is some code

 

sub create_pnt

 

    Dim x_1, y_1 As float

    Dim win_id As Integer

    Dim i_numrows_1 As SmallInt

   

'   Open Table "M:\Mapdata\Building\Property_Hazards\lut_Item_Description.TAB" Interactive

 

'Set Map XY Units "m" CoordSys Earth Projection 18, 31, "m", 173, -41, 2510000, 6023150

 

'First, make sure the user didn't click in a Layout window.

    win_id = FrontWindow()

       If WindowInfo(win_id, WIN_INFO_TYPE) <> WIN_MAPPER Then

          Note "You must click inside a MAP WINDOW."

          Exit Sub

       End If

      

' Retrieve the coordinates of the point where the user clicked.

  x_1 = CommandInfo(CMD_INFO_X)

  y_1 = CommandInfo(CMD_INFO_Y)

 

    insert into hazards (obj)

       values (createpoint(x_1,y_1))

 

    i_numrows_1 = TableInfo("hazards", TAB_INFO_Nrows)

       select * from hazards

       where rowid = i_numrows_1

       update selection

          set    X_Coord = x_1,

                 Y_Coord = y_1

             

 

   

    call Dialog_screen

 

end sub

 

 

Regards,

 

Andrew Hare

GIS Administrator

Waimate District Council

This email has been scrubbed for your protection by SMX. For more information visit smx.co.nz

Michael Jenne

unread,
Jun 2, 2009, 7:01:21 PM6/2/09
to mapi...@googlegroups.com

Andrew,

Thanks much.

 

Mike Jenne

Andrew Hare

unread,
Jun 2, 2009, 9:33:21 PM6/2/09
to mapi...@googlegroups.com

Was wrong when this happens

Icons change

Layer control disappears

Some layers disappear

 

 

Regards,

 

Andrew Hare

GIS Administrator

Waimate District Council

This email has been scrubbed for your protection by SMX. For more information visit smx.co.nz
image001.jpg

Natalie Bennett

unread,
Jun 2, 2009, 9:37:38 PM6/2/09
to mapi...@googlegroups.com
Hi Andrew,

I don't have answers, but have been getting this when using the Find
window a lot. Restarting usually fixes.

Nat Bennett
GIS Officer
Wellington Council
NSW Australia
(02) 6840 1728

>>> "Andrew Hare" <AND...@waimatedc.govt.nz> 3/06/2009 11:33 am >>>
Was wrong when this happens

Icons change

Layer control disappears

Some layers disappear







Regards,



Andrew Hare

GIS Administrator

Waimate District Council


______________________________________________________________________________

This email has been scrubbed for your protection by SMX.
For more information visit http://smx.co.nz
______________________________________________________________________________




______________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
Reply all
Reply to author
Forward
0 new messages