Converter from SHP




General

shp2cdh5.exe is an application that converts your shp/dbf files to CadH5. A CadH5 user, assigned to your project, granted with CadH5 Administrator rights, can upload files to the project.

Download the .zip file and unzip it to one directory.

It contains these programs:



shp2cdh5Win.exe

This is a .NET (3.5) wrapper program around shp2cdh5.exe and dumpCdh5ToTxt.exe, to make it more easy for Windows users to convert their .shp files. You can manage some settings that internally are translated to arguments, and then do the conversion. It expects shp2cdh5.exe and dumpCdh5ToTxt.exe to reside in the same path as shp2cdh5Win.exe. Settings are stored in a file shp2cdh5Win.ini, also in this path.



shp2cdh5.exe

This Windows command line program converts a directory with .shp files into one .cdh5 file with one level per input .shp file. This is the 'usage' text:

All .shp in dir will be processed; every .shp needs a samename.shx;\n");
optionally a samename.dbf; every .shp goes to one level in outfile\n");
Options:\n");
-dumpcdh5totxt fullpathcdh5file (create .txt in path cdh5file with large report)\n\n");
-dumpshp N (print coordinates instead of make dgh5; N: nr of digits, 1 or higher)\n\n");
-o outfile.cdh5 (in currentdir, or give fullpath) (default: out.cdh5)\n");
-prec N (where N is precision) (default: 10000)\n");
-mainrsz N (where N is size mainrange in mainunits) (default: 500)\n");
-dispstats (to display nrof shapetypes/parttypes at the end) (default: no)\n");
-leveltbl (path/name file tbl colors/linew levels)(default: no, random)\n");
-extrashptyp NAME (add extra attr, defname NAME, with int shapetype)\n");
-extraparttyp NAME (add extra attr, defname NAME, with int parttype)\n");
-extrapartnr NAME (add extra attr, defname NAME, with partnr 1-BASED)\n");
-extrashpnrparts NAME (add extra attr, defname NAME, nr-of-parts shape)\n");
 (but 0 may happen for shapes without parts)\n");

This program creates a .cdh5 file from files *.shp from the input directory. One .shp file results in one level in the output file, with the file name as the level name. The symbology (color, linewidth) of the levels can be configured in a level table, or randomly be determined.

The converter ignores any .prj file and does not perform latlon projections. If your .shp input is actually latitude and longitude, they are just considered X and Y. It is better to set a MainRange size of 1, or 2, instead of the default of 500, in that case.

Leveltable: after option -leveltbl you specify the full path of the leveltable. This is a comma- or semicolon separated file. Lines starting with # are ignored (comment lines). Every other line must contain these parts: levelname, color (which is called "style" in HTML5 terms), linewidth (>= 1), fillcolor, fillalpha (a transparency number from 0.0 to 1.0, where 1.0 is intransparent).
Colors are specified as hexadecimal rgb values starting with #, or as the int value (example: 16777215 is white).
Fillcolor: -1 means "no fill".
The program looks up the values with levelname (which is the .shp file name) as the key, case-independent. If the level is not found in the table data, for example if no leveltable is used, then random values are used for the different levels.

Example, used for demo_dresden_big.cdh5:

#level;color;linewidth;fillcolor;fillalpha
gis_osm_buildings_v06;#00ff00;3;#00ff00;0.3
gis_osm_pois_a_v06;#880000;2;#880000;0.3

The option -dumpshp 3 (not available from shp2cdh5Win.exe wrapper) makes it suppress the creation of the output file, but listing .shp coordinates in the console, with 3 digits precision (3 is an example; it must be 1 or higher).



dumpCdh5ToTxt.exe

This program allows you to select a .cdh5 file. It then creates a .txt file with the same name in the same path. The .txt file shows a lot of internal details of the file, that may be of interest, for example how many 'MainRanges' it contains. It is also a check: if inconsistencies are found, those will be reported as errors.

From shp2cdh5Win.exe, it is invoked from the menu Extra > Dump cdh5 to txt



Linux users

Linux users are probably able to use shp2cdh5.exe and dumpCdh5ToTxt.exe by means of "Wine", but we currently have not the possibilities of trying it out.