How to import file. KMZ to R

Asked

Viewed 198 times

0

Hello, good afternoon!

I would like to import polygons saved in google Earth in formed . KMZ, for R, can even an example (https://gis.stackexchange.com/questions/247413/importing-kml-files-to-r) , using the package rgdal, following the suggestion:

file <- "IRRIGA_TEST.kmz"
teste<- readOGR(file,"IRRIGA_TEST")

But it presents another type of error!!!

test<- readOGR(file,"IRRIGA_TEST") Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open data source

Example of how the file structure is! exemplo da estrutura e conteúdo do arquivo

What I really need, a way to get these polygons to R. in a practical way, without having to manually use some converter!

If possible, what would be the continuation of the commands so I could plot these polygons on R?

Why this need, I can’t use the RgoogleMaps because now google asks key api.

I don’t know how to upload the KMZ file here, so it follows in code format:

<?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>IRRIGA_TEST.kmz</name>
    <Style id="s_ylw-pushpin_hl">
        <IconStyle>
            <scale>1.3</scale>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
            </Icon>
            <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
        </IconStyle>
        <LineStyle>
            <width>3</width>
        </LineStyle>
        <PolyStyle>
            <color>00ffffff</color>
        </PolyStyle>
    </Style>
    <StyleMap id="m_ylw-pushpin">
        <Pair>
            <key>normal</key>
            <styleUrl>#s_ylw-pushpin</styleUrl>
        </Pair>
        <Pair>
            <key>highlight</key>
            <styleUrl>#s_ylw-pushpin_hl</styleUrl>
        </Pair>
    </StyleMap>
    <Style id="s_ylw-pushpin">
        <IconStyle>
            <scale>1.1</scale>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
            </Icon>
            <hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
        </IconStyle>
        <LineStyle>
            <width>3</width>
        </LineStyle>
        <PolyStyle>
            <color>00ffffff</color>
        </PolyStyle>
    </Style>
    <Folder>
        <name>IRRIGA_TEST</name>
        <open>1</open>
        <Placemark>
            <name>ATO</name>
            <styleUrl>#m_ylw-pushpin</styleUrl>
            <Polygon>
                <tessellate>1</tessellate>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            -41.61239043011333,-20.25984928359816,0 -41.61263549363422,-20.25968234232641,0 -41.6127091607348,-20.25975258399449,0 -41.61281291852859,-20.25971445755573,0 -41.6128791025759,-20.25977820203531,0 -41.6129237671286,-20.25975826307046,0 -41.61309969780471,-20.25960094504155,0 -41.61296826382507,-20.25935174284447,0 -41.61368879755981,-20.25919603492147,0 -41.61677860590577,-20.26171412364079,0 -41.61627006636545,-20.2622403709807,0 -41.61239043011333,-20.25984928359816,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
        <Placemark>
            <name>RH</name>
            <styleUrl>#m_ylw-pushpin</styleUrl>
            <Polygon>
                <tessellate>1</tessellate>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                            -41.60972141517327,-20.25776286279268,0 -41.6099862904024,-20.25770944143978,0 -41.61004049618223,-20.25784889299789,0 -41.60973968756554,-20.25787964993655,0 -41.60972141517327,-20.25776286279268,0 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
    </Folder>
</Document>
</kml>
  • try to work with the arguments encoding and use_iconvof function

  • I have no idea how to use!!! or what information put!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.