使用awk从另一个KML文件创建KML文件

时间:2019-03-04 22:21:04

标签: awk

尝试获取一个非常大的KML文件(sample.kml):

<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="tl_2010_19013_tabblock10" id="tl_2010_19013_tabblock10">
    <SimpleField name="STATEFP10" type="string"></SimpleField>
    <SimpleField name="COUNTYFP10" type="string"></SimpleField>
    <SimpleField name="TRACTCE10" type="string"></SimpleField>
    <SimpleField name="BLOCKCE10" type="string"></SimpleField>
    <SimpleField name="GEOID10" type="string"></SimpleField>
    <SimpleField name="NAME10" type="string"></SimpleField>
    <SimpleField name="MTFCC10" type="string"></SimpleField>
    <SimpleField name="UR10" type="string"></SimpleField>
    <SimpleField name="UACE10" type="string"></SimpleField>
    <SimpleField name="UATYP10" type="string"></SimpleField>
    <SimpleField name="FUNCSTAT10" type="string"></SimpleField>
    <SimpleField name="ALAND10" type="float"></SimpleField>
    <SimpleField name="AWATER10" type="float"></SimpleField>
    <SimpleField name="INTPTLAT10" type="string"></SimpleField>
    <SimpleField name="INTPTLON10" type="string"></SimpleField>
