[Proj] ogr2ogr to convert KML files into ESRI Shapefiles?
Frank Warmerdam
warmerdam at pobox.com
Thu Mar 3 10:48:35 EST 2011
On 11-03-03 06:50 AM, Roger Oberholtzer wrote:
> As the subject says, I am trying to convert KML files into ESRI
> Shapefiles. I use a command like this:
>
> ogr2ogr -f "ESRI Shapefile" rst31_tyid2_2.shp rst31_tyid2_2.kml
>
> I get the following error:
>
> ERROR 1: Attempt to write non-point (LINESTRING) geometry to point shapefile.
> ERROR 1: Terminating translation prematurely after failed
> translation of layer DATA from RST (use -skipfailures to skip errors)
>
> Indeed the kml file does have a<linestring/> component. It is a path
> defined by WGS84 latitudes, longitudes and altitudes. I'm sensing this
> is a problem for shapefiles. Is there a reasonable solution?
Roger,
This question would be better addressed to the GDAL/OGR mailing list
(gdal-dev at lists.osgeo.org). I imagine the problem is that the kml file
has a mixture of geometry types in it, perhaps points and lines? Shapefiles
can only hold one type of geometry - in the above case likely established
by the first geometry written to the file.
You will need to do something like:
ogr2ogr out_points.shp your.kml -skipfailures -nlt point
ogr2ogr out_lines.shp your.kml -skipfailures -nlt linestring
ogr2ogr out_poly.shp your.kml -skipfailures -nlt polygon
Good luck,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Proj
mailing list