1

I am really new to gdal and have a real simple kml file. I tested this kml file in google earth and there was no problem displaying it. But when I try to rasterize it I get the following error:
"text.kml not recognized as a supported file format".
My command is:

gdal_rasterize -of "Gtiff" -burn 255 -burn 0 -burn 0 -burn 127 -init 0 -init 0 -init 0 -init 0 -ot Byte -ts 800 800 test.kml test.tiff

Does anyone know what I did wrong?

Update:
Using gets me: gdal_info --formats VRT -raster- (rw+v): Virtual Raster GTiff -raster- (rw+vs): GeoTIFF NITF -raster- (rw+vs): National Imagery Transmission Format RPFTOC -raster- (rovs): Raster Product Format TOC format ECRGTOC -raster- (rovs): ECRG TOC format HFA -raster- (rw+v): Erdas Imagine Images (.img) SAR_CEOS -raster- (rov): CEOS SAR Image CEOS -raster- (rov): CEOS Image JAXAPALSAR -raster- (rov): JAXA PALSAR Product Reader (Level 1.1/1.5) GFF -raster- (rov): Ground-based SAR Applications Testbed File Format (.gff) ELAS -raster- (rw+v): ELAS AIG -raster- (rov): Arc/Info Binary Grid AAIGrid -raster- (rwv): Arc/Info ASCII Grid GRASSASCIIGrid -raster- (rov): GRASS ASCII Grid SDTS -raster- (rov): SDTS Raster DTED -raster- (rwv): DTED Elevation Raster PNG -raster- (rwv): Portable Network Graphics JPEG -raster- (rwv): JPEG JFIF MEM -raster- (rw+): In Memory Raster JDEM -raster- (rov): Japanese DEM (.mem) GIF -raster- (rwv): Graphics Interchange Format (.gif) BIGGIF -raster- (rov): Graphics Interchange Format (.gif) ESAT -raster- (rov): Envisat Image Format BSB -raster- (rov): Maptech BSB Nautical Charts XPM -raster- (rwv): X11 PixMap Format BMP -raster- (rw+v): MS Windows Device Independent Bitmap DIMAP -raster- (rov): SPOT DIMAP AirSAR -raster- (rov): AirSAR Polarimetric Image RS2 -raster- (ros): RadarSat 2 XML Product SAFE -raster- (rov): Sentinel-1 SAR SAFE Product PCIDSK -raster,vector- (rw+v): PCIDSK Database File PCRaster -raster- (rw+): PCRaster Raster File ILWIS -raster- (rw+v): ILWIS Raster Map SGI -raster- (rw+): SGI Image File Format 1.0 SRTMHGT -raster- (rwv): SRTMHGT File Format Leveller -raster- (rw+): Leveller heightfield Terragen -raster- (rw+): Terragen heightfield ISIS3 -raster- (rov): USGS Astrogeology ISIS cube (Version 3) ISIS2 -raster- (rw+v): USGS Astrogeology ISIS cube (Version 2) PDS -raster- (rov): NASA Planetary Data System VICAR -raster- (rov): MIPL VICAR file TIL -raster- (rov): EarthWatch .TIL ERS -raster- (rw+v): ERMapper .ers Labelled L1B -raster- (rovs): NOAA Polar Orbiter Level 1b Data Set FIT -raster- (rwv): FIT Image GRIB -raster- (rov): GRIdded Binary (.grb) RMF -raster- (rw+v): Raster Matrix Format WCS -raster- (rovs): OGC Web Coverage Service WMS -raster- (rwvs): OGC Web Map Service MSGN -raster- (ro): EUMETSAT Archive native (.nat) RST -raster- (rw+v): Idrisi Raster A.1 INGR -raster- (rw+v): Intergraph Raster GSAG -raster- (rwv): Golden Software ASCII Grid (.grd) GSBG -raster- (rw+v): Golden Software Binary Grid (.grd) GS7BG -raster- (rw+v): Golden Software 7 Binary Grid (.grd) COSAR -raster- (rov): COSAR Annotated Binary Matrix (TerraSAR-X) TSX -raster- (rov): TerraSAR-X Product COASP -raster- (ro): DRDC COASP SAR Processor Raster R -raster- (rwv): R Object Data Store MAP -raster- (rov): OziExplorer .MAP KMLSUPEROVERLAY -raster- (rwv): Kml Super Overlay PDF -raster,vector- (w+): Geospatial PDF Rasterlite -raster- (rws): Rasterlite MBTiles -raster- (rw+v): MBTiles PLMOSAIC -raster- (ro): Planet Labs Mosaics API CALS -raster- (rw): CALS (Type 1) WMTS -raster- (rwv): OGC Web Mab Tile Service SENTINEL2 -raster- (rovs): Sentinel 2 MRF -raster- (rw+v): Meta Raster Format PNM -raster- (rw+v): Portable Pixmap Format (netpbm) DOQ1 -raster- (rov): USGS DOQ (Old Style) DOQ2 -raster- (rov): USGS DOQ (New Style) GenBin -raster- (rov): Generic Binary (.hdr Labelled) PAux -raster- (rw+): PCI .aux Labelled MFF -raster- (rw+v): Vexcel MFF Raster MFF2 -raster- (rw+): Vexcel MFF2 (HKV) Raster FujiBAS -raster- (ro): Fuji BAS Scanner Image GSC -raster- (rov): GSC Geogrid FAST -raster- (rov): EOSAT FAST Format BT -raster- (rw+v): VTP .bt (Binary Terrain) 1.3 Format LAN -raster- (rw+v): Erdas .LAN/.GIS CPG -raster- (ro): Convair PolGASP IDA -raster- (rw+v): Image Data and Analysis NDF -raster- (rov): NLAPS Data Format EIR -raster- (rov): Erdas Imagine Raw DIPEx -raster- (rov): DIPEx LCP -raster- (rwv): FARSITE v.4 Landscape File (.lcp) GTX -raster- (rw+v): NOAA Vertical Datum .GTX LOSLAS -raster- (rov): NADCON .los/.las Datum Grid Shift NTv2 -raster- (rw+vs): NTv2 Datum Grid Shift CTable2 -raster- (rw+v): CTable2 Datum Grid Shift ACE2 -raster- (rov): ACE2 SNODAS -raster- (rov): Snow Data Assimilation System KRO -raster- (rw+v): KOLOR Raw ROI_PAC -raster- (rw+v): ROI_PAC raster ENVI -raster- (rw+v): ENVI .hdr Labelled EHdr -raster- (rw+v): ESRI .hdr Labelled ISCE -raster- (rw+v): ISCE raster ARG -raster- (rwv): Azavea Raster Grid format RIK -raster- (rov): Swedish Grid RIK (.rik) USGSDEM -raster- (rwv): USGS Optional ASCII DEM (and CDED) GXF -raster- (ro): GeoSoft Grid Exchange Format NWT_GRD -raster- (rov): Northwood Numeric Grid Format .grd/.tab NWT_GRC -raster- (rov): Northwood Classified Grid Format .grc/.tab ADRG -raster- (rw+vs): ARC Digitized Raster Graphics SRP -raster- (rovs): Standard Raster Product (ASRP/USRP) BLX -raster- (rwv): Magellan topo (.blx) PostGISRaster -raster- (rws): PostGIS Raster driver SAGA -raster- (rw+v): SAGA GIS Binary Grid (.sdat) XYZ -raster- (rwv): ASCII Gridded XYZ HF2 -raster- (rwv): HF2/HFZ heightfield raster OZI -raster- (rov): OziExplorer Image File CTG -raster- (rov): USGS LULC Composite Theme Grid E00GRID -raster- (rov): Arc/Info Export E00 GRID ZMap -raster- (rwv): ZMap Plus Grid NGSGEOID -raster- (rov): NOAA NGS Geoid Height Grids IRIS -raster- (rov): IRIS data (.PPI, .CAPPi etc) GPKG -raster,vector- (rw+vs): GeoPackage PLSCENES -raster,vector- (ro): Planet Labs Scenes API HTTP -raster,vector- (ro): HTTP Fetching Wrapper So only KML overlay is found. How do configure gdal so that a "normal" KML is read?


