[R-sig-Geo] How to read or import a kml file in R

Alex Mandel tech_dev at wildintellect.com
Mon Mar 24 20:37:44 CET 2014


Ya, there are some exceptions. ie Styling is not really supported,
though work on the OGR side is in progress on that. Also there are some
kml files that merely have urls to some web server where the kml really
is (ie exports from Google maps). These notoriously don't work with OGR
or other kml engines.

The hack is to use google earth to open them and then save them back out
to yet another kml that actually has the data (I'm oversimplifying the
steps).

http://gdal.org/ogr/ogr_formats.html

FYI, if you use the Libkml driver you might get more details than the
traditional OGR kml drivers. Libkml behaves more like google earth,
since it's also written by google.

Thanks,
Alex

On 03/24/2014 11:38 AM, Hodgess, Erin wrote:
> I didn't realize that readOGR could do that.  Very cool!  Thanks for the good info.
> 
> ________________________________________
> From: Alex Mandel [tech_dev at wildintellect.com]
> Sent: Monday, March 24, 2014 1:30 PM
> To: Hodgess, Erin; Manuel Spínola; r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] How to read or import a kml file in R
> 
> Well that hardly seems the whole story.
> rgdal package's readOGR should be able to import kml into an sp object,
> which can be analyzed or plotted.
> 
> https://stat.ethz.ch/pipermail/r-sig-geo/2010-May/008370.html
> 
> I think Erin was confusing it with KMZ files which are a bundle of kml +
> images(sometimes) that are hard to use anywhere but Google Earth. Though
> the trick is to just unzip them and use the components individually.
> 
> Thanks,
> Alex
> 
> On 03/24/2014 11:16 AM, Hodgess, Erin wrote:
>> Hello Manuel:
>>
>> Not sure what you're trying to do.  KML files display in Google Earth & Google Maps.
>>
>> You can create KML files in R but not display them.
>>
>> Hope this helps!
>>
>> Sincerely,
>> Erin
>>
>> ________________________________________
>> From: r-sig-geo-bounces at r-project.org [r-sig-geo-bounces at r-project.org] on behalf of Manuel Spínola [mspinola10 at gmail.com]
>> Sent: Monday, March 24, 2014 1:02 PM
>> To: r-sig-geo at r-project.org
>> Subject: [R-sig-Geo] How to read or import a kml file in R
>>
>> Dear list members,
>>
>> How to read a .kml file in R.  I was reading some threads on this, but I
>> stll don't understand how to do it.
>>
>> The name of my file is "Circuito Tamarindo.kml"
>>
>> Best,
>>
>> Manuel
>>
>> --
>> *Manuel Spínola, Ph.D.*
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspinola at una.ac.cr
>> mspinola10 at gmail.com
>> Teléfono: (506) 2277-3598
>> Fax: (506) 2237-7036
>> Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
>> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>>
>>         [[alternative HTML version deleted]]
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list