Maybe I am just loosin' my time struggling to import KML polygons in GRASS but here is my attempt and my problems. I have read past threads but I didn't really found the "SOLUTION"
I understand that it should be easy to play with xpath and xslt but since KML's are XML's but, again, I have no idea about xpath and xslt and I try do it the way I "know" more or less... ;-p If there is already a solution... I would be more than greatful since I am in the last phase of my current work. Here is my attempt to import coordinates the "hard way": --- 1. Decompress KMZ and get the "KML" # I was told, and I read, that KML are just XML's. So... 2. Replacing the KMLheader <kml xmlns="http://earth.google.com/kml/2.2"> with <?xml-stylesheet type="text/xsl" href="kml2html.xsl" ?> <kml> 3. Saving the KML file in the same folder with an .xsl (in my case kml2html.xsl given by a friend --- file attached) 4. Open with a browser and either (a) "copy-paste" the coordinates for which I am interested or (b) "save as" txt file. 5. I choose (a) for my first attempt and save some coordinates in a txt file and try to import them "sacrificing" the meta-data. ["example.xyz" with coordinates attached.] The problem is that the coordinates are given in form of x,y,z but continuously... that is one "x,y,z" field after another separated by "space" and not in separate lines! It looks like this: x1,y1,z1 x2,y2,z2 x3,y3,z3 [...] xi,yi,zi and NOT like this: x1,y1,z1 x2,y2,z x3,y3,z3 [...] xi,yi,zi 6. I have studied v.out.ascii (since it is the reverse of v.in.ascii) and I came up with this bash loop which WORKS in the command line. I can import the desired coordinates in GRASS and I think it should be easy to "clean" and convert in areas. ["example.grass-ready.xyz" attached] The problem is that my "solution" DOES NOT work in a script due to an error in "cut -d ' ' -f$i #### How can I use in -f a variable (stepwise increasing number) instead of a constant number? INPUT=example.xyz OUTPUT= just a name TYPE=B ### "B" for "boundaries" ...or "L" for lines better? i=0 PRIMITIVES="`cat $INPUT | wc -w`" echo "$TYPE $PRIMITIVES" > $OUTPUT.grass-ready; cat $OUTPUT.grass-ready | echo "\nVERTI:">> $OUTPUT.grass-ready until [ $i -gt $PRIMITIVES ]; do cat $INPUT | cut -d' ' -f$i | tr ',' ' ' >> $OUTPUT.grass-ready; let i=i+1; done ### Note in tr ',' ' ' -- second character is a space 7. If this is going to work I was thinking to "grep" somehow the metadata out of the "saved as txt file" and force it with a script in the X.grass-ready ascii ... Some more questions: * ogr officially supports "KML" reading and writing. I can't read with ogrinfo any KML file. I have read about "expat" support... but isn't this activated by default in ogr coming with FWTools? Sorry for the QGIS question: * QGIS suppports GML reading?
kml2html.xsl
Description: XML document
22.78329984000001,37.77047369000001,0 22.78279034,37.76997424,0 22.78314504,37.769356,0 22.7832187,37.76861147,0 22.78363257,37.76853913,0 22.78367179,37.76828878,0 22.78325918,37.76828452,0 22.7835377,37.76686349,0 22.78394129,37.76688158,0 22.78400628,37.76666633,0 22.78380106,37.76632988,0 22.78419918,37.76614593,0 22.7837289,37.76591122,0 22.78398736,37.76567707,0 22.78446801,37.76581437,0 22.78472846,37.76600655,0 22.78505692,37.7668597,0 22.78505951,37.76732862,0 22.78548957,37.76787634,0 22.78617047,37.76919283,0 22.78636019,37.76940374,0 22.78688837,37.76916495,0 22.78585283,37.76764005,0 22.78546701,37.76707189,0 22.78541854,37.76627735,0 22.78543507,37.76580388,0 22.78558948,37.76552027,0 22.78604032000001,37.76646619,0 22.78669358,37.76625003,0 22.78681418,37.76641924000001,0 22.78679287,37.76664887,0 22.78645677,37.76679865,0 22.78696414,37.76745164,0 22.78639587,37.76755086,0 22.78636330000001,37.76800227,0 22.78768309,37.76886675,0 22.79185788,37.77002782,0 22.7937064,37.77092669,0 22.79376121,37.77086745,0 22.79357996,37.77075454,0 22.79428099,37.7708146,0 22.79483149,37.77140115000001,0 22.79518683,37.77140479,0 22.79529283,37.77219336000001,0 22.79546457,37.77222928,0 22.79557456,37.77275153,0 22.79598597,37.77261905,0 22.79606149,37.77203564,0 22.79631123,37.77191004,0 22.79653722,37.7719209,0 22.79625164000001,37.77093553,0 22.79579403,37.77059768,0 22.79470736,37.76986896,0 22.79513118,37.76963409,0 22.79586182,37.77040188000001,0 22.79614455,37.77023391,0 22.79648345,37.77058764,0 22.7969449,37.77130557,0 22.79682754,37.77190238,0 22.79611252000001,37.77282626,0 22.79591522,37.77365492,0 22.79588246,37.77434657,0 22.79605351,37.7744252,0 22.79612757,37.77517339,0 22.79672223,37.77620846000001,0 22.79684763,37.77651587,0 22.79699712,37.77688231,0 22.7969088,37.77725957000001,0 22.79648687,37.77793334,0 22.7959503,37.77857986,0 22.79595207,37.77878551,0 22.79031159,37.77898882,0 22.78773325,37.77618445,0 22.78518441,37.77302938,0 22.78496352,37.77275594000001,0 22.78486508,37.77262753,0 22.78446917,37.77259892,0 22.78446068,37.77248046,0 22.78467841000001,37.77238877000001,0 22.78462792,37.77232702,0 22.78450944,37.77234206,0 22.78442884,37.77191663,0 22.78428756,37.77117099,0 22.78465364,37.77103552,0 22.78455814000001,37.77089564,0 22.78417573000001,37.77098563,0 22.78403708,37.77095976,0 22.78336184000001,37.77118153,0 22.78316601,37.77148947,0 22.78291123,37.77150133,0 22.7825273,37.77156890000001,0 22.78220470000001,37.77129159,0 22.78252004,37.77090553,0 22.78265236,37.77115199,0 22.78287853,37.7712192,0 22.78307933,37.77060845,0 22.78325132,37.7706607,0
VERTI: B 97 22.78329984000001 37.77047369000001 0 22.78279034 37.76997424 0 22.78314504 37.769356 0 22.7832187 37.76861147 0 22.78363257 37.76853913 0 22.78367179 37.76828878 0 22.78325918 37.76828452 0 22.7835377 37.76686349 0 22.78394129 37.76688158 0 22.78400628 37.76666633 0 22.78380106 37.76632988 0 22.78419918 37.76614593 0 22.7837289 37.76591122 0 22.78398736 37.76567707 0 22.78446801 37.76581437 0 22.78472846 37.76600655 0 22.78505692 37.7668597 0 22.78505951 37.76732862 0 22.78548957 37.76787634 0 22.78617047 37.76919283 0 22.78636019 37.76940374 0 22.78688837 37.76916495 0 22.78585283 37.76764005 0 22.78546701 37.76707189 0 22.78541854 37.76627735 0 22.78543507 37.76580388 0 22.78558948 37.76552027 0 22.78604032000001 37.76646619 0 22.78669358 37.76625003 0 22.78681418 37.76641924000001 0 22.78679287 37.76664887 0 22.78645677 37.76679865 0 22.78696414 37.76745164 0 22.78639587 37.76755086 0 22.78636330000001 37.76800227 0 22.78768309 37.76886675 0 22.79185788 37.77002782 0 22.7937064 37.77092669 0 22.79376121 37.77086745 0 22.79357996 37.77075454 0 22.79428099 37.7708146 0 22.79483149 37.77140115000001 0 22.79518683 37.77140479 0 22.79529283 37.77219336000001 0 22.79546457 37.77222928 0 22.79557456 37.77275153 0 22.79598597 37.77261905 0 22.79606149 37.77203564 0 22.79631123 37.77191004 0 22.79653722 37.7719209 0 22.79625164000001 37.77093553 0 22.79579403 37.77059768 0 22.79470736 37.76986896 0 22.79513118 37.76963409 0 22.79586182 37.77040188000001 0 22.79614455 37.77023391 0 22.79648345 37.77058764 0 22.7969449 37.77130557 0 22.79682754 37.77190238 0 22.79611252000001 37.77282626 0 22.79591522 37.77365492 0 22.79588246 37.77434657 0 22.79605351 37.7744252 0 22.79612757 37.77517339 0 22.79672223 37.77620846000001 0 22.79684763 37.77651587 0 22.79699712 37.77688231 0 22.7969088 37.77725957000001 0 22.79648687 37.77793334 0 22.7959503 37.77857986 0 22.79595207 37.77878551 0 22.79031159 37.77898882 0 22.78773325 37.77618445 0 22.78518441 37.77302938 0 22.78496352 37.77275594000001 0 22.78486508 37.77262753 0 22.78446917 37.77259892 0 22.78446068 37.77248046 0 22.78467841000001 37.77238877000001 0 22.78462792 37.77232702 0 22.78450944 37.77234206 0 22.78442884 37.77191663 0 22.78428756 37.77117099 0 22.78465364 37.77103552 0 22.78455814000001 37.77089564 0 22.78417573000001 37.77098563 0 22.78403708 37.77095976 0 22.78336184000001 37.77118153 0 22.78316601 37.77148947 0 22.78291123 37.77150133 0 22.7825273 37.77156890000001 0 22.78220470000001 37.77129159 0 22.78252004 37.77090553 0 22.78265236 37.77115199 0 22.78287853 37.7712192 0 22.78307933 37.77060845 0 22.78325132 37.7706607 0
signature.asc
Description: This is a digitally signed message part
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
