[Gdal-dev] Question on using ogr-perl module

wqual wolfgang.qual at gmx.net
Thu Apr 6 06:53:28 EDT 2006


Hello Ari, 
great! Thanks again for your help. For GRASS-vectorlayers, I had to write this 
for the 
'directory': /home/wqual/grassdata/spearfish60/PERMANENT/vector/archsites/head';

greetings,

Wolfgang
--8<--------------------------------------------------------------------------------------------------------
Am Mittwoch 05 April 2006 pH:01:20 nachmittags/abends schrieb Ari Jolma:
> wqual kirjoitti:
> >  Hi list, I would like to get the fieldnames of a given attribute
> >  table using the perl-module ogr. It is possible to obtain the number
> >  of layers of my dataset (with GetLayerCount, see below), but I do not
> >  succeed in using other commands like GetLayerDefn, GetFeature (see
> >  result below). Is there a simple way to get the attribute fieldnames?
> >  Any comments/ideas are most welcome!
>
> I have a dialog box in my Gtk2::Ex::Geo modules:
> http://map.hut.fi/PerlForGeoinformatics/OGROpen.png
>
> The code behind the dialog box opens a datasource (for example a
> directory or database), lists the layers, and, when asked, gives the
> schema. The code for this dialog box is here
> http://cvs.sourceforge.net/viewcvs.py/libral/Gtk2-Ex-Geo/lib/Gtk2/Ex/Geo/OG
>RDialog.pm.in?rev=1.4&view=auto
>
> The code for getting the attribute field names is this (from sub
> fill_property_and_schema_tvs):
>
> my $schema = $layer->GetLayerDefn();
>
>     my $n = $schema->GetFieldCount();
>     my %data;
>     for my $i (0..$n-1) {
> 	my $c = $schema->GetFieldDefn($i);
> 	$data{$c->GetName} = $c->GetFieldTypeName($c->GetType);
>     }
>
>
> There is also a dialog box for the attribute table:
> http://map.hut.fi/PerlForGeoinformatics/features_dialog.png
>
> The code for this dialog box is in the same file as above, see sub
> browse_features and a few subs below it. There are examples of using
> GetFeature.
>
> Ari
>
> >  Best regards, Wolfgang



More information about the Gdal-dev mailing list