On 8/11/06, Tyler Mitchell <[EMAIL PROTECTED]> wrote:
On 11-Aug-06, at 3:57 PM, P Kishor wrote:

> I have a CSV file called 'foo.txt' inside a directory called 'bar'.
> The first row contains column headers. I am trying to construct a
> meaningful OVF file like so, but failing.
>
> <OGRVRTDataSource>
>  <OGRVRTLayer  name="foo">
>  <SrcDataSource>CSV:"C:\\path\\to\\bar"</SrcDataSource>
>  <SrcLayer>foo.txt</SrcLayer>
>  <GeometryField encoding="PointFromColumns" x="LONGITUDE"
> y="LATITUDE"/>
>  <GeometryType>wkbPoint</GeometryType>
>  </OGRVRTLayer>
> </OGRVRTDataSource>

Hi Puneet,

 From my experience you have to treat the text file as the datasource
and the (only) layer will have the same prefix.  So don't point to
the folder, instead point to the file itself as the datasource.
Also, it seems ogr likes to have the CSV file with a .csv extension.
Even adding that CSV: prefix doesn't do the trick for me - so rename
your text file.

So here is what works for me:

$ cat foo.ovf
<OGRVRTDataSource>
<OGRVRTLayer name="foo">
<SrcDataSource>foo.csv</SrcDataSource>
<SrcLayer>foo</SrcLayer>
<GeometryField encoding="PointFromColumns" x="lon" y="lat"/>
<GeometryType>wkbPoint</GeometryType>
</OGRVRTLayer>
</OGRVRTDataSource>

$ cat foo.csv
"lat","lon"
54,124
55,122

Hope it helps,


Thanks, but unfortunately no. Here is my situation --

cd "C:\My Documents\resources"
less foo.ovf
<OGRVRTDataSource>
 <OGRVRTLayer name="foo">
 <SrcDataSource>"C:\\My Documents\\Data\\foo.csv"</SrcDataSource>
 <SrcLayer>foo</SrcLayer>
 <GeometryField encoding="PointFromColumns" x="LONGITUDE" y="LATITUDE"/>
 <GeometryType>wkbPoint</GeometryType>
 </OGRVRTLayer>
</OGRVRTDataSource>

less proj.txt
PROJCS['USA_Contiguous_Lambert_Conformal_Conic',GEOGCS['GCS_Nor...

cd "C:\My Documents\Data"
less foo.csv
ID,A,B,C,D,E,LONGITUDE,LATITUDE,F
1,10,,,,,-106.524288,35.139437,
2,10,,,,,-106.522907,35.132337,
3,10,,,,,-106.519838,35.148427,

cd "C:\My Documents\Home"
ogr2ogr -f "ESRI Shapefile" \
   -a_srs "C:\\My Documents\\resources\\proj.txt" \
   -t_srs "C:\\My Documents\\resources\\proj.txt" \
   foo_shapefile \
   "C:\\My Documents\\resources\\foo.ovf"

Couldn't run: ogr2ogr -f "ESRI Shapefile" -a_srs "C:/My
Documents/resources/proj.txt" -t_srs "C:/My
Documents/resources/proj.txt" foo_shapefile "C:/My
Documents/resources/foo.ovf" (No such file or directory)

I can't tell whether ogr2ogr can't file 'foo.ovf', or it can't find
the files referenced inside 'foo.ovf', or if I have something else
wrong altogether.


--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.ies.wisc.edu/
Open Source Geospatial Foundation https://edu.osgeo.org/

Reply via email to