2

住所情報を含む .csv ファイルがある場合は、それを Google Earth (以降、GE と呼びます) にドラッグ アンド ドロップすると、ウィザードが表示され、フィールドを割り当てることができます。GE は場所のジオコーディングを開始し、各住所のポイント (緯度と経度) を作成します。その後、ジオコーディングされたファイルを kml としてエクスポートし、各ポイントの緯度/経度を取得できます。ただし、このプロセスには 2500 行の制限があります。

kml (またはおそらく xml) ファイルを作成して GE に取り込み、ジオコーディング プロセスを開始することができ、この方法には行制限がないことを聞いたことがあります。誰かがこれを行う方法を理解するのを手伝ってもらえますか? 次のコードを試してみましたが、GE に正常にインポートされますが、ポイントが作成されません。

同様のことを行うことができ、ビジネスで使用するために1日あたり100,000行の行制限があるGoogle Maps APIをいくつか知っていますが、GEでプロセスを機能させたいと思っています.

<?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>GEImport1.csv</name>
    <Schema name="GEImport1" id="S_GEImport1_S">
        <SimpleField type="string" name="Adress"><displayName>&lt;b&gt;Adress&lt;/b&gt;</displayName>
</SimpleField>
    </Schema>
    <Style id="hlightPointStyle">
        <IconStyle>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href>
            </Icon>
        </IconStyle>
        <BalloonStyle>
            <text><![CDATA[<table border="0">
  <tr><td><b>Adress</b></td><td>$[GEImport1/Adress]</td></tr>
</table>
]]></text>
        </BalloonStyle>
    </Style>
    <Style id="normPointStyle">
        <IconStyle>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href>
            </Icon>
        </IconStyle>
        <BalloonStyle>
            <text><![CDATA[<table border="0">
  <tr><td><b>Adress</b></td><td>$[GEImport1/Adress]</td></tr>
</table>
]]></text>
        </BalloonStyle>
    </Style>
    <StyleMap id="pointStyleMap">
        <Pair>
            <key>normal</key>
            <styleUrl>#normPointStyle</styleUrl>
        </Pair>
        <Pair>
            <key>highlight</key>
            <styleUrl>#hlightPointStyle</styleUrl>
        </Pair>
    </StyleMap>
    <Folder id="layer 0">
        <name>GEImport1</name>
        <visibility>0</visibility>
        <Placemark>
            <visibility>0</visibility>
            <styleUrl>#pointStyleMap</styleUrl>
            <ExtendedData>
                <SchemaData schemaUrl="#S_GEImport1_S">
                    <SimpleData name="Adress">6212 GATUN CT Port ST Lucie, FL</SimpleData>
                </SchemaData>
            </ExtendedData>
        </Placemark>
        <Placemark>
            <visibility>0</visibility>
            <styleUrl>#pointStyleMap</styleUrl>
            <ExtendedData>
                <SchemaData schemaUrl="#S_GEImport1_S">
                    <SimpleData name="Adress">6213 DIANA CT Port ST Lucie, FL</SimpleData>
                </SchemaData>
            </ExtendedData>
        </Placemark>
        <Placemark>
            <visibility>0</visibility>
            <styleUrl>#pointStyleMap</styleUrl>
            <ExtendedData>
                <SchemaData schemaUrl="#S_GEImport1_S">
                    <SimpleData name="Adress">6213 DUKE CIR Port ST Lucie, FL</SimpleData>
                </SchemaData>
            </ExtendedData>
        </Placemark>
    </Folder>
</Document>
</kml>

編集: 最終結果
JasonM1 のソリューションはうまくいきました! kmlファイルの次の形式になりました。

<?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>AddressImport</name>
    <Style id="normPointStyle">
        <IconStyle>
            <Icon>
                <href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href>
            </Icon>
        </IconStyle>
        <BalloonStyle>
            <text><![CDATA[<table border="0">
          <tr><td><b>Address</b></td><td>$[address]</td></tr>
          </table>]]>
      </text>
        </BalloonStyle>
    </Style>
    <StyleMap id="pointStyleMap">
        <Pair>
            <key>normal</key>
            <styleUrl>#normPointStyle</styleUrl>
        </Pair>
    </StyleMap>
    <Folder id="layer 0">
        <name>AddressImport</name>
        <visibility>1</visibility>
        <Placemark>
            <visibility>1</visibility>
            <address>9994 CHADWICK DR Port ST Lucie, FL</address>
            <styleUrl>#pointStyleMap</styleUrl>
        </Placemark>
        <Placemark>
            <visibility>1</visibility>
            <address>9995 AMBROSE WAY Port ST Lucie, FL</address>
            <styleUrl>#pointStyleMap</styleUrl>
        </Placemark>
        <Placemark>
            <visibility>1</visibility>
            <address>9997 STONEGATE DR Port ST Lucie, FL</address>
            <styleUrl>#pointStyleMap</styleUrl>
        </Placemark>
    </Folder>
