[R-sig-Geo] reading KML files in R
Wade Wall
wade.wall at gmail.com
Thu May 27 20:52:43 CEST 2010
I am not exactly sure what you mean by identify the correct layer
name. Using R under Linux, this is what happens.
I have a file in the current directory named ASMI_GA.kml
library(rgdal)
tmp<-readOGR(".", layer="ASMI_GA.kml")
However, I get the following message.
Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =
input_field_name_encoding) :
Cannot open file
I have expat XML parser installed and gdal. This probably sounds
rather stupid, but I am not sure what the following means in the link
that Dr. Bivand provided: "KML reading is only available if GDAL/OGR
is built with the Expat XML Parser, otherwise only KML writing will be
supported." I installed both as debian packages (using get-apt).
Should I install both from source code, Expat XML Parser first and
then GDAL?
Sorry if I seem dense here, but it is not real clear to me. Also,
even though this may be beyond the scope of R-sig-geo, I think that
other people are also struggling with this.
Thanks for any help.
Wade
On Thu, May 27, 2010 at 2:15 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
> On Thu, 27 May 2010, rick reeves wrote:
>
>> I do note that the example I provided does not demonstrate how to READ a
>> KML
>> file into R. But, SOON, I plan to modify the example to demonstrate
>> reading of KMLs
>> into some R-compatible format.
>
> readOGR() does read KML files, but you do have to identify the correct layer
> name - see:
>
> http://www.gdal.org/ogr/drv_kml.html
>
> Roger
>
>>
>> RR
>>
>> On 5/27/2010 10:15 AM, Wade Wall wrote:
>>>
>>> Hi all,
>>>
>>> Does anyone have experience reading and writing KML files in R? I
>>> have seen several threads that seem to suggest that it is difficult if
>>> not impossible, but it is convenient to use KML files when working
>>> with Google Earth and inconvenient to read and write shapefiles and
>>> then convert to KML using other software.
>>>
>>> If anyone is able to read and write KML files, if they could provide a
>>> description of how to do it, I am sure a lot of people would
>>> appreciate it. I have tried to do so under both Windows and Linux to
>>> no avail. The Windows approach looks more difficult, judging by the
>>> readme file associated with rgdal.
>>>
>>> Thanks,
>>>
>>> Wade
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>>
>>
>>
>>
>
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
>
>
More information about the R-sig-Geo
mailing list