VECTOR AND RASTER DATA STORAGE BASED ON MORTON CODE

Even though geomatique is so developed nowadays, the integration of spatial data in vector and raster formats is still a very tricky problem in geographic information system environment. And there is still not a proper way to solve the problem. This article proposes a method to interpret vector data and raster data. In this paper, we saved the image data and building vector data of Guilin University of Technology to Oracle database. Then we use ADO interface to connect database to Visual C ++ and convert row and column numbers of raster data and X Y of vector data to Morton code in Visual C++ environment. This method stores vector and raster data to Oracle Database and uses Morton code instead of row and column and X Y to mark the position information of vector and raster data. Using Morton code to mark geographic information enables storage of data make full use of storage space, simultaneous analysis of vector and raster data more efficient and visualization of vector and raster more intuitive. This method is very helpful for some situations that need to analyse or display vector data and raster data at the same time. * Corresponding author: Tao Yue; E-mail: yuetao@glut.edu.cn.


INTRODUCTION
Vector and raster spatial data models are the based format for storing geographic data digitally.And both of them have their own advantages and disadvantages.Many of comprehensive geographic information systems (GIS) offering provide both integrated raster and vector analysis techniques (Turk A.G, 1992).Integrated raster and vector processing capabilities are most desirable and provide the greatest flexibility for data manipulation and analysis (Turk A.G., 1992).But there is still not a proper way to realize the integration of spatial data in vector and raster formats perfectly.Many researchers such as Wu Z. et al. (2017), Zhou G. et al. (2006) and Li C. et al. (2017) studied to unify the storage and management of vector data and raster data in spatial database, but they cannot realize the integrated vector and raster in analysis process and visualization.The other problem is that, with the maturing of UAV remote sensing true digital orthophoto map high precision mapping techniques (Zhou G. et al., 2008(Zhou G. et al., , 2009(Zhou G. et al., , 2016)), the quality of TOM (raster data) is becoming higher and higher, and the amount of data is bigger and bigger.At the same time, there are more and more image information need to be stored in database.
Referring to the above problems, this paper proposes to store vector and raster data in Oracle Database 12C based on Morton code.For the purpose of storing a large number of high quality image data, the method takes full advantage of the powerful capabilities of Oracle database management in common data and Oracle GoeRaster in image (David B., 2009).GeoRaster is a feature of Oracle Spatial and Graph that lets us store, index, query, analyse, and deliver raster image and gridded data and its associated metadata (Xie Q. et al., 2012).Using Morton code instead of row number and column number to mark the position information of vector and raster data can make connecting vector and raster data more easily and more efficient.In the future, this method can also be applied to 3D city data storage and analysis, which is now being welcomed (Zhou G. et al, 2013, Guo J. et al., 2017).Each image data should be divided into a number of small blocks called pixel.And each block is stored in a raster data table (RDT) using a BLOB object (Ravi K et al., 2007).It means that every raster data table corresponds to an SDO_GEORASTER object.In general, the position of the block is recorded using the row number and column number in RDT.This article, however, will use Morton code instead of row and column number to record the location of the block (the section 3 will describe Morton in detail).We can add some attributes such as elevation, grey scale to RDT if they are useful for spatial analysis or visualization.CREATE

Morton Code
In a 2n*2n image, i and j are used to represent the row and column number of image data.And m(i, j) is used to represent the Morton code of the i-th row and the j-th column (see Figure 2).The following conversion relationship can obtain Morton code from row and column number: In this formula: presents down remainder arithmetic, and mod() represents rounding operation.

Figure 2. Conversion of Morton code
The Morton code conversion of vector data is little different form the raster, because the information of vector point: X Y are decimal.
Figure 3 is a good explanation shows how vector data and raster data can be related by the Morton code.Assuming that the length of each block is 1 meter, then m1=m(2, 2) represents a point of vector in image in Figure 3a.And its corresponding vector point in Figure 3b is M1=M(2, 2).The Morton code of vector and raster data obtained by formula (1) are equal: m(2, 2)=M(2, 2)=12.When we want to do data processing, we can obtain vector information and raster information at the same time through Morton code.With two kinds of data information, it can make the data visualization more intuitive and the data processing more efficient.
(a) (b) Figure 3. Morton code between vector and raster Using Morton code to record the position information of vector and raster data has the following two important benefits: (1) As we all know, raster image is two-dimensional, its position information needs row number and column number to mark together.The two-dimensional image data can translate into a one-dimensional data using the Morton code, as shown in Figure 2. It can reduce data redundancy to some extent when restoring raster data.
(2) What is most important, one-dimensional image retrieval is much faster than two-dimensional image, just as twodimensional image is faster than three-dimensional image.
(3) After raster data and vector data are converted into onedimensional at the same time, they can easily correspond to each other through their common attributes, that's Morton code.In data retrieval, the location of the target can be quickly located with Morton code.It is just like the index which is useful.

Data Import
There are many C++ interfaces that can access Oracle Database, such as ODBC and ADO that are simple to use G., 2012).We use ADO interface, a comprehensive and easy-to-use API, to connect Oracle Database 12C to Visual C++.Then we import an image data of Guilin University of Technology to Raster table we created for test.
INSERT INTO GUT_image (name, image) VALUES ('gut_image', SDO_GEOR.INIT('GUT_IMAGE_RDT')); After importing image data to database, we storage the pixel information of the SDO_GEORASTER object to raster data table by using the LOB storage format SecureFile LOBs (SecureFiles).And then, we use a pointer to point to the data that needs to be saved and set some important properties.When choosing block size, we'd better trade off the size of a raster block and the number of blocks required for a Georaster object.
In this paper, we divide the image into 512 rows and 512 columns.After successfully importing data to taster data table, we can check all information of image in raster data table (see Figure 6a) and use a comprehensive ETL tool, third parties provide visualization client, to display the image in Georaster table (see Figure 4).We can use some basic functions of ETL tool to browse images, including zooming in, zooming out and roaming.It's very convenient.In order to import vector object to table, we first edit vector data to TXT in a certain format, it serves as control file.Spatial information such as spatial reference systems, geometry coordinates, and their connection order are stored in this TXT.
And then, we use the SQL*LOADER tool to import vector objects.After saving vector data we can see the information in the table.In Figure 5, we see the shape of the building geometry.
Figure 5. Shape of building