Update2 using ogrinfo test.kml says: FAILURE: Unable to open datasource test.kml with the following drivers. -> PCIDSK -> PDF -> ESRI Shapefile -> MapInfo File -> UK .NTF -> OGR_SDTS -> S57 -> DGN -> OGR_VRT -> REC -> Memory -> BNA -> CSV -> GML -> GPX -> KML -> GeoJSON -> OGR_GMT -> GPKG -> SQLite -> WAsP -> PostgreSQL -> OpenFileGDB -> XPlane -> DXF -> Geoconcept -> GeoRSS -> GPSTrackMaker -> VFK -> PGDUMP -> OSM -> GPSBabel -> SUA -> OpenAir -> OGR_PDS -> WFS -> HTF -> AeronavFAA -> EDIGEO -> GFT -> SVG -> CouchDB -> Cloudant -> Idrisi -> ARCGEN -> SEGUKOOA -> SEGY -> ElasticSearch -> Carto -> AmigoCloud -> SXF -> Selafin -> JML -> PLSCENES -> CSW -> VDV -> TIGER -> AVCBin -> AVCE00 -> HTTP

Update3: The KML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
    <name>Testname</name>
    <Style id="ObstacleInfo">
        <LabelStyle>
            <color>ff0000ff</color>
        </LabelStyle>
        <LineStyle>
            <color>40ffffff</color>
            <width>2</width>
        </LineStyle>
    </Style>
            <Placemark>
            <name>Mast 363 ft AGL</name>
            <description>Wyhlen(Mast) 363 ft AGL/ 1.229 ft MSL</description>

            <styleUrl>#ObstacleInfo</styleUrl>
            <LineString>
                <extrude>1</extrude>
                <altitudeMode>relativeToGround</altitudeMode>
                <coordinates>
                                7.676111,47.536667,110
                                8.676111,47.536667,110
                                7.676111,47.636667,110
                                8.676111,47.636667,110
                                </coordinates>
            </LineString>
        </Placemark>        
