How to convert data from shapefile to GML

Source: Internet
Author: User

The conversion process from data in the shapefile format to data in the GML format can be divided into two major steps: one is to obtain data based on the data in the shapefile data documentation, and the other is to construct the data in the GML format according to the GML standard. From the analysis of the shapefile data format and the GML format, we can see that the acquisition of shapefile documents mainly reads the coordinate file and attribute file, and creates the corresponding schema file according to the field description of DBF, use the DBF field name as the child node of the feature element, and select the GML ry of GML based on the geometric type of the SHP file storage. the identifier defined by XSD. The GPS program for creating GML is to store the read shapefile data in the format of GML. The figure below shows an algorithm flow chart designed to convert the shapfile file to the GML document. This algorithm can effectively convert the shapfile file to the GML document. String 6

String 6

 

Conversion algorithm flow from shape file to GML document

String 4

 

Refer to the open-source geotools class library and assc (another simple shapefile converter) class library, and use the basic classes provided in these two class libraries to convert the shapefile format and the shapefile to the GML format, quickly, conveniently, and effectively converts SHP-GML (shapefile format to GML format. The process of obtaining shapefile data using the geotools and assc base class libraries.

String 8

 

String 3

 

Shape file data acquisition process

String 6

 

Description: first, define a new shapefileinfo class. Use this class to obtain the description and number of records of the Data Type in the shapefile file, and store the information in a temp vector. The temp vector is saved with the field name, field type, field description information in the DBF file, coordinate range, field count, record count, and field length information in the shapefileinfo class. The simpleclassdata class is saved to the temp vector, including the shapefile type description, space data color table, and file name information. At this point, the data parsing process ends. Next, we need to build the GML document.

String 5

 

Shape files are organized according to the object type. The object type can be divided into three types: point, line, and polygon. A shape file can only contain one type of object, that is, only one of the points, lines, or surface features can be included. For the three types of points, lines, and faces, create the GML data process.

String 1

 

Step 1: generate a file with the suffix "GML" and write the XML declaration. Step 2: Obtain the coordinate range of the GML data from the temp vector and define the featuremember tag. Step 3: Determine the data type based on featuremember. Call different build processes based on data types. For points, lines, and surfaces, the specific construction process is basically similar. The following uses the line as an example to describe GIS in detail. If it is a line, write the linestring tag and construct the current line element. If it is multiline, write the multilinestring tag and construct each line element in the multiline. At this time, repeat the above judgment. After all types of data in the SHP data are converted, these types of GML tags are integrated into a GML file, SHP data to GML data is successfully converted.

String 2

 

String 3

 

SHP-to-GML construction Flowchart

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.