</Schema>
<Folder><name>tl_2010_19013_tabblock10</name>
<Placemark>
    <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
    <ExtendedData><SchemaData schemaUrl="#tl_2010_19013_tabblock10">
        <SimpleData name="STATEFP10">19</SimpleData>
        <SimpleData name="COUNTYFP10">013</SimpleData>
        <SimpleData name="TRACTCE10">002700</SimpleData>
        <SimpleData name="BLOCKCE10">2051</SimpleData>
        <SimpleData name="GEOID10">190130027002051</SimpleData>
        <SimpleData name="NAME10">Block 2051</SimpleData>
        <SimpleData name="MTFCC10">G5040</SimpleData>
        <SimpleData name="UR10">R</SimpleData>
        <SimpleData name="FUNCSTAT10">S</SimpleData>
        <SimpleData name="ALAND10">3890</SimpleData>
        <SimpleData name="AWATER10">0</SimpleData>
        <SimpleData name="INTPTLAT10">+42.4779525</SimpleData>
        <SimpleData name="INTPTLON10">-092.2489677</SimpleData>
    </SchemaData></ExtendedData>
      <Polygon><outerBoundaryIs><LinearRing><coordinates>-92.248857,42.476255 -92.248998,42.476256 -92.24906,42.479886 -92.248968,42.479915 -92.248857,42.476255</coordinates></LinearRing></outerBoundaryIs></Polygon>
  </Placemark>
  <Placemark>
    <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
    <ExtendedData><SchemaData schemaUrl="#tl_2010_19013_tabblock10">
        <SimpleData name="STATEFP10">19</SimpleData>
        <SimpleData name="COUNTYFP10">013</SimpleData>
        <SimpleData name="TRACTCE10">002800</SimpleData>
        <SimpleData name="BLOCKCE10">3066</SimpleData>
        <SimpleData name="GEOID10">190130028003066</SimpleData>
        <SimpleData name="NAME10">Block 3066</SimpleData>
        <SimpleData name="MTFCC10">G5040</SimpleData>
        <SimpleData name="UR10">R</SimpleData>
        <SimpleData name="FUNCSTAT10">S</SimpleData>
        <SimpleData name="ALAND10">2669021</SimpleData>
        <SimpleData name="AWATER10">0</SimpleData>
        <SimpleData name="INTPTLAT10">+42.3771200</SimpleData>
        <SimpleData name="INTPTLON10">-092.1523795</SimpleData>
    </SchemaData></ExtendedData>
      <Polygon><outerBoundaryIs><LinearRing><coordinates>-92.142669,42.369695 -92.152457,42.369649 -92.155691,42.369641 -92.157833,42.369636 -92.1613,42.369628 -92.162245,42.369626 -92.162143,42.376605 -92.162074,42.380176 -92.162012,42.383357 -92.162,42.383994 -92.161987,42.38463 -92.142533,42.384571 -92.142555,42.382183 -92.142614,42.376921 -92.142638,42.373725 -92.142669,42.369695</coordinates></LinearRing></outerBoundaryIs></Polygon>
  </Placemark>
  <Placemark>
    <Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
    <ExtendedData><SchemaData schemaUrl="#tl_2010_19013_tabblock10">
        <SimpleData name="STATEFP10">19</SimpleData>
        <SimpleData name="COUNTYFP10">013</SimpleData>
        <SimpleData name="TRACTCE10">002800</SimpleData>
        <SimpleData name="BLOCKCE10">3114</SimpleData>
        <SimpleData name="GEOID10">190130028003114</SimpleData>
        <SimpleData name="NAME10">Block 3114</SimpleData>
        <SimpleData name="MTFCC10">G5040</SimpleData>
        <SimpleData name="UR10">R</SimpleData>
        <SimpleData name="FUNCSTAT10">S</SimpleData>
        <SimpleData name="ALAND10">3812216</SimpleData>
        <SimpleData name="AWATER10">0</SimpleData>
        <SimpleData name="INTPTLAT10">+42.3221995</SimpleData>
        <SimpleData name="INTPTLON10">-092.1314948</SimpleData>
    </SchemaData></ExtendedData>
      <Polygon><outerBoundaryIs><LinearRing><coordinates>-92.113071,42.317871 -92.113062,42.317839 -92.113063,42.317808 -92.113075,42.317769 -92.113076,42.31773 -92.11311,42.317621 -92.113131,42.317598 -92.113131,42.317559 -92.113154,42.317536 -92.113166,42.317497 -92.113272,42.317373 -92.113339,42.31728 -92.113361,42.317218 -92.113374,42.317147 -92.113376,42.317022 -92.113355,42.316991 -92.113346,42.31696 -92.113325,42.316935 -92.113275,42.316849 -92.113159,42.316746 -92.11315,42.316718 -92.113105,42.316663 -92.113051,42.316607 -92.112996,42.316566 -92.112942,42.316517 -92.112897,42.316461 -92.11287,42.316406 -92.112863,42.316316 -92.112865,42.316248 -92.112885,42.316159 -92.112914,42.316104 -92.112952,42.31605 -92.113019,42.315968 -92.11303,42.315885 -92.113018,42.315867 -92.11579,42.316047 -92.11661,42.316018 -92.116927,42.315869 -92.117785,42.315208 -92.118495,42.314244 -92.118563,42.31403 -92.118608,42.313551 -92.118464,42.313239 -92.117058,42.312234 -92.116791,42.31199 -92.11677,42.311607 -92.117186,42.311219 -92.117344,42.311119 -92.117952,42.310486 -92.118048,42.310488 -92.118213,42.310499 -92.118289,42.310491 -92.118365,42.310463 -92.118404,42.310454 -92.118456,42.310436 -92.118532,42.310418 -92.118609,42.31039 -92.118648,42.310382 -92.118801,42.310327 -92.11884,42.310309 -92.118877,42.310299 -92.119032,42.310226 -92.119109,42.310199 -92.119145,42.310199 -92.119311,42.310161 -92.119376,42.310154 -92.119415,42.310155 -92.119452,42.310146 -92.119491,42.310146 -92.119541,42.310126 -92.11958,42.310119 -92.119619,42.3101 -92.119656,42.310092 -92.119695,42.310073 -92.120094,42.309954 -92.120161,42.309922 -92.120184,42.309897 -92.120228,42.309881 -92.120248,42.309861 -92.120388,42.309791 -92.120434,42.309783 -92.120479,42.309767 -92.120659,42.309719 -92.120693,42.309703 -92.120739,42.309695 -92.120773,42.309679 -92.120862,42.309655 -92.120898,42.309638 -92.120953,42.309631 -92.120998,42.309615 -92.121134,42.309583 -92.121224,42.309568 -92.12128,42.309552 -92.121369,42.309536 -92.121416,42.30952 -92.12146,42.309512 -92.121786,42.309482 -92.121989,42.309444 -92.122091,42.30942 -92.122169,42.309396 -92.122216,42.309388 -92.122249,42.309371 -92.122294,42.309364 -92.122327,42.309348 -92.122374,42.30934 -92.122418,42.309341 -92.122463,42.309333 -92.122507,42.309342 -92.122553,42.309359 -92.122641,42.309376 -92.122831,42.309396 -92.122877,42.309413 -92.122921,42.309421 -92.122954,42.309438 -92.122976,42.309464 -92.123121,42.309498 -92.123365,42.309475 -92.12341,42.309465 -92.123438,42.309444 -92.123511,42.309402 -92.123571,42.30936 -92.123672,42.309308 -92.123847,42.309267 -92.124121,42.30927 -92.124164,42.309249 -92.124338,42.309209 -92.124439,42.309178 -92.124526,42.309157 -92.124786,42.309117 -92.124845,42.309118 -92.124888,42.309108 -92.12493,42.309109 -92.125075,42.3091 -92.125161,42.309101 -92.125278,42.309113 -92.125421,42.309146 -92.125463,42.309169 -92.125506,42.309169 -92.125693,42.309214 -92.125793,42.309226 -92.125936,42.30926 -92.125994,42.30926 -92.126137,42.309284 -92.126181,42.309295 -92.126368,42.309297 -92.126455,42.309309 -92.126512,42.30931 -92.126541,42.309331 -92.126583,42.309343 -92.126625,42.309365 -92.126684,42.309376 -92.126756,42.309398 -92.126827,42.309432 -92.12687,42.309432 -92.126912,42.309443 -92.127056,42.309445 -92.127173,42.309436 -92.12726,42.309437 -92.127317,42.309459 -92.127359,42.309459 -92.127403,42.30947 -92.127705,42.309474 -92.127762,42.309485 -92.127834,42.309486 -92.127878,42.309498 -92.12795,42.309509 -92.128036,42.309531 -92.128078,42.309554 -92.12812,42.309564 -92.128192,42.309598 -92.128512,42.309687 -92.128694,42.309732 -92.128822,42.309777 -92.128995,42.309811 -92.129309,42.30989 -92.129353,42.309911 -92.12941,42.309923 -92.129482,42.309955 -92.129524,42.309967 -92.129647,42.310029 -92.129725,42.310076 -92.129781,42.31012 -92.129923,42.31025 -92.130007,42.310391 -92.130034,42.310422 -92.130048,42.310455 -92.130103,42.310552 -92.130117,42.310585 -92.130146,42.310617 -92.130187,42.310682 -92.130214,42.310714 -92.13027,42.310843 -92.130325,42.310941 -92.130353,42.310962 -92.130396,42.311005 -92.130437,42.31107 -92.130465,42.311134 -92.130492,42.311167 -92.130535,42.311243 -92.130561,42.311318 -92.130561,42.31135 -92.130574,42.311393 -92.13057,42.311618 -92.130606,42.311723 -92.130623,42.311778 -92.130592,42.31186 -92.130591,42.311902 -92.130601,42.311935 -92.130599,42.312059 -92.130609,42.312092 -92.130608,42.312125 -92.130619,42.312158 -92.130618,42.312191 -92.130639,42.312224 -92.13065,42.312258 -92.130671,42.312283 -92.130682,42.312316 -92.130703,42.312341 -92.130735,42.312416 -92.13078,42.312482 -92.130845,42.312565 -92.130909,42.312657 -92.13092,42.31269 -92.130941,42.312724 -92.130951,42.312757 -92.130973,42.312782 -92.131027,42.312865 -92.131103,42.312949 -92.131167,42.313032 -92.131178,42.313065 -92.131221,42.313115 -92.131286,42.313174 -92.13133,42.3132 -92.131352,42.313225 -92.131385,42.313241 -92.131441,42.313292 -92.131484,42.313325 -92.131506,42.313351 -92.131572,42.313393 -92.131648,42.313459 -92.131832,42.313668 -92.131962,42.313794 -92.131995,42.313819 -92.132105,42.313961 -92.132137,42.313986 -92.132159,42.314011 -92.132203,42.314028 -92.132225,42.314053 -92.132245,42.314144 -92.132243,42.31421 -92.132253,42.314277 -92.132252,42.31431 -92.132326,42.314423 -92.132358,42.3144 -92.132411,42.314424 -92.132461,42.314478 -92.132481,42.314518 -92.13248,42.314549 -92.132491,42.31458 -92.13249,42.314611 -92.13253,42.314743 -92.132579,42.314829 -92.132641,42.314908 -92.132671,42.314963 -92.13271,42.315017 -92.132751,42.315103 -92.132761,42.315135 -92.132761,42.315165 -92.132749,42.315196 -92.132767,42.31529 -92.132788,42.315352 -92.132787,42.315408 -92.132786,42.315461 -92.132774,42.315491 -92.132771,42.315624 -92.132759,42.315655 -92.132738,42.315678 -92.132727,42.315708 -92.132726,42.315739 -92.132716,42.315771 -92.132715,42.315802 -92.132703,42.31584 -92.132703,42.315871 -92.132691,42.315902 -92.132649,42.315948 -92.132617,42.316002 -92.132605,42.316033 -92.132615,42.316065 -92.132615,42.316095 -92.132623,42.316126 -92.132737,42.316268 -92.132768,42.316291 -92.132767,42.316322 -92.132782,42.316339 -92.132817,42.3164 -92.132837,42.316424 -92.132847,42.316455 -92.132867,42.316487 -92.132877,42.316518 -92.132897,42.316541 -92.132908,42.316572 -92.132907,42.316603 -92.132937,42.316658 -92.132946,42.316689 -92.132987,42.316737 -92.133007,42.316775 -92.133079,42.316846 -92.133109,42.316901 -92.13316,42.316956 -92.133222,42.317011 -92.133241,42.317035 -92.133377,42.31709 -92.133408,42.317107 -92.133428,42.31713 -92.133423,42.317355 -92.133441,42.317448 -92.133462,42.317511 -92.133482,42.31755 -92.133492,42.317581 -92.133522,42.317636 -92.133531,42.317667 -92.133561,42.317722 -92.133601,42.317847 -92.133621,42.317878 -92.13362,42.317908 -92.133608,42.317939 -92.133767,42.317866 -92.133763,42.318028 -92.133781,42.318153 -92.133803,42.31818 -92.133814,42.318242 -92.13384,42.318305 -92.133874,42.318362 -92.133896,42.318389 -92.133931,42.3184 -92.133958,42.318426 -92.133972,42.318453 -92.133972,42.318484 -92.133997,42.318578 -92.13401,42.318604 -92.134037,42.31863 -92.134051,42.318662 -92.134071,42.318689 -92.134105,42.318704 -92.134127,42.31873 -92.134173,42.318851 -92.134206,42.318909 -92.134243,42.318955 -92.134288,42.318998 -92.134474,42.319199 -92.134488,42.31923 -92.134517,42.319268 -92.13459,42.319388 -92.134617,42.319414 -92.134658,42.319498 -92.134693,42.319555 -92.134779,42.319708 -92.13482,42.319766 -92.134827,42.319797 -92.134853,42.31985 -92.134939,42.319979 -92.135015,42.320056 -92.135068,42.320096 -92.135086,42.32013 -92.135085,42.320163 -92.1351,42.320223 -92.135126,42.320255 -92.135146,42.32027 -92.135162,42.320297 -92.135258,42.320397 -92.135355,42.320484 -92.13539,42.320509 -92.135487,42.320559 -92.13554,42.320607 -92.135583,42.320653 -92.135601,42.32068 -92.135671,42.320754 -92.135687,42.320781 -92.135715,42.320801 -92.135731,42.320828 -92.135907,42.320976 -92.13604,42.321083 -92.136153,42.321124 -92.136171,42.321158 -92.13618,42.321191 -92.136179,42.321225 -92.136221,42.321311 -92.136239,42.321338 -92.136292,42.321379 -92.136502,42.321587 -92.136527,42.321607 -92.136599,42.321635 -92.136634,42.321655 -92.136652,42.321681 -92.136676,42.321748 -92.136708,42.321798 -92.136764,42.321856 -92.13678,42.321883 -92.136913,42.32199 -92.136931,42.322017 -92.137009,42.322084 -92.137071,42.322118 -92.137106,42.322145 -92.137124,42.322172 -92.137132,42.322205 -92.137148,42.322238 -92.137184,42.322265 -92.137298,42.322393 -92.137376,42.322461 -92.137411,42.322474 -92.137579,42.322575 -92.137694,42.322656 -92.13777,42.322689 -92.137834,42.322731 -92.137862,42.322758 -92.137896,42.322778 -92.13795,42.322786 -92.138012,42.322826 -92.138142,42.322934 -92.138179,42.322948 -92.138205,42.322968 -92.138241,42.322981 -92.138286,42.322989 -92.138364,42.323016 -92.138445,42.32305 -92.138542,42.323111 -92.138711,42.323153 -92.138814,42.323156 -92.138901,42.323168 -92.138973,42.323184 -92.139044,42.323207 -92.139085,42.323225 -92.139116,42.32324 -92.139197,42.323268 -92.139232,42.323274 -92.13934,42.323318 -92.139745,42.323393 -92.139867,42.3234 -92.14007,42.323429 -92.140156,42.323436 -92.140265,42.323437 -92.140345,42.323448 -92.140431,42.323466 -92.14051,42.323499 -92.140618,42.323538 -92.140749,42.323551 -92.140966,42.323607 -92.141261,42.323664 -92.141349,42.323676 -92.141384,42.323687 -92.141449,42.323699 -92.14158,42.323711 -92.141885,42.323715 -92.141994,42.323721 -92.142189,42.323756 -92.142318,42.323768 -92.142427,42.323797 -92.142624,42.323828 -92.142713,42.323823 -92.142963,42.323886 -92.143149,42.323913 -92.143237,42.323932 -92.143318,42.323957 -92.143399,42.323988 -92.14343,42.324006 -92.143487,42.324025 -92.143518,42.324043 -92.143558,42.324055 -92.143663,42.324111 -92.143688,42.324132 -92.143719,42.32416 -92.143886,42.324282 -92.143919,42.324313 -92.143983,42.324356 -92.144047,42.324393 -92.144078,42.324417 -92.144336,42.324505 -92.1444,42.324542 -92.14454,42.324654 -92.144716,42.324894 -92.144772,42.324955 -92.144836,42.324998 -92.144995,42.32509 -92.145156,42.325164 -92.145237,42.325195 -92.145476,42.32533 -92.145596,42.325422 -92.1457,42.325484 -92.145781,42.325527 -92.145933,42.325589 -92.146046,42.325645 -92.146069,42.325705 -92.146068,42.325735 -92.146092,42.32576 -92.146132,42.325778 -92.146227,42.325845 -92.1463,42.325882 -92.146372,42.325913 -92.146404,42.325938 -92.146605,42.326048 -92.146684,42.326073 -92.146725,42.326092 -92.146765,42.326105 -92.146798,42.326123 -92.14687,42.326148 -92.146958,42.326167 -92.147048,42.326168 -92.147145,42.326163 -92.147226,42.326164 -92.147267,42.326171 -92.147339,42.326236 -92.147513,42.326303 -92.147777,42.326429 -92.147821,42.326446 -92.147865,42.326447 -92.14791,42.326456 -92.147954,42.326456 -92.147998,42.326465 -92.148108,42.326507 -92.148141,42.326524 -92.148163,42.32655 -92.14836,42.326659 -92.148404,42.32666 -92.148449,42.326652 -92.148493,42.326653 -92.148526,42.32667 -92.148569,42.326761 -92.148579,42.326794 -92.148601,42.326819 -92.148744,42.326845 -92.148789,42.326846 -92.148833,42.326854 -92.148877,42.326871 -92.148921,42.32688 -92.148952,42.326897 -92.149028,42.326964 -92.14905,42.326989 -92.149049,42.327022 -92.149126,42.327088 -92.149159,42.327105 -92.149203,42.327114 -92.149236,42.327131 -92.149379,42.327174 -92.149479,42.327191 -92.149655,42.327235 -92.149699,42.327252 -92.149754,42.32726 -92.14981,42.327261 -92.149895,42.32727 -92.150087,42.327273 -92.150287,42.327259 -92.150332,42.327251 -92.150398,42.327252 -92.150831,42.327224 -92.151164,42.327228 -92.151253,42.327237 -92.151297,42.327246 -92.151341,42.327246 -92.151386,42.327255 -92.15143,42.327256 -92.151485,42.327264 -92.151629,42.327274 -92.151817,42.327293 -92.152139,42.327297 -92.152228,42.32729 -92.152361,42.3273 -92.15245,42.327301 -92.152638,42.327319 -92.152859,42.327363 -92.152992,42.327373 -92.153136,42.327375 -92.153313,42.32741 -92.15339,42.327443 -92.153479,42.327492 -92.153516,42.32751 -92.153551,42.327519 -92.153586,42.327537 -92.153634,42.327538 -92.153669,42.327556 -92.153717,42.327556 -92.15386,42.327594 -92.154001,42.327666 -92.154035,42.327693 -92.154142,42.327738 -92.154178,42.327748 -92.154213,42.327766 -92.154261,42.327802 -92.154332,42.327838 -92.154401,42.327884 -92.154438,42.327902 -92.154543,42.327983 -92.15466,42.328046 -92.154719,42.328091 -92.154765,42.328144 -92.154883,42.328252 -92.154905,42.328279 -92.154941,42.328306 -92.154975,42.32836 -92.154999,42.328387 -92.155056,42.328502 -92.155079,42.328529 -92.155091,42.328556 -92.155126,42.328591 -92.155136,42.328618 -92.15537,42.328834 -92.155499,42.328959 -92.155557,42.329022 -92.155675,42.329129 -92.15578,42.32921 -92.155814,42.329246 -92.155851,42.329273 -92.155909,42.329336 -92.155979,42.329399 -92.156049,42.329452 -92.156143,42.329533 -92.156154,42.32956 -92.15619,42.329578 -92.156236,42.329614 -92.156319,42.329695 -92.156377,42.329739 -92.156517,42.329874 -92.156529,42.329901 -92.156553,42.329927 -92.15661,42.330017 -92.15662,42.330044 -92.156644,42.330071 -92.156656,42.330097 -92.156678,42.330124 -92.15669,42.330151 -92.156714,42.330178 -92.156724,42.330204 -92.156748,42.330231 -92.15676,42.330258 -92.156782,42.330284 -92.156794,42.33032 -92.156817,42.330347 -92.156885,42.330463 -92.156931,42.330578 -92.15693,42.330614 -92.156942,42.330641 -92.156925,42.331428 -92.156935,42.331491 -92.156948,42.331517 -92.156971,42.331544 -92.157029,42.331589 -92.157167,42.331719 -92.157196,42.331749 -92.157216,42.331779 -92.157245,42.331808 -92.157384,42.332037 -92.157427,42.332083 -92.157525,42.332202 -92.157543,42.332232 -92.157631,42.332314 -92.15767,42.332329 -92.157817,42.332441 -92.157875,42.332494 -92.157893,42.332524 -92.158078,42.332695 -92.158147,42.332748 -92.158186,42.33277 -92.158226,42.332785 -92.158255,42.332808 -92.158334,42.332838 -92.158413,42.332876 -92.15853,42.332944 -92.158764,42.333123 -92.158803,42.333146 -92.158843,42.333176 -92.158872,42.333206 -92.159127,42.333386 -92.159322,42.333506 -92.159351,42.333535 -92.159517,42.333648 -92.159636,42.333715 -92.159665,42.333745 -92.159703,42.333761 -92.159831,42.333858 -92.159869,42.333873 -92.159929,42.333918 -92.160084,42.334008 -92.160203,42.334069 -92.160262,42.334113 -92.160379,42.334181 -92.160526,42.334293 -92.160564,42.334316 -92.160593,42.334339 -92.160683,42.334384 -92.160898,42.334519 -92.160937,42.334534 -92.160966,42.334556 -92.161006,42.334572 -92.161134,42.334662 -92.161192,42.334714 -92.161259,42.334766 -92.1613,42.334789 -92.161329,42.334819 -92.161436,42.334879 -92.161495,42.334924 -92.161612,42.334991 -92.161672,42.335037 -92.161701,42.335067 -92.161866,42.335179 -92.161984,42.335224 -92.162063,42.335247 -92.162103,42.335255 -92.162142,42.33527 -92.162171,42.335293 -92.162181,42.335323 -92.16229,42.335371 -92.162641,42.335563 -92.162712,42.335609 -92.16294,42.335729 -92.163049,42.335775 -92.16312,42.335812 -92.163168,42.33583 -92.163204,42.335849 -92.163241,42.335859 -92.163386,42.335923 -92.163477,42.33597 -92.163664,42.336113 -92.162248,42.33718 -92.160963,42.338149 -92.160811,42.338256 -92.160649,42.338354 -92.160479,42.338444 -92.1603,42.338525 -92.159617,42.338751 -92.157873,42.338913 -92.157549,42.338938 -92.157224,42.338952 -92.156973,42.338955 -92.153683,42.338952 -92.15334,42.338956 -92.152975,42.338972 -92.15261,42.338998 -92.15246,42.339014 -92.152456,42.338671 -92.152451,42.3383 -92.152444,42.33768 -92.152391,42.333372 -92.152351,42.330106 -92.152336,42.329948 -92.152307,42.329791 -92.152263,42.329636 -92.152204,42.329484 -92.152177,42.329427 -92.152132,42.329334 -92.152046,42.329189 -92.151946,42.329049 -92.151834,42.328914 -92.15171,42.328785 -92.151573,42.328663 -92.151426,42.328548 -92.151268,42.328441 -92.151056,42.328318 -92.150925,42.328253 -92.150741,42.328173 -92.15055,42.328102 -92.150352,42.328041 -92.15015,42.32799 -92.148237,42.327567 -92.148234,42.327143 -92.148109,42.32692 -92.147736,42.326676 -92.146558,42.326399 -92.146248,42.326404 -92.145876,42.326689 -92.145749,42.327016 -92.143211,42.326454 -92.142271,42.326242 -92.137763,42.326234 -92.132934,42.326185 -92.123152,42.326184 -92.114017,42.326235 -92.114035,42.326125 -92.113982,42.325989 -92.113952,42.325928 -92.113911,42.32586 -92.113841,42.325781 -92.113759,42.325732 -92.113728,42.325707 -92.1136,42.325566 -92.113584,42.325535 -92.11356,42.32551 -92.113529,42.325419 -92.113531,42.325322 -92.113544,42.325153 -92.113552,42.325122 -92.113555,42.324989 -92.113549,42.32494 -92.113568,42.324844 -92.113568,42.324813 -92.113636,42.324662 -92.113674,42.324468 -92.113684,42.324372 -92.113686,42.324244 -92.113695,42.324208 -92.113695,42.324171 -92.11375,42.32396 -92.113751,42.323911 -92.113744,42.323881 -92.113745,42.323839 -92.113737,42.323808 -92.113737,42.323777 -92.113668,42.323638 -92.113627,42.323587 -92.113611,42.323556 -92.113604,42.323525 -92.113624,42.323368 -92.113651,42.323269 -92.113678,42.323213 -92.113697,42.323113 -92.113698,42.323043 -92.113676,42.322975 -92.113642,42.322911 -92.113626,42.322868 -92.113562,42.322741 -92.113538,42.322672 -92.113485,42.322414 -92.113487,42.322283 -92.113472,42.322226 -92.113456,42.322201 -92.113457,42.322132 -92.113435,42.321957 -92.113437,42.321888 -92.113448,42.321813 -92.113466,42.321744 -92.113475,42.321675 -92.113485,42.321638 -92.113502,42.321613 -92.113503,42.321582 -92.11353,42.321513 -92.11355,42.321376 -92.113552,42.321269 -92.113522,42.321131 -92.113466,42.320974 -92.11339,42.320682 -92.113339,42.320556 -92.113319,42.320532 -92.113269,42.320445 -92.113238,42.320422 -92.113206,42.320366 -92.113186,42.320343 -92.113167,42.320296 -92.113137,42.320241 -92.113116,42.320162 -92.11311,42.320045 -92.1131,42.319997 -92.113101,42.319959 -92.11309,42.319927 -92.113096,42.319646 -92.113108,42.319615 -92.113109,42.319576 -92.113121,42.319545 -92.113125,42.319364 -92.113115,42.319325 -92.113115,42.319294 -92.113085,42.319232 -92.113044,42.319169 -92.113014,42.319113 -92.112869,42.318994 -92.112775,42.31897 -92.112714,42.318883 -92.112703,42.318852 -92.112684,42.31882 -92.112706,42.31875 -92.112727,42.318719 -92.112856,42.318635 -92.112921,42.318549 -92.112933,42.318518 -92.112933,42.318487 -92.112943,42.318456 -92.112945,42.318393 -92.112957,42.31833 -92.112958,42.3183 -92.11297,42.318268 -92.113023,42.318191 -92.113112,42.318107 -92.11312,42.318083 -92.113102,42.317988 -92.113071,42.317871</coordinates></LinearRing></outerBoundaryIs></Polygon>
  </Placemark>
