Discussion:
[gdal-dev] VRT layer definition question
Al Piszcz
2021-05-31 20:30:33 UTC
Permalink
I am having a challenge determining the right position or entry for the
Field entry, the spatial filter error below indicates my VRT format is not
correct. Is there a better approach? Thank you.
ogrmerge.py -overwrite_ds -single -o __sdg\merge_02.csv __sdg\merge_01.vrt
*Warning 1: The 'lon' and/or 'lat' fields of the source layer are not
declared as numeric fields, so the spatial filter cannot be turned into an
attribute filter on them*

The VRT is defined as
<OGRVRTDataSource>
<OGRVRTLayer name="file1">
<SrcDataSource>lib/_data/sdg/data\file1.csv</SrcDataSource>
<SrcLayer>file1</SrcLayer>
<Field name="lon" type="real" />
<Field name="lat" type="real" />
<SrcRegion clip="true">POLYGON ((0.0 0.0, 0.0 0.1, 0.1 0.1, 0.1 0.0, 0.0
0.0))</SrcRegion>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
</OGRVRTLayer>

<OGRVRTLayer name="file2">
<SrcDataSource>lib/_data/sdg/data\file2.csv</SrcDataSource>
<SrcLayer>file2</SrcLayer>
<Field name="lon" type="real" />
<Field name="lat" type="real" />
<SrcRegion clip="true">POLYGON ((0.0 0.0, 0.0 0.1, 0.1 0.1, 0.1 0.0, 0.0
0.0))</SrcRegion>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
</OGRVRTLayer>

</OGRVRTDataSource>
jratike80
2021-05-31 20:41:55 UTC
Permalink
Hi,

Please add couple of rows from your CSV file. Maybe the lon and lat fields
are otherwise OK but GDAL does not recognize them to contain numbers but
perhaps text. You can also check what sort of attributes ogrinfo reports
with

ogrinfo file1.csv -al -so

-Jukka Rahkonen-
Post by Al Piszcz
I am having a challenge determining the right position or entry for the
Field entry, the spatial filter error below indicates my VRT format is not
correct. Is there a better approach? Thank you.
ogrmerge.py -overwrite_ds -single -o __sdg\merge_02.csv __sdg\merge_01.vrt
*Warning 1: The 'lon' and/or 'lat' fields of the source layer are not
declared as numeric fields, so the spatial filter cannot be turned into an
attribute filter on them*
The VRT is defined as
<OGRVRTDataSource>
<OGRVRTLayer name="file1">
<SrcDataSource>
lib/_data/sdg/data\file1.csv
</SrcDataSource>
<SrcLayer>
file1
</SrcLayer>
<Field name="lon" type="real" />
<Field name="lat" type="real" />
<SrcRegion clip="true">
POLYGON ((0.0 0.0, 0.0 0.1, 0.1 0.1, 0.1 0.0, 0.0
0.0))
</SrcRegion>
<GeometryType>
wkbPoint
</GeometryType>
<LayerSRS>
WGS84
</LayerSRS>
<GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
</OGRVRTLayer>
<OGRVRTLayer name="file2">
<SrcDataSource>
lib/_data/sdg/data\file2.csv
</SrcDataSource>
<SrcLayer>
file2
</SrcLayer>
<Field name="lon" type="real" />
<Field name="lat" type="real" />
<SrcRegion clip="true">
POLYGON ((0.0 0.0, 0.0 0.1, 0.1 0.1, 0.1 0.0, 0.0
0.0))
</SrcRegion>
<GeometryType>
wkbPoint
</GeometryType>
<LayerSRS>
WGS84
</LayerSRS>
<GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
</OGRVRTLayer>
</OGRVRTDataSource>
_______________________________________________
gdal-dev mailing list
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
Al Piszcz
2021-06-01 06:01:10 UTC
Permalink
Jukka:
Thank you, interesting, lat,lon interpreted as string by gdalinfo.

==== Request 1
ogrinfo file1.csv -al -so
INFO: Open of `file1.csv'
using driver `CSV' successful.

Layer name: file1
Geometry: None
Feature Count: 1000
Layer SRS WKT:
(unknown)
lon: String (0.0)
lat: String (0.0)
id: String (0.0)
field_4: String (0.0)

=== Request 2
::: file1.csv
lon,lat,id,
0.084362378404311,0.08587464990542,"0"
0.090601035370249,0.005574551382458,"1"
0.074081946277276,0.020574321282505,"2"
0.034318505618178,0.034922734033886,"3"
0.008330436091964,0.013543226571866,"4"



Message: 2
Date: Mon, 31 May 2021 13:41:55 -0700 (MST)
From: jratike80 <***@maanmittauslaitos.fi>
To: gdal-***@lists.osgeo.org
Subject: Re: [gdal-dev]
Message-ID: <1622493715145-***@n6.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi,

Please add couple of rows from your CSV file. Maybe the lon and lat fields
are otherwise OK but GDAL does not recognize them to contain numbers but
perhaps text. You can also check what sort of attributes ogrinfo reports
with

ogrinfo file1.csv -al -so

-Jukka Rahkonen-
jratike80
2021-06-01 09:46:57 UTC
Permalink
Hi,

Ogrinfo finds numbers from the .csv file with a little help:
ogrinfo csv.csv csv -al -oo autodetect_type=yes

Ogrinfo finds numbers from the .csv file automatically, probably because the
fields are mapped into real in the vrt file:
ogrinfo csv.vrt -al -so

But ogrmerge.py does have a problem:
ogrmerge f csv -o merged.csv csv.vrt
Warning 1: The 'lon' and/or 'lat' fields of the source layer are not
declared as numeric fields, so the spatial filter cannot be turned into an
attribute filter on them

Ogrmerge runs when I add a mapping file .csvt

csv.csvt
=====
Real,Real,String

It seems to me that your vrt file is OK but there is some issue in the
ogrmerge.py script that does not get the data type of the field correctly
from vrt. Write the csvt file and you should be fine.

-Jukka Rahkonen-
Post by Al Piszcz
Thank you, interesting, lat,lon interpreted as string by gdalinfo.
==== Request 1
ogrinfo file1.csv -al -so
INFO: Open of `file1.csv'
using driver `CSV' successful.
Layer name: file1
Geometry: None
Feature Count: 1000
(unknown)
lon: String (0.0)
lat: String (0.0)
id: String (0.0)
field_4: String (0.0)
=== Request 2
::: file1.csv
lon,lat,id,
0.084362378404311,0.08587464990542,"0"
0.090601035370249,0.005574551382458,"1"
0.074081946277276,0.020574321282505,"2"
0.034318505618178,0.034922734033886,"3"
0.008330436091964,0.013543226571866,"4"
Message: 2
Date: Mon, 31 May 2021 13:41:55 -0700 (MST)
From: jratike80 &lt;
&gt;
Subject: Re: [gdal-dev]
Message-ID: <
Content-Type: text/plain; charset=us-ascii
Hi,
Please add couple of rows from your CSV file. Maybe the lon and lat fields
are otherwise OK but GDAL does not recognize them to contain numbers but
perhaps text. You can also check what sort of attributes ogrinfo reports
with
ogrinfo file1.csv -al -so
-Jukka Rahkonen-
_______________________________________________
gdal-dev mailing list
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
Loading...