Map partitioning by region in MapInfo (with MapBasic)

Source: Internet
Author: User

Question:
I have a map composed of three layers, one for a river, one for a national big city, and one for a county or city. Now, MapInfo is centered on Foshan, splits a square map. This division is not a programming process. I hope to write down the specific steps.
Question:
I. Divide a square map? There are still many squares of the same size. What is the size of a square?
2. What reference regions are used for segmentation? Is it the square mentioned above or the area of each province or city?
3. After the split, is it a separate tab file or what? How to name it?
Question supplement:
A square is like a square, and its size is hard to say because it can be zoomed in and out through Mapinfo, but only the square can cover the city of Foshan; another mistake was made late. It was not a national map, but a map of two broad areas. Map of rivers, cities, counties, cities, and cities in different regions: If the map is in a city, it contains the entire object of the Foshan City and the objects of the cities around the Foshan City, it can only contain a small part. Similarly, in the city map, there are four districts in the big city of Foshan, and the square should contain the four districts. The surrounding counties and cities of the four districts can only contain a small part. In the river map, don't be so strict, you don't need to divide it into squares; they are saved separately, so you can separate them separately, and you don't need to separate them together.
I personally think:
I think it is hard to say that the size of a MapInfo can be enlarged or reduced. (the size I mentioned is not relative size, but absolute size, that is, the square with the length and width of meters on the map, which cannot be changed );
I think 2. If it is a city map, it contains the entire object of the Foshan City, and the objects of the surrounding cities of the Foshan City can only contain a small part (I think there is no error ), similarly, in the county and city map, there are four districts in the big city of Foshan, and the square should contain the four districts. (if there is an error, each square should include one district, there are four squares in total. PS: Baidu searched the southern network and found that there are six districts under Foshan, namely the urban area, Shiwan district, Shunde District, Nanhai District, Sanshui district, and Gaoming district. However, the national administrative code standard is queried. Code It is found that there are three districts and four counties, that is, 440601 of the city, 440602 of the city, 440603 of the city, 440681 of the Shiwan district, 440682 of the city, 440683 of the city, 440684 of the city, of the city, and of the city, gaoyi)
Think 3: only this square is required to cover the city of Foshan (then, the boundary of this area should be clear. It is best to have an administrative area like this, in this way, the size of the square is easy to determine. Otherwise, the size of the Square must be determined based on the points or lines or the line in the field, that is, the Minx, miny, maxx and Maxy are used to determine the square)
Think 4. Line and surface exceeding the square range must be broken or cut.
5. The square should be a rectangle. (I personally guess and think that if the map projection is a latitude and longitude projection, it is unlikely to be a square)

