[gdal-dev] ogr2ogr: problems converting from shapefile to kml

Vishal Mehta vishal.mehta at sei-us.org
Wed Apr 6 18:39:59 EDT 2011


Hi all,

I'm having some trouble with a simple conversion from shapefile to kml.
Description
1. I need to have a points file in kml that is is EPSG 3857 (the mercator that Google uses)
2. I have a points file in both shapefile as well as kml format, in EPSG 4326
3. Here are the things i tried using ogr2ogr - all failed (in all cases except first, result was a kml file in EPSG 4326

a. projecting from kml (in 4326) to kml (in 3857) : result is warning message with no file generated
vishal at SEI-Davis:~/Bangalore$ ogr2ogr -t_srs EPSG:3857 borewells_3857 borewells.kml
Warning 6: Normalized/laundered field name: 'Description' to 'Descriptio'

b. projecting the original shp (4326) to shp (3857), then transforming the  shp (3857) to kml(3857)
- here, in the first step the projection occurred, but the shp had no SRS defined(!)
- so i assigned an srs to the projected shp creating a new shp

vishal at SEI-Davis:~/Bangalore$ ogr2ogr -s_srs EPSG:3857 -t_srs EPSG:3857 vectors/borewells_proj.shp vectors/borewells_proj2.shp
vishal at SEI-Davis:~/Bangalore$ ogrinfo -al vectors/borewells_proj2.shp |head -35
INFO: Open of `vectors/borewells_proj2.shp'
      using driver `ESRI Shapefile' successful.

Layer name: borewells_proj2
Geometry: Point
Feature Count: 472
Extent: (8631985.036287, 1453323.352994) - (8640606.797279, 1460268.097365)
Layer SRS WKT:
PROJCS["WGS_84_Pseudo_Mercator",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_1984",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["Meter",1],
    PARAMETER["latitude_of_origin",0.0]]
UTM_X_: Real (16.6)
UTM_Y_: Real (16.6)
Code_No: String (254.0)
Water_Leve: Real (16.6)
OGRFeature(borewells_proj2):0
  UTM_X_ (Real) =    779330.000000
  UTM_Y_ (Real) =   1437291.000000
  Code_No (String) = BN1
  Water_Leve (Real) =         6.550000
  POINT (8635605.072968550026417 1458434.537971410667524)
...

- then i tried converting borewells_proj2.shp to kml
ogr2ogr -f KML borewells_proj2.kml vectors/borewells_proj2.shp

- but, the kml file is STILL in EPSG 4326 and is also missing the Z field

vishal at SEI-Davis:~/Bangalore$ ogrinfo -al borewells_proj2.kml |head -35
Had to open data source read-only.
INFO: Open of `borewells_proj2.kml'
      using driver `KML' successful.

Layer name: borewells_proj2
Geometry: Point
Feature Count: 472
Extent: (77.542441, 13.028161) - (77.619892, 13.089322)
Layer SRS WKT:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        TOWGS84[0,0,0,0,0,0,0],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9108"]],
    AUTHORITY["EPSG","4326"]]
Name: String (0.0)
Description: String (0.0)
OGRFeature(borewells_proj2):0
  Name (String) = 
  Description (String) = 
  POINT (77.574960246677222 13.073175653949869)
...

Help?
Vishal


More information about the gdal-dev mailing list