[GRASS-dev] Projection-problem

Stephan Holl holl at gdf-hannover.de
Thu May 11 10:46:58 EDT 2006


Hello again Paul,

On Thu, 11 May 2006 15:05:30 +0100 (BST) Paul Kelly
<paul-grass at stjohnspoint.co.uk> wrote:

> Hello again Stephan
> 
> On Thu, 11 May 2006, Stephan Holl wrote:
> 
> > Ahhh, I found out:
> >
> > # show layers in folders
> > v.in.ogr -l dsn=/tmp layer=spear_roads out=test5
> > Data source contains 3 layers:
> > spear_roads, flst_gef, NSG_Beispie
> > ^^^          ^^^        ^^^
> > EPSG:26713 EPSG:31467 EPSG:31467
> >
> [...]
> > The first syntax fails, if the datasource (the folders the shapes
> > are in) shapefiles with different projections reside in.
> >
> > No problem, if you export heaps of spearfish-shapes, but put another
> > shape with e.g. EPSG:4326 inside and you will fail to import the
> > dataset with the second syntax.
> >
> > This seems to be a bug (if anybody can confirm of course)
> 
> Good detective work.
> I agree; I had a little look at the logic in v.in.ogr and it seems a 
> little bit confused (but of course I might be confused too!). As far
> as I can see the spatial subregion checking (used only if the
> spatial= option is used) and projection checking use the *last* layer
> found to base their checks on.

I see, so then the found reaction make sense.

> 
> The way I saw it before was that all layers in the dataset should
> have the same projection so that should be OK. But I see now from
> your example that that is not always the case. 

...especially not when you are using another database like PostGIS or
Oracle which have ususally more layers with different projections in.

> Please try the
> attached patch below (I haven't tested; I don't really use v.in.ogr)
> which should cause the projection checks to be based on the first
> layer *actually imported* (i.e. not just the first or last one found
> in the dataset).

Well, yes, this eliminates my problem. Now both synatxes work for
shapes even when a folder contains differntly projected shapefiles.

Good work!

> 
> I would be grateful if you could let me know if this works. However,
> as far as I can see, the spatial subregion code still seems to assume
> that only one layer is being imported---can anybody confirm this?

Cool, Paul. This works for me now!

Perhaps anybody can confirm this as well and commit it to CVS?

Best
	Stephan


> Index: main.c
> ===================================================================
> RCS file: /grassrepository/grass6/vector/v.in.ogr/main.c,v
> retrieving revision 1.62
> diff -u -r1.62 main.c
> --- main.c      4 Apr 2006 18:20:19 -0000       1.62
> +++ main.c      11 May 2006 14:00:11 -0000
> @@ -298,6 +298,9 @@
>              layers[i] = i;
>       }
> 
> +    /* Get first imported layer to use for extents and projection
> check */
> +    Ogr_layer = OGR_DS_GetLayer( Ogr_ds, layers[0] );
> +
>       if ( spat_opt->answer ) {
>           /* See as reference: gdal/ogr/ogr_capi_test.c */
> 



-- 
GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office      -     Mengendamm 16d      -     D-30177 Hannover
Internet: www.gdf-hannover.de      -      Email: holl at gdf-hannover.de
Phone : ++49-(0)511.39088507       -        Fax: ++49-(0)511.39088508




More information about the grass-dev mailing list