Personal solution:
Taking a large city as an example, Foshan City is divided into four districts, namely, the small cities under the big city mentioned above, which need to be divided into four squares. (If I do not have the other Party's data, I will use the Shanghai sample data for demonstration. I will split the different regions in Shanghai and each district will have an independent square)
Draw a square on an empty layer, and the square will overwrite the area. Select the points wrapped in square shape, and cut the lines and surfaces that are exposed outside the square. extract these selected point and line surfaces and split them. (I think it is quite simple to say, so it is not easy to implement two sentences. I found that many people on the Forum asked questions and asked questions. I think it should be similar to this question)

Specific steps:
In fact, I did basic first.ProgramTo solve this problem, I will first explain how to implement it Using Mapinfo, and then introduce the basic program so that the program can be easily understood.
Step 1: frame. Draw based on the administrative area. If there is no such area, find Minx, miny, Maxx, and Maxy based on what I mentioned above, and draw based on the maximum and minimum coordinates.
Step 2: solve the problem. The frame layer above is used as the bottom layer, and the vertex layer is set to editable. All vertices in the box are selected using the edge selection tool on the panel in the lower Square area. Save the selected selection table to another copy.
Step 3: solve the problem. Similarly, the square frame layer is used as the bottom layer, all objects in the line layer (or a part under a box) are selected, the line layer is set to editable, And the menu bar tool is set to an object, select a square box, and then the menu bar tool will erase the external image (or you can break it down. The method used in the following program is the decomposition method ). Note that you need to save the value after erasure, otherwise your table will be empty. Then, select the line object under the square box and save it. (You can also use the boundary selection tool. Of course, do not save the data for the next square. Just save the selected data as needed)
Step 4: solve the problem. Same as above.
Program Method:
The program contains some simple MapBasic statements, so I will not explain them much. The program has explained some of them.

MapBasic code
1 Include " MapBasic. Def "
2 Dim Minx, miny, Maxx, Maxy As Float
3 Dim Myobj As   Object
4 Dim II As   Integer
5 Open Table " G: \ sh_tab \ admin_ploy.tab "   As Admin_ploy ' Surface. The square range is based on this surface.
6 Open Table " G: \ sh_tab \ land. Tab "   As Land ' Surface
7 Open Table " G: \ sh_tab \ POI. Tab "   As Poi ' Point
8 Open Table " G: \ sh_tab \ road_line.tab "   As Road ' Line
9 Open Table " G: \ sh_tab \ Temp. Tab "   As Temp ' Temporary surface layer. Please create it in advance. It is mainly used to create a temporary square.
10 Map from temp, poi, road, land, admin_ploy
11 Set Map Layer " Temp " Editable On
12 Fetch first from admin_ploy
13 II = 1
14 Do   While   Not EOT (admin_ploy)
15   Select   * From admin_ploy where rowid = II into Tempa
16 Minx = Tableinfo (Tempa, tab_info_minx)
17 Miny = Tableinfo (Tempa, tab_info_miny)
18 Maxx = Tableinfo (Tempa, tab_info_maxx)
19 Maxy = Tableinfo (Tempa, tab_info_maxy)
20 Create rect (Minx, miny) (Maxx, Maxy)
21 II = II + 1
22 Fetch Next From admin_ploy
23 Loop
24 Set Map Layer " Temp " Editable off
25
26 Fetch first from temp
27 II = 1
28 Do   While   Not EOT (temp)
29 Myobj = Temp. OBJ
30   ' Point Selection and output. If the output is MIF, you can also directly Save
31   Select   * From poi where OBJ partly within myobj into Tempa
32 Export " Tempa " Into " G: \ sh_tab \ temp \ poi " + II + " . MIF " Type " MIF "
33   ' Line to ensure that the line is not included outside the square
34   Set Map Layer " Road " Editable On
35   Select   * From Road
36   Set Target On
37   Select   * From temp where rowid = II
38 Objects Split Into target data name = Name, Class = Class, remark = Remark
39   Select   * From road where OBJ within myobj into Tempa
40 Export " Tempa " Into " G: \ sh_tab \ temp \ Road " + II + " . MIF " Type " MIF "
41 Rollback table Road
42   Set Map Layer " Road " Editable off
43   ' Surface
44   Set Map Layer " Land " Editable On
45   Select   * From land
46   Set Target On
47   Select   * From temp where rowid = II
48 Objects Split Into target data name = Name, Class = Class, remark = Remark
49   Select   * From land where OBJ within myobj into Tempa
50 Export " Tempa " Into " G: \ sh_tab \ temp \ land " + II + " . MIF " Type " MIF "
51 Rollback table land
52   Set Map Layer " Land " Editable off
53 II = II + 1
54 Fetch Next From temp
55 Loop
56 Note " OK "
57
58

Question extension:Many other splitting problems should also be able to be used to inspire applications. For example, you can use this method to divide a 1: W graph into a large proportion of. 5 W graph. I originally wanted to use MapInfo Ole + vb, but it didn't take too much time. So I made a simple basic program first. If I have time, I can add it. I am a little tired, so some of the above is relatively simple. If you have any questions, I can give them a detailed explanation. At last, I don't know if I have implemented the function?

Thank You For Your discussion and corrections.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.