Re: [GRASS-user] db.out.ogr: not exporting rows

2019-02-27 Thread Micha Silver

  
  

On 27/02/2019 15:55, Rich Shepard
  wrote:

On
  Wed, 27 Feb 2019, Micha Silver wrote:
  
  
  I should add to my previous message that
if you specify 'dbf' format the

script will delete all other components of an existing shapefile
(by the

same name).

  
  
  Micha,
  
  
  Wait. Why does db.out.ogr allow the output file to be another
  database? How
  
  often would someone want to do this?
  
  
  Related question: the format option is required, but to the input
  or output?
  
  Look at the first example. It has an input and output but no
  format.
  



Your input would be an existing GRASS vector. But it could be any
  other OGR accessible data table, I suppose.
The default output format is CSV, if you don't specify anything
  else. But it could be several others: DBF, GML, MySQL, PostgreSQL,
  SQLite.



  
  I've not before used db.out.ogr so you've taught ma a lot.
  
  
  Best regards,
  
  
  Rich
  
  ___
  
  grass-user mailing list
  
  grass-user@lists.osgeo.org
  
  https://lists.osgeo.org/mailman/listinfo/grass-user

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
  

___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] db.out.ogr: not exporting rows

2019-02-27 Thread Rich Shepard

On Wed, 27 Feb 2019, Micha Silver wrote:


I should add to my previous message that if you specify 'dbf' format the
script will delete all other components of an existing shapefile (by the
same name).


Micha,

Wait. Why does db.out.ogr allow the output file to be another database? How
often would someone want to do this?

Related question: the format option is required, but to the input or output?
Look at the first example. It has an input and output but no format.

I've not before used db.out.ogr so you've taught ma a lot.

Best regards,

Rich
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] db.out.ogr: not exporting rows

2019-02-27 Thread Rich Shepard

On Wed, 27 Feb 2019, Micha Silver wrote:


Looking at the source code for db.out.ogr, I see that this module has a
somewhat strange approach to checking for the overwrite flag. There is a
test for existence of a file with the same name as the GRASS *input*
layer, but with .dbf extension. If such a file exists, the module fails,
as you saw. 


Micha,

Wow! It would never have occurred to me that --o was needed! Because
v.out.ogr is supposed to have a .dbf for input (as the default), and the
output was specified as .csv there could not be any overwritten file.
Besides, the purpose of the module is to _export_ rows from the database
file, not overwrite the table.

From your detailed look at the source code I suggest a clean up that would
prevent the output file having the same extension as the input file (despite
that making no sense at all) and letting the rest work as expected.


In your case, you could get around the issue by simply adding the
overwrite flag to your command. Since you're saving to a *.csv, there's no
danger of overwriting any existing dbf.


Yes, I'll do this. Thanks very much for taking the time to find this quirk.

Best regards,

Rich
___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] db.out.ogr: not exporting rows

2019-02-27 Thread Micha Silver

  
  

On 26/02/2019 23:37, Rich Shepard
  wrote:

Current
  map displayed is Pit_Lakes@pit_lakes. I want to export the 42 rows
  
  in the table and followed the example on the manual page:
  
  
  GRASS 7.7.svn:~/data/grassdata/Nevada/BMRR > db.out.ogr
  in=Pit_Lakes
  
  out=pit_lakes.csv
  
  ERROR: File  already exists
  

Rich:
I should add to my previous message that if you specify 'dbf'
  format the script will delete all other components of an existing
  shapefile (by the same name).

  


  
  I am not seeing what error I made and would appreciate being shown
  what I've
  
  done incorrectly.
  
  
  TIA,
  
  
  Rich
  
  ___
  
  grass-user mailing list
  
  grass-user@lists.osgeo.org
  
  https://lists.osgeo.org/mailman/listinfo/grass-user

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
  

___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] db.out.ogr: not exporting rows

2019-02-27 Thread Micha Silver

  
  

On 26/02/2019 23:37, Rich Shepard
  wrote:

Current
  map displayed is Pit_Lakes@pit_lakes. I want to export the 42 rows
  
  in the table and followed the example on the manual page:
  
  
  GRASS 7.7.svn:~/data/grassdata/Nevada/BMRR > db.out.ogr
  in=Pit_Lakes
  
  out=pit_lakes.csv
  
  ERROR: File  already exists
  
  
  I am not seeing what error I made and would appreciate being shown
  what I've
  
  done incorrectly.
  



Looking at the source code for db.out.ogr, I see that this module
  has a somewhat strange approach to checking for the overwrite
  flag. There is a test for existence of a file with the same name
  as the GRASS *input* layer, but with .dbf extension. If such a
  file exists, the module fails, as you saw.  I can only guess that
  this unusual test was implemented to avoid overwriting the *.dbf
  component of a shapefile. That is, when saving an attribute table
  to a dbf file, if there was a shapefile with the same name, then
  it's dbf component would get changed, corrupting the whole
  shapefile. I think this could be done more simply. (I'll suggest a
  PR)


In your case, you could get around the issue by simply adding the
  overwrite flag to your command. Since you're saving to a *.csv,
  there's no danger of overwriting any existing dbf.


 
Regards,
Micha

 


  
  TIA,
  
  
  Rich
  
  ___
  
  grass-user mailing list
  
  grass-user@lists.osgeo.org
  
  https://lists.osgeo.org/mailman/listinfo/grass-user

-- 
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
  

___
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user