[GRASS-dev] Projection-problem

Paul Kelly paul-grass at stjohnspoint.co.uk
Thu May 11 10:05:30 EDT 2006


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.

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. 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).

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?

Paul

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 */





More information about the grass-dev mailing list