1. Background
In the production of the overall open source toolbox products, data warehousing is an important link. Although PostGIS provides data warehousing interface operations, this tool cannot be integrated into our toolbox, and the tool interface, operation is not ideal, and can not be customized to complete a number of specific requirements. Therefore, it is more necessary to make a self-made SHP storage tool.
2. Thinking 2.1 shp Import idea
SHP import into the database, whether it is PostgreSQL, MySQL, Oracle, etc., is the first to convert SHP to match the corresponding database of SQL, and then import into the corresponding database.
For PostgreSQL, the Pgsql2shp.exe tool in the PG installation path enables the conversion of SHP data into compliant SQL.
2.2 Batch Import Ideas
We can use the Write BAT file to import each SQL generated by the transformation in turn.
2.3 Precautions
Problems with missing spatial information tables and spatial functions may occur in a.postgresql, resulting in data not being imported. For this kind of problem, we can check the related table and function before importing, and then make the whole batch import.
B.SHP and shp where the file path needs to be in English.
3. Flowchart Design
4. Implement
--Welcome reprint, but retain the copyright, please indicate the source in obvious place: http://www.cnblogs.com/naaoveGIS/
Principle and design of SHP data batch importing PostgreSQL tool