</Folder>
</Document></kml>

并创建一个仅包含此列表中的GEOID10的地标的新文件(eligible.txt):

190130028003089
190130028003087
190130028003086
190130028003085
190130028003084
190130028003082
190130028003057
190130028003044
190130028003043
190130028003042
190130028003041
190130028003031
190130028003030
190130028003028
190130028003027
190130028003023
190130028003022
190130028003021
190130028003020
190130028003018
190130028003016
190130028003009
190130028003003
190130028003001
190130028001119
190130028001118
190130028001103
190130028001095

这是我的黑客尝试,非常感谢James Brown启发了我阅读awk。

./ bensawk <合格.txt

#!/ bin / bash     边读边;做      awk -v p =“ $ line”'     // {d = 1; b =“”; }#d是删除,b是缓冲区,将两者重置     {b = b $ 0(/ /?“”:ORS)}#将数据收集到d     / p / {d = 0}#如果匹配集d = 0     / / && d = 0 {print b}#如果行与print b匹配     'sample.kml >>出来     完成

1 个答案:

答案 0 :(得分:0)

您可能要使用XML感知工具来完成此任务。与xmllint

$ echo 'cat //*[local-name()="SimpleData"][@*[local-name()="name" and .="GEOID10"]]/text()' | 
  xmllint --shell file.xml | 
  sed -n '2~2p'

190130027002051
190130028003066
190130028003114