Mateusz
Mateusz

Reputation: 49

save file in XYZ format as vector (GML or shp)

I am using QGIS software. I would like to show value of each raster cell as label. My idea (I don't know any plugin or any functionality from QGIS which allow to 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.


yes - sorry I forgot to add such information.

In general after preparing CSV file (using gdal2xyz.py with -csv option), I need to add one line at begining of it: "Longitude,Latitude,Value" (without the quotes)

Then I need to create a VRT file which contain

*> <OGRVRTDataSource>
>     <OGRVRTLayer name="Shapefile_name">
>         <SrcDataSource>Shapefile_name.csv</SrcDataSource>
>         <GeometryType>wkbPoint</GeometryType>
> 
>         <GeometryField encoding="PointFromColumns" x="Longitude"
> y="Latitude"/>
>     </OGRVRTLayer> </OGRVRTDataSource>*

Run the command "ogr2ogr -select Value Shapefile_name.shp Shapefile_name.vrt". I got the file evap_OBC.shp and two other associated files.

Upvotes: 1

Views: 2452

Answers (1)

mloskot
mloskot

Reputation: 38942

For the sake of archive completeness, this question has also been asked on GDAL mailing list as thread save raster as point-vector file. It seems Chaitanya provided solution for it.

Upvotes: 0

Related Questions