</Document>
</kml>

また、次の Excel VBA コードを使用して、kml ファイルを自動的に作成しました。

Sub CreateCSV_FSO()
    Dim objFSO
    Dim objTF
    Dim ws As Worksheet
    Dim lRow As Long
    Dim lCol As Long
    Dim strTmp As String
    Dim lFnum As Long
    Dim sFilePath As String
    Dim i As Long
    Dim x As Integer 'used to represent the column that contains the address
    sFilePath = ActiveWorkbook.Path & "\AddressImport.kml"

    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objTF = objFSO.createtextfile(sFilePath, True, False)

    'Header information
    objTF.writeline "<?xml version=""1.0"" encoding=""UTF-8""?>"
    objTF.writeline "<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"">"
    objTF.writeline "    <Document>"
    objTF.writeline "<name>AddressImport</name>"
    objTF.writeline "    <Style id=""normPointStyle"">"
    objTF.writeline "        <IconStyle>"
    objTF.writeline "            <Icon>"
    objTF.writeline "                <href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href>"
    objTF.writeline "            </Icon>"
    objTF.writeline "        </IconStyle>"
    objTF.writeline "        <BalloonStyle>"
    objTF.writeline "            <text><![CDATA[<table border=""0"">"
    objTF.writeline "          <tr><td><b>Address</b></td><td>$[address]</td></tr>"
    objTF.writeline "          </table>]]>"
    objTF.writeline "      </text>"
    objTF.writeline "        </BalloonStyle>"
    objTF.writeline "    </Style>"
    objTF.writeline "    <StyleMap id=""pointStyleMap"">"
    objTF.writeline "        <Pair>"
    objTF.writeline "            <key>normal</key>"
    objTF.writeline "            <styleUrl>#normPointStyle</styleUrl>"
    objTF.writeline "        </Pair>"
    objTF.writeline "    </StyleMap>"
    objTF.writeline "    <Folder id=""layer 0"">"
    objTF.writeline "        <name>AddressImport</name>"
    objTF.writeline "        <visibility>1</visibility>"

    'input the number representative of the column that contains the address
    x = 7 'a=1,b=2,c=3,d=4.....etc.
    i = 2
    While Cells(i, x) <> ""

        strTmp = ""
        strTmp = Cells(i, x)
        strTmp = Replace(strTmp, "&", "and")

        objTF.writeline "        <Placemark>"
        objTF.writeline "            <visibility>1</visibility>"
        objTF.writeline "            <address>" & strTmp & "</address>"
        objTF.writeline "            <styleUrl>#pointStyleMap</styleUrl>"
        objTF.writeline "        </Placemark>"


        strTmp = Cells(i, x)
        i = i + 1
    Wend

    objTF.writeline "    </Folder>"
    objTF.writeline "</Document>"
    objTF.writeline "</kml>"


    objTF.Close
    Set objFSO = Nothing
    MsgBox "Done!", vbOKOnly

End Sub
4

1 に答える 1

2

Google Earth が住所を自動的にジオコーディングする KMLの < address > 要素を使用します。

<Placemark>
    <visibility>0</visibility>
    <address>6213 DUKE CIR Port ST Lucie, FL</address>
    <styleUrl>#pointStyleMap</styleUrl>             
</Placemark>

<address>緯度と経度の座標を使用する代わりに、タグを使用してポイントの位置を指定できます。(ただし、 が指定されている場合<Point>は、 が優先されます<address>。)

また、Schema 要素とAdress SchemaData 要素は不要になり、BalloonStyle テキストの$[address]フィールドを直接インライン化できます。

<BalloonStyle>
      <text><![CDATA[<table border="0">
          <tr><td><b>Adress</b></td><td>$[address]</td></tr>
          </table>]]>
      </text>
</BalloonStyle>

KML ファイルを Google Earth に読み込んで保存すると、Google Earth によって、座標が入力された次のように変更されます。

<Placemark>
    <address>6213 DUKE CIR Port ST Lucie, FL</address>
    <styleUrl>#pointStyleMap</styleUrl>
    <MultiGeometry>
        <Point>
            <coordinates>-80.36086,27.366379,0</coordinates>
        </Point>
        <LinearRing>
            <coordinates>
                -80.36086,27.366379,0 -80.36086,27.366379,0 -80.36086,27.366379,0 -80.36086,27.366379,0 -80.36086,27.366379,0 
            </coordinates>
        </LinearRing>
    </MultiGeometry>
</Placemark>
于 2013-03-20T14:04:09.073 に答える