[GRASS-user] How to import KML polygons in GRASS?
Nikos Alexandris
nikos.alexandris at felis.uni-freiburg.de
Sun Feb 24 10:24:08 EST 2008
WOW!
Finally... I have got working using this
http://spanring.name/blog/wp-content/files/kml2gml.xsl
from here http://www.perrygeo.net/wordpress/?p=3
which most of you must be already aware I suppose!
Cool... it works since QGIS does read GML's.
I am still interested in my "SOLUTION" (especially in the "-f" parameter
in the "cur" command).
Does ogr2ogr convert from GML to GRASS vector files?
Oh... I am trying it out right away... ;-)
On Sun, 2008-02-24 at 16:05 +0100, Nikos Alexandris wrote:
> 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?
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
--
Nikos Alexandris
.
Department of Remote Sensing & Landscape Information Systems
Faculty of Forestry & Environmental Sciences, Albert-Ludwigs-University Freiburg
.
Tel. +49 (0) 761 203 3697 / Fax. +49 (0) 761 203 3701 / Skype: Nikos.Alexandris
.
Address: Tennenbacher str. 4, D-79106 Freiburg i. Br., Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20080224/f7e041fe/attachment-0001.bin
More information about the grass-user
mailing list