Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How does one get the optional arguments in .dumpkml working? According to the .help .dumpkml should work like this:

.dumpkml table_name geom_column kml_path [precision] [name_column] [desc_column]

I can get it working with

.dumpkml table geom table.kml

But every point is just called 'name' and when I try:

.dumpkml table geom table.kml name_column=column

All I do is lose the geometry (x,y=0,0) and everything still gets called 'name' rather than the value within the specified column.

Any assistance appreciated, Phil.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

The arguments are positional, not named.

So if you want to specify the name_column, you have to specify the precision. If you want to specify the desc_column, you have to specify the precision and the name_column.

Here is an example:

bradh@ornata:~/devel/spatialite/libspatialite-work/test/sql_stmt_tests$ spatialite testdb1.sqlite 
SpatiaLite version ..: 3.1.0-RC2        Supported Extensions:
        - 'VirtualShape'        [direct Shapefile access]
        - 'VirtualDbf'          [direct DBF access]
        - 'VirtualXL'           [direct XLS access]
        - 'VirtualText'         [direct CSV/TXT access]
        - 'VirtualNetwork'      [Dijkstra shortest path]
        - 'RTree'               [Spatial Index - R*Tree]
        - 'MbrCache'            [Spatial Index - MBR cache]
        - 'VirtualSpatialIndex' [R*Tree metahandler]
        - 'VirtualFDO'          [FDO-OGR interoperability]
        - 'SpatiaLite'          [Spatial SQL - OGC]
PROJ.4 version ......: Rel. 4.7.1, 23 September 2009
GEOS version ........: 3.3.2-CAPI-1.7.2
SQLite version ......: 3.7.9
Enter ".help" for instructions
spatialite> .tables
SpatialIndex            geometry_columns_auth   roads_net_data        
alpha_roads             idx_roads_geom          spatial_ref_sys       
alpha_roads_net         idx_roads_geom_node     spatialite_history    
alpha_roads_net_data    idx_roads_geom_parent   views_geometry_columns
data1                   idx_roads_geom_rowid    virts_geometry_columns
geom_cols_ref_sys       roads                 
geometry_columns        roads_net             
spatialite> .headers on
spatialite> .schema alpha_roads
CREATE TABLE alpha_roads(
  id,
  geom NUM,
  node_from,
  node_to
);
CREATE TRIGGER "ggi_alpha_roads_geom" BEFORE INSERT ON "alpha_roads"
FOR EACH ROW BEGIN
SELECT RAISE(ROLLBACK, 'alpha_roads.geom violates Geometry constraint [geom-type or SRID not allowed]')
WHERE (SELECT type FROM geometry_columns
WHERE f_table_name = 'alpha_roads' AND f_geometry_column = 'geom'
AND GeometryConstraints(NEW."geom", type, srid, 'XY') = 1) IS NULL;
END;
CREATE TRIGGER "ggu_alpha_roads_geom" BEFORE UPDATE ON "alpha_roads"
FOR EACH ROW BEGIN
SELECT RAISE(ROLLBACK, 'alpha_roads.geom violates Geometry constraint [geom-type or SRID not allowed]')
WHERE (SELECT type FROM geometry_columns
WHERE f_table_name = 'alpha_roads' AND f_geometry_column = 'geom'
AND GeometryConstraints(NEW."geom", type, srid, 'XY') = 1) IS NULL;
END;

spatialite> select id,astext(geom) from alpha_roads limit 5;
id|astext(geom)
ARC_2|LINESTRING(11.207073 42.436534, 11.207147 42.436522)
ARC_3|LINESTRING(11.207147 42.436522, 11.207224 42.436518, 11.207629 42.436342, 11.207864 42.436236, 11.208152 42.436198)
ARC_4|LINESTRING(11.208152 42.436198, 11.209313 42.436293, 11.209607 42.436343)
ARC_5|LINESTRING(11.209607 42.436343, 11.210469 42.436489)
ARC_6|LINESTRING(11.210469 42.436489, 11.211013 42.436625)
spatialite> .dumpkml alpha_roads geom foo.kml 5 id

Which will give you something that starts like:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
        <Placemark><name>ARC_2</name><description>description</description><LineString><coordinates>11.20707,42.43653 11.20715,42.43652</coordinates></LineString></Placemark>
        <Placemark><name>ARC_3</name><description>description</description><LineString><coordinates>11.20715,42.43652 11.20722,42.43652 11.20763,42.43634 11.20786,42.43624 11.20815,42.4362</coordinates></LineString></Placemark>
        <Placemark><name>ARC_4</name><description>description</description><LineString><coordinates>11.20815,42.4362 11.20931,42.43629 11.20961,42.43634</coordinates></LineString></Placemark>
        <Placemark><name>ARC_5</name><description>description</description><LineString><coordinates>11.20961,42.43634 11.21047,42.43649</coordinates></LineString></Placemark>
        <Placemark><name>ARC_6</name><description>description</description><LineString><coordinates>11.21047,42.43649 11.21101,42.43662</coordinates></LineString></Placemark>

If you want to get a real description, you can use the extra element:

spatialite> .dumpkml alpha_roads geom foo.kml 5 id node_from

to get:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
        <Placemark><name>ARC_2</name><description>NODE_1</description><LineString><coordinates>11.20707,42.43653 11.20715,42.43652</coordinates></LineString></Placemark>
        <Placemark><name>ARC_3</name><description>NODE_2</description><LineString><coordinates>11.20715,42.43652 11.20722,42.43652 11.20763,42.43634 11.20786,42.43624 11.20815,42.4362</coordinates></LineString></Placemark>
        <Placemark><name>ARC_4</name><description>NODE_3</description><LineString><coordinates>11.20815,42.4362 11.20931,42.43629 11.20961,42.43634</coordinates></LineString></Placemark>
        <Placemark><name>ARC_5</name><description>NODE_4</description><LineString><coordinates>11.20961,42.43634 11.21047,42.43649</coordinates></LineString></Placemark>

It might look slight different on your machine, since this is a wierd out of date, pre-release with devel changes machine :-)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.