[GRASS-user] v.out.ogr and Date fields

Markus Neteler neteler at osgeo.org
Wed Nov 6 06:00:49 PST 2019


Hi Daniel,

On Mon, Nov 4, 2019 at 12:23 PM Daniel McInerney
<daniel.o.mcinerney at gmail.com> wrote:
>
> Hi List,
>
> As part of a workflow, we are importing ESRI Shapefiles into GRASS so
> that we can manage the vector topology, before re-exporting the vectors
> back to an ESRI Shapefile. However, we noticed that the date fields are
> being converted from a field of type Date to type String.

AFAIK this is how SQLite handles it internally but the GRASS DBMI
driver should take care of it to keep it in date format.


> Hopefully the
> following steps will demonstrate the issue:
>
> The input Shapefile is scdb_date, with a date field called 'BA_DATE':
>
>  >ogrinfo -so -al scdb_date.shp | grep BA_DATE
> BA_DATE: Date (10.0)
>
> After importing into GRASS using v.in.ogr, the field is still of type
> DATE (although the length has increased to 20):
>
>  >db.describe scdb_date | grep -A 5 BA_DATE
> column:BA_DATE
> description:
> type:DATE
> len:20
> scale:0
> precision:0
>
> However, when I export the vector (scdb_date) back to an ESRI Shapefile
> using v.out.ogr, the BA_DATE is converted to a String:
>
> v.out.ogr input=scdb_date output=scdb_date_export.shp
> format='ESRI_Shapefile'
>
>  >ogrinfo -so -al scdb_date_export.shp | grep 'BA_DATE'
> BA_DATE: String (20.0)

Probably the date detection failed in the grass-sqlite driver?
Could it be an encoding problem?

> I tried exporting to a GeoPackage, but the issue persists. While, we can
> still overcome this issue using ogr and SQL, I am wondering if is there
> a flag or option in v.out.ogr that I am overlooking that would maintain
> the fields of type Date or is there something else that I should consider?

As this is unexpected could you make a small data sample available to
easier reproduction?

thanks
Markus


More information about the grass-user mailing list