Convert to Morton Code
According to formula (1), we can convert row and column number to Morton code in Visual C++ environment: First of all, we create a function to realize of translation.Next, we convert one pair of row and column number to Morton code and update it to raster data table.Last but not least, we set up a loop statement to repeat the above steps to complete all data conversions.int getMortonNum(row, column) { //Implementation of formula (1).return (Morton code); } for (int id = 1; id <Num ; id++) // Num represents the number of pixels needed to convert the Morton code.{ //execute the query statement, get the row and column number of a pixel.int Morton= getMortonNum(row, column) //Execute the update statement and place the converted Morton code in the corresponding pixel record field.} Just like Figure 6 shows, there are row number and column number record pixel of image respectively, but after converting to Morton code, there is only one column.When we select a pixel form raster data, then system will automatically determine whether the corresponding data exists in vector data.If the corresponding data is exists, system will automatically display or analysis it.
The conversion of Morton code of vector data is just like raster data and it should use formula (2).After storing all information of vector and raster data, we can view all the vector data and raster data information by selecting vector point data or directly through the Morton code, as shown in Figure 6.

CONCLUSION
This article proposed a method to store vector and raster data in Oracle database and convert row and column number and X Y of position information to Morton code.This method makes it easy to relate vector data to raster data.When retrieving or viewing the data, we can easily get all the information including vector data and raster data.These advantages can enable some spatial analysis and visualization to save time and calculation to certain extent.Using Morton code instead of row and column and X Y to mark the positional information of vector and raster data can make retrieval of data faster.

Figure 4 .
Figure 4. Storage of raster data Figure 7. Select information from database

TABLE GUT_image_rdt
LOB (RASTERBLOCK) STORE AS (NOCACHE NOLOGGING);The vector part is described in Figure1a, there is at least one Geometry table records information of every polygon, line and point object.Every object is described in detail in one record and every record has a SDO_GEOMETRY object which includes the position of vertex, the order of vertex connection and other spatial information of polygon, line and point.Every Geometry table corresponds to a Point table.In this table, the information of every vertex such as ID, Elevation, Morton codes of polygon, line and point object are recorded individually.The method of create of the two table is resemble to raster table.