v.out.ogr - layer name

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

v.out.ogr - layer name

daniel mcinerney-2
Hi List,

When I export a vector using v.out.ogr, I'm unable to assign an output
layer name when the output format is 'ESRI_Shapefile'. For example:

v.out.ogr input=grid_clip output=grid_clip.shp output_layer=sub_grid
format='ESRI_Shapefile'

Exporting 4 areas (may take some time)...
  100%
v.out.ogr complete. 4 features (Polygon type) written to <sub_grid>

the message indicates that it has been written to sub_grid, but the
output from ogrinfo indicates that is hasn't been updated:

ogrinfo -so grid_clip.shp

INFO: Open of `grid_clip.shp'
       using driver `ESRI Shapefile' successful.
1: grid_clip (Polygon)

However, the above process works, and the correct layer name is written,
when the output format is GeoPackage or SQLite. I can update the layer
name subsequently with ogr2ogr, but it would be preferable if this could
be avoided. I'm using GRASS 7.4.0 (2018) on Ubuntu 18.04 (bionic).

Any advice appreciated.

Regards,

Daniel.

_______________________________________________
grass-user mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: v.out.ogr - layer name

Moritz Lennert
On 3/01/19 15:13, Daniel McInerney wrote:

> Hi List,
>
> When I export a vector using v.out.ogr, I'm unable to assign an output
> layer name when the output format is 'ESRI_Shapefile'. For example:
>
> v.out.ogr input=grid_clip output=grid_clip.shp output_layer=sub_grid
> format='ESRI_Shapefile'
>
> Exporting 4 areas (may take some time)...
>    100%
> v.out.ogr complete. 4 features (Polygon type) written to <sub_grid>
>
> the message indicates that it has been written to sub_grid, but the
> output from ogrinfo indicates that is hasn't been updated:
>
> ogrinfo -so grid_clip.shp
>
> INFO: Open of `grid_clip.shp'
>         using driver `ESRI Shapefile' successful.
> 1: grid_clip (Polygon)
>
> However, the above process works, and the correct layer name is written,
> when the output format is GeoPackage or SQLite. I can update the layer
> name subsequently with ogr2ogr, but it would be preferable if this could
> be avoided. I'm using GRASS 7.4.0 (2018) on Ubuntu 18.04 (bionic).
>
> Any advice appreciated.

I don't think shapefile supports the notion of layer names as each layer
is in a separate file, so file = layer, and filename = layername.

v.out.ogr could possibly be enhanced by including a warning about this
when the user tries to assigne a layer name to a shapefile.

Moritz
_______________________________________________
grass-user mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: v.out.ogr - layer name

Markus Metz-3


On Fri, Jan 4, 2019 at 4:04 PM Moritz Lennert <[hidden email]> wrote:

>
> On 3/01/19 15:13, Daniel McInerney wrote:
> > Hi List,
> >
> > When I export a vector using v.out.ogr, I'm unable to assign an output
> > layer name when the output format is 'ESRI_Shapefile'. For example:
> >
> > v.out.ogr input=grid_clip output=grid_clip.shp output_layer=sub_grid
> > format='ESRI_Shapefile'
> >
> > Exporting 4 areas (may take some time)...
> >    100%
> > v.out.ogr complete. 4 features (Polygon type) written to <sub_grid>
> >
> > the message indicates that it has been written to sub_grid, but the
> > output from ogrinfo indicates that is hasn't been updated:
> >
> > ogrinfo -so grid_clip.shp
> >
> > INFO: Open of `grid_clip.shp'
> >         using driver `ESRI Shapefile' successful.
> > 1: grid_clip (Polygon)
> >
> > However, the above process works, and the correct layer name is written,
> > when the output format is GeoPackage or SQLite. I can update the layer
> > name subsequently with ogr2ogr, but it would be preferable if this could
> > be avoided. I'm using GRASS 7.4.0 (2018) on Ubuntu 18.04 (bionic).
> >
> > Any advice appreciated.
>
> I don't think shapefile supports the notion of layer names as each layer
> is in a separate file, so file = layer, and filename = layername.

For shapefiles, the datasource name is the folder and the layer name is the name of the actual shapefile without .shp.

The output option of v.out.ogr defines the datasource name. OGR handles shapefiles a bit special, i.e. the output layer name with .shp is accepted as output datasource name where the layer name is also defined.
For example
/path/to/grid_clip.shp

the datasource name is /path/to, the layer name is grid_clip, and datasource and layer name can be set together with /path/to/grid_clip.shp. This is OGR specific, not GRASS specific.

>
> v.out.ogr could possibly be enhanced by including a warning about this
> when the user tries to assigne a layer name to a shapefile.

Assigning a layer name to an output shapefile works just fine with e.g. v.out.ogr output=/path/to output_layer=sub_grid

Markus M

>
> Moritz
> _______________________________________________
> grass-user mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/grass-user

_______________________________________________
grass-user mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-user