</Document>
</kml>



Update4: ogrinfo --version GDAL 2.1.3, released 2017/20/01

ogrinfo --format KML
Format Details:
Short Name: KML
Long Name: Keyhole Markup Language (KML)
Supports: Vector
Extension: kml
Help Topic: drv_kml.html
Supports: Open() - Open existing dataset.
Supports: Create() - Create writable dataset.
Supports: Virtual IO - eg. /vsimem/
Creation Field Datatypes: Integer Real String


<CreationOptionList>
<Option name="GPX_USE_EXTENSIONS" type="boolean" description="Whether to write non-GPX attributes in an &lt;extensions&gt; tag" default="NO" />
<Option name="NameField" type="string" description="Field to use to fill the KML &lt;name&gt; element" default="Name" />
<Option name="DescriptionField" type="string" description="Field to use to fill the KML &lt;description&gt; element" default="Description" />

clampToGround relativeToGround absolute

10
  • KML is vector format and read by the OGR side of GDAL when used for example in gdal_rasterize. What does ogrinfo test.kml report?
    – user30184
    Apr 19 '17 at 7:02
  • @user30184 ogrinfo test.kml says: FAILURE: Unable to open datasource `nguyen_test.kml' with the following drivers. I added the whole list into my question
    – nguvi
    Apr 19 '17 at 8:02
  • And then gdalinfo nguyen_test.kmlif is happens to be already a KML overlay?
    – user30184
    Apr 19 '17 at 8:12
  • @user30184 too bad thats not the case. gdalinfo tells me: "ERROR 4: 'test.kml' not recognized as a supported file format. gdalinfo failed - unable to open 'test.kml'.
    – nguvi
    Apr 19 '17 at 8:14
  • Without sample data I am lost, I apologize.
    – user30184
    Apr 19 '17 at 8:17
1

Not reproduced:

$ gdal_rasterize -of "Gtiff" -burn 255 -burn 0 -burn 0 -burn 127 -init 0 -init 0 -init 0 -init 0 -ot Byte -ts 800 800 test.kml test.tiff
0...10...20...30...40...50...60...70...80...90...100 - done.
$ gdalinfo --version
GDAL 2.1.3, released 2017/20/01
$ ogrinfo --version
GDAL 2.1.3, released 2017/20/01
$ ogrinfo --format KML
Format Details:
  Short Name: KML
  Long Name: Keyhole Markup Language (KML)
  Supports: Vector
  Extension: kml
  Help Topic: drv_kml.html
  Supports: Open() - Open existing dataset.
  Supports: Create() - Create writable dataset.
  Supports: Virtual IO - eg. /vsimem/
  Creation Field Datatypes: Integer Real String

  <CreationOptionList>
    <Option name="GPX_USE_EXTENSIONS" type="boolean" description="Whether to write non-GPX attributes in an &lt;extensions&gt; tag" default="NO" />
    <Option name="NameField" type="string" description="Field to use to fill the KML &lt;name&gt; element" default="Name" />
    <Option name="DescriptionField" type="string" description="Field to use to fill the KML &lt;description&gt; element" default="Description" />
    <Option name="AltitudeMode" type="string-select" description="Value of the &lt;AltitudeMode&gt; element for 3D geometries">
      <Value>clampToGround</Value>
      <Value>relativeToGround</Value>
      <Value>absolute</Value>
    </Option>
  </CreationOptionList>

  <LayerCreationOptionList />

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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