[GRASS-user] import more kml from directory

Ciao Grass users.
Probably my question is trivial, but I can not fix.
1) I want to import many files. kml (all in the same folder) and then I
would like a merge(with v.patch).
I tried to import v.in.ogr all together .... maybe I'm wrong.

2) Maybe I can do a merge of all files with ogr2ogr?

Thanks for any advice
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/import-more-kml-from-directory-tp6050317p6050317.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Gabriele wrote:

Probably my question is trivial, but I can not fix.
1) I want to import many files. kml (all in the same
folder) and then I
would like a merge(with v.patch).
I tried to import v.in.ogr all together .... maybe I'm
wrong.

I'll let others talk about new developments in v.in.ogr and
the GUI which may help with that.

but from the unix command line (or Msys command line in MS
Windows) you could do like:

- make sure filenames are SQL compliant (no dots except the.kml,
start with a letter, ..)
- run a little loop on the unix command line:

for file in *.kml ; do
   v.in.ogr dsn="$file" output=`basename $file .kml`
done

then to patch them all together:

v.patch out=merged_kml in=`g.mlist vect sep=, pattern="*"`

(refine pattern= to just your input maps as needed, or leave
that out to list all vector maps)

2) Maybe I can do a merge of all files with ogr2ogr?

perhaps
?

Hamish

Ciao Hamish and thanks.
It works.... ok :slight_smile:

But I have also tried with my small script (attached) that does not work and
I did not understand why. Maybe, if you want, you can watch it.

Thank you very much.

http://osgeo-org.1803224.n2.nabble.com/file/n6052924/v.import_kml.sh
v.import_kml.sh
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/import-more-kml-from-directory-tp6050317p6052924.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 02/22/2011 06:10 PM, Gabriele N. wrote:

Ciao Hamish and thanks.
  It works.... ok :slight_smile:

But I have also tried with my small script (attached) that does not work and
I did not understand why. Maybe, if you want, you can watch it.

Thank you very much.

http://osgeo-org.1803224.n2.nabble.com/file/n6052924/v.import_kml.sh
v.import_km

I think I can see two problems with the script:
First, the dsn= parameter should be the full kml file name, i.e. ${i} as you have set up the loop, and not the just the basename ${cartella}.
Second, I think that the layer= option is not necessary. And you surely should not set it to the output name $nome. The layer= option takes a number (i.e. the number of the layer).
HTH

--
Micha Silver
Arava Development Co. +972-52-3665918
http://surfaces.co.il

On Tue, Feb 22, 2011 at 8:52 PM, Micha Silver <micha@arava.co.il> wrote:

On 02/22/2011 06:10 PM, Gabriele N. wrote:

Ciao Hamish and thanks.
It works.... ok :slight_smile:

But I have also tried with my small script (attached) that does not work
and
I did not understand why. Maybe, if you want, you can watch it.

Thank you very much.

http://osgeo-org.1803224.n2.nabble.com/file/n6052924/v.import_kml.sh
v.import_km

I think I can see two problems with the script:
First, the dsn= parameter should be the full kml file name, i.e. ${i} as you
have set up the loop, and not the just the basename ${cartella}.
Second, I think that the layer= option is not necessary. And you surely
should not set it to the output name $nome. The layer= option takes a number
(i.e. the number of the layer).

For pretty much all other vector modules, the layer option takes a
number and refers to a GRASS vector layer number. For v.in.ogr, the
layer option is the name, not the number, of an OGR layer. OGR layer
names available in a given dsn are printed with v.in.ogr -l. BTW, one
single kml file can contain several layers.

Markus M

Ciao.
Thanks.
Now, although "crude", it works. However, I put "exit" (or exit 0 exit 1)
at the end but the script does not finish properly.

What do you say?

Thanks

http://osgeo-org.1803224.n2.nabble.com/file/n6057767/v.import_kml.sh
v.import_kml.sh
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/import-more-kml-from-directory-tp6050317p6057767.html
Sent from the Grass - Users mailing list archive at Nabble.com.

On 23/02/2011 07:19, Markus Metz wrote:

On Tue, Feb 22, 2011 at 8:52 PM, Micha Silver<micha@arava.co.il> wrote:

On 02/22/2011 06:10 PM, Gabriele N. wrote:

Ciao Hamish and thanks.
  It works.... ok :slight_smile:

But I have also tried with my small script (attached) that does not work
and
I did not understand why. Maybe, if you want, you can watch it.

Thank you very much.

http://osgeo-org.1803224.n2.nabble.com/file/n6052924/v.import_kml.sh
v.import_km

I think I can see two problems with the script:
First, the dsn= parameter should be the full kml file name, i.e. ${i} as you
have set up the loop, and not the just the basename ${cartella}.
Second, I think that the layer= option is not necessary. And you surely
should not set it to the output name $nome. The layer= option takes a number
(i.e. the number of the layer).

For pretty much all other vector modules, the layer option takes a
number and refers to a GRASS vector layer number. For v.in.ogr, the
layer option is the name, not the number, of an OGR layer. OGR layer
names available in a given dsn are printed with v.in.ogr -l. BTW, one
single kml file can contain several layers.

Ooops, sorry for misleading, and thanks, Markus, for catching that.

(BTW, will the term "layer" be changing its meaning in GRASS 7?? There was much discussion on this some time ago, and alternative names were suggested for the database connection concept that "layer" was meant to refer to)

Markus M

This mail was received via Mail-SeCure System.

--
Micha Silver
http://www.surfaces.co.il/
Arava Development Co. +972-52-3665918