H2D - OpenHistoricalDataMap/OHDMConverter GitHub Wiki
Importing historic vector geometries into OHDM is a two step process:
- Import the external geometries into a postgis table
- Import this table into the OHDM database.
Step 1 requires format specific database tools. Step 2 is done by our OHDMConverter.
Step 1: Import geometries into Import DB
Create a schema (e.g. import) in your OHDM DB server. Geometries come often in a standardized export format, like shapefile. Those geometries have to be imported into a PostGIS-Table.
Import Shapefiles
Use shp2pgsql for this task. It produces statement which can be processed by psql.
Assumed there is a shapefile called historicGeometries an import could look like this
shp2pgsql -s 4326 historicGeometries.dbf importSchema.historicGeometries > importCommands.sql
The spatial reference system should be set (in this case 4326). If not set, 4326 will be assumed. Geomtries are stored in table historicGeometries
in schema importSchema
Those commands are executed with psql, e.g.
psql -d your_OHDM_DB -U your_user_name -f importCommands.sql
Geometries are now in our database. In the next and final step, they are to be imported into the OHDM DB.
Step 2 Import into OHDM
Set up your historic parameter file.
servername:db_host_name
portnumber:port_number
username:user_name_on_db
pwd:your_password
dbname:ohdm
schema:importhistoric
columnNameObjectName: [enter column name that contains geoobject name]
columnNameGeometry: [enter column name that contains objects' geometry]
tableName: [enter table name]
columnValidSinceDay: [column that contains data of first valid day of this object - default 01]
columnValidSinceMonth: [column that contains data of first valid month of this object - default 01]
columnValidSinceYear: [column that contains data of first valid year of this object - validSince or this entry must be set]
columnValidUntilDay: [column that contains data of last valid day of this object - default 28]
columnValidUntilMonth: [column that contains data of last valid onth of this object - default 12]
columnValidUntilYear: [column that contains data of last valid year of this object - validUntil or this entry must be set]
validSince: [data are valid since: format yyyy-mm-dd - used if no validSince columns are defined]
validUntil: [data are valid until: format yyyy-mm-dd - used if no validUntil columns are defined]
classificationID: [enter classification id, can be found in table classification, e.g. 13 - borders]
sourceURL: [url from which you have received the data - can be empty]
sourceLicense: [data license - must be with your project of course]
sourceComments: [a comment]
sourceCitation: [even if it is not explicitly required - cite creator of the data.]
The first few lines describe database access as usual. There are more details to describe, though. Imported data usually contain more than just geometries. Very often, data even contain more geometries for a object, e.g. borders of a country but also its capital. Each import process will only import one geometry. Nevertheless, the import can be repeated with another geometry column.
We work on a graphical tool that helps to edit those configuration files.
Run the import with a command line similar to this:
java -classpath <your-jdbc-driver.jar> -jar OHDMConverter.jar -h historic_import_parameter -d ohdm_parameter
The data are now imported. Each import is logged with a row in the external_imports
table in ohdm. It contains all necessary information to remove imported data if necessary.