[gdal-dev] save raster as point-vector file
Mateusz Kędzior
matandked at gmail.com
Thu Aug 11 14:17:31 EDT 2011
Hi Chaitanya,
I try to add full path to csv file - is it correct?
===================================================NEW VRT
FILE====================================
<OGRVRTDataSource>
<OGRVRTLayer name="evap_OBCXYZn">
<SrcDataSource>"/media/windows/studia/2_sem_mgr/mgr/prof_Zawadzki/dods/gldas/00Z07Apr2009_00Z15Apr2009/evap_OBCXYZn.csv"</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="Longitude"
y="Latitude"/>
</OGRVRTLayer>
</OGRVRTDataSource>
================================================================================================
When I try use ogrinfor I get an error message:
FAILURE:
Unable to open datasource `evap_OBCXYZn.vrt' with the following drivers.
When I use the same tool at csv file I get:
=================================
INFO: Open of `evap_OBCXYZn.csv'
using driver `CSV' successful.
1: evap_OBCXYZn (None)
================================
The CSV file contain such information:
============================
Longitude,Latitude,Name
20.132145,52.4227439,1.78132e-05
20.382145,52.4227439,1.89083e-05
...
and so on..
============================
How I can change it to get vector-point layer? As I wrote I can only get a
layer without geometry if I point to csv file.
============
Best regards,
Mateusz
W dniu 11 sierpnia 2011 10:04 użytkownik Chaitanya kumar CH <
chaitanya.ch at gmail.com> napisał:
> What is the output of ogrinfo on the .vrt file?
>
>
> 2011/8/11 Mateusz Kędzior <matandked at gmail.com>
>
>> Hi Chaitanya,
>>
>> I say that I don't need to create VRT file, but I was wrong. When I try to
>> run ogr2ogr utility:
>> *
>> ogr2ogr -f GML output_file.gml input_file.csv*
>>
>> I discover that created file contain only table - if I choose ESRI
>> shapefile as output, I get only dbf file.
>>
>> So i try to generate such file:
>>
>>
>> ================================================================================
>> <OGRVRTDataSource>
>> <OGRVRTLayer name="evap_OBC_OBCXYZn">
>> <SrcDataSource>evap_OBC_OBCXYZn.csv</SrcDataSource>
>>
>> <GeometryType>wkbPoint</GeometryType>
>> <LayerSRS>WGS84</LayerSRS>
>> <GeometryField encoding="PointFromColumns" x="Longitude"
>> y="Latitude"/>
>> </OGRVRTLayer>
>> </OGRVRTDataSource>
>>
>> =================================================================================
>>
>> but:
>>
>> - if I type .vrt file as input I get an empty GML file
>> - if I I type .csv file as input I get an output which contain only
>> table (without geometry)
>>
>> How I can run it properly?
>> Which values are allowed in <GeometryField encoding> property?
>> ===================
>> Best regards,
>> Mateusz
>>
>> W dniu 10 sierpnia 2011 05:58 użytkownik Chaitanya kumar CH <
>> chaitanya.ch at gmail.com> napisał:
>>
>> Mateusz,
>>>
>>> You have to change the OGRVRTLayer name property to point to the file
>>> name without the extension. Also change the SrcDataSource element.
>>>
>>> FYI, this process creates a vector file with points. gdal_polygonize
>>> produces polygons.
>>>
>>>
>>> 2011/8/10 Mateusz Kędzior <matandked at gmail.com>
>>>
>>>> Hi again,
>>>>
>>>> is it mandatory to create such file?
>>>> Regarding to information on GDAL/OGR page should I create simple text
>>>> file which contains only other OGRVRTLayer name property :
>>>>
>>>> <OGRVRTDataSource>
>>>> <OGRVRTLayer name="test">
>>>> <SrcDataSource>test.csv</SrcDataSource>
>>>> <GeometryType>wkbPoint</GeometryType>
>>>> <LayerSRS>WGS84</LayerSRS>
>>>> <GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>
>>>> </OGRVRTLayer>
>>>> </OGRVRTDataSource>
>>>>
>>>> ==============
>>>> Best regards,
>>>> Mateusz
>>>>
>>>> W dniu 9 sierpnia 2011 20:13 użytkownik Chaitanya kumar CH <
>>>> chaitanya.ch at gmail.com> napisał:
>>>>
>>>>> Create a text file with just the header. Use the cat command to join
>>>>> this file and the xyz file.
>>>>> $ cat HeaderFile.csv file1.csv > file1.cHi sv
>>>>>
>>>>> You can repeat this on all files in a shell script.
>>>>>
>>>>> Otherwise add the following line in the gdal2xyz.py script at line 144
>>>>> [1].
>>>>>
>>>>> dst_fh.write( 'Longitude,Latitude,Name' )
>>>>>
>>>>> You will also have to create a separate vrt file for each csv file. The
>>>>> SrcDataSource element value changes for each file.
>>>>>
>>>>> [1]:
>>>>> http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/scripts/gdal2xyz.py?rev=21127#L145
>>>>>
>>>>>
>>>>> 2011/8/9 Mateusz Kędzior <matandked at gmail.com>
>>>>>
>>>>>> Chaitanya,
>>>>>>
>>>>>> if I understand properly, I need to add one line to each of processed
>>>>>> files.
>>>>>> How I can do it quickly? Is there any option in gdal2xyz.py script?
>>>>>>
>>>>>> If no - what would You recommend?
>>>>>> I think about sed utility, but it's general difficult in use.
>>>>>>
>>>>>> When I am thinking about Python I see only one possibility - load each
>>>>>> file to variable and then assign to another first line plus variable and at
>>>>>> last - save it.
>>>>>>
>>>>>> ==============
>>>>>> Best Regards,
>>>>>> Mateusz
>>>>>>
>>>>>> W dniu 9 sierpnia 2011 13:38 użytkownik Chaitanya kumar CH <
>>>>>> chaitanya.ch at gmail.com> napisał:
>>>>>>
>>>>>> Mateusz,
>>>>>>>
>>>>>>> gdal2xyz.py creates space delimited fields. Consider running it with
>>>>>>> the -csv option to delimit it with comma.
>>>>>>> Now you can almost use it as a csv format vector file. You just need
>>>>>>> to add a header row and define a small VRT file as described in OGR's CSV
>>>>>>> driver page[1].
>>>>>>> Run ogrinfo and ogr2ogr on the .vrt file to check the file.
>>>>>>>
>>>>>>> [1]: http://www.gdal.org/ogr/drv_csv.html
>>>>>>>
>>>>>>> 2011/8/9 Mateusz Kędzior <matandked at gmail.com>
>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I would like to show value of each raster cell as label. My idea (I
>>>>>>>> don't know any plugin or any functionality in GDAL/OGR which allow to do it
>>>>>>>> easier) is to export raster using gdal2xyz.py into coordinates-value format
>>>>>>>> and then save it as vector (GML or shapefile). For this second task, I try
>>>>>>>> to use
>>>>>>>>
>>>>>>>> =================================================================================================================================================
>>>>>>>> gdal_polygonize.py:
>>>>>>>> gdal_polygonize.py rainfXYZ.txt rainf.shp Creating output rainf.shp
>>>>>>>> of format GML. 0...10...20...30...40...50...60...70...80...90...100 - done.
>>>>>>>>
>>>>>>>> =================================================================================================================================================
>>>>>>>> unfortunately I am unable to load created file (even if I change the
>>>>>>>> extension to .gml)
>>>>>>>> ogr2ogr tool don't even recognize this format.
>>>>>>>>
>>>>>>>> =========================
>>>>>>>> Thank You in advance,
>>>>>>>> Mateusz
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> gdal-dev mailing list
>>>>>>>> gdal-dev at lists.osgeo.org
>>>>>>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Best regards,
>>>>>>> Chaitanya kumar CH.
>>>>>>>
>>>>>>> +91-9494447584
>>>>>>> 17.2416N 80.1426E
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best regards,
>>>>> Chaitanya kumar CH.
>>>>>
>>>>> +91-9494447584
>>>>> 17.2416N 80.1426E
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Chaitanya kumar CH.
>>>
>>> +91-9494447584
>>> 17.2416N 80.1426E
>>>
>>
>>
>
>
> --
> Best regards,
> Chaitanya kumar CH.
>
> +91-9494447584
> 17.2416N 80.1426E
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110811/31f3a93a/attachment-0001.html
More information about the gdal-dev
mailing list