20

I wanted to convert Raster into Point Vector in QGIS. Is it possible? QGIS have option to convert it into polygon but i didn't found any tool to convert it into point. can anyone help me?

AndreJ
  • 76,698
  • 5
  • 86
  • 162
suyogpatwardhan
  • 899
  • 2
  • 9
  • 24

8 Answers8

20

QGIS 3.4

There tool is a Raster pixels to points tool newly added in QGIS 3.4 (Oct./2018).

enter image description here Raster pixels to points

This tool works with astonishing speed. When I converted 11-megabyte single band raster to point layer (which end up with 6 million points), the process time was:

Raster pixels to points ............................................. | 10.35 sec.

Processing - SAGA Raster values to points .......... | 380 sec.

SAGA GUI - Grid Values to Points ........................... | 130 sec.

(At the moment I could not run) GRASS r.to.vect ...... | not timed.

(This may not be a fair comparison, because SAGA tools return x and y coordinates along with the raster values).

Kazuhito
  • 30,746
  • 5
  • 69
  • 149
13

If you're using a version of QGIS that integrates SAGA algorithms, you can use the Grid values to points tool. You'll find it in the processing toolbox under SAGA/ Shapes-Grid (at least for QGIS 2.4.0).

m.chips
  • 308
  • 2
  • 7
11

Saving as ASCII grid and importing as delimited text may do what you want.

See this tutorial:

http://www.slideshare.net/shencoop/qgis-raster-to-point

If you want a less densified point file, try this tutorial:

http://www.gistutor.com/quantum-gis/19/54-how-to-sample-raster-datasets-using-points-in-quantum-gis-qgis.html

AndreJ
  • 76,698
  • 5
  • 86
  • 162
5

GRASS-GIS-tool r.to.vect will do it. Select point as output. You have to install GRASS-GIS for that.

Antoine
  • 541
  • 1
  • 6
  • 14
  • 1
    Inside QGIS, you will find it in the processing toolbox as well. Make sure to select Feature type point. – AndreJ Aug 19 '15 at 10:39
2

Raster -> Conversion -> Polygonize (Raster to vector) - This will create a polygon shapefile with squares representing each pixel from your raster. - Add an x and y field to your attribute table. - Calculate geometry for x and y centroids. - Export your attribute table to excel. - Save as a CSV. - Import CSV to ArcGIS and display x and y data to create new point shapefile with the pixels values.

John
  • 21
  • 1
1
REM English
    REM Tested in QGIS console version 2.18 (OSGEO4W Shell)
    REM Tested in Windows Operating System
    REM Folder where the image is (replace with your file directory): C: / Users / Administrator / Documents / ruts /
    REM Name of the dsm file: dtm_phase1_vm_15m_inside.tif
    REM Name of the output file csv: dtm_phase1_vm_15m_inside.csv
    REM Name of output file shp: dtm_phase1_vm_15m_inside.shp
REM eye that some directions (path) has separator / (bar) and other \ (backslash), respect them so you do not have problems
REM spanish
    REM Probado en consola de QGIS version 2.18 (OSGEO4W Shell)
    REM Probado en Sistema Operativo Windows
    REM Carpeta donde estan la imagen (sustituya por su directorio de archivos): C:/Users/Administrator/Documents/surcos/
    REM Nombre del archivo dsm: dtm_phase1_vm_15m_inside.tif
    REM Nombre del archivo de salida csv: dtm_phase1_vm_15m_inside.csv
    REM Nombre del archivo de salida shp: dtm_phase1_vm_15m_inside.shp
    REM ojo que algunas direcciones (path) tiene separador / (slash) y otras \ (backslash), respetelos para que no tenga problemas

REM converts the dsm image (surface model) from TIF format to CSV format
REM convierte la imagen dsm (modelo de superficie) de formato TIF a formato CSV

gdal2xyz.bat -band 1 -csv C:\Users\Administrator\Documents\surcos\dtm_phase1_vm_15m_inside.tif C:/Users/Administrator/Documents/surcos/dtm_phase1_vm_15m_inside.csv

REM removes the null values from the csv file (Z = 0)
REM elimina los valores nulos del archivo csv (Z = 0)

sed -i '/,0\s*$/d' C:/Users/Administrator/Documents/surcos/dtm_phase1_vm_15m_inside.csv

REM adds header to file with column names x, y, z
REM agrega encabezado al archivo con nombres de columna x,y,z

sed -i '1 i\x,y,z' C:/Users/Administrator/Documents/surcos/dtm_phase1_vm_15m_inside.csv

REM converts the csv file to shp format
REM covierte el archivo csv a formato shp

ogr2ogr -s_srs EPSG:32749 -t_srs EPSG:32749 -dialect SQLite -sql "SELECT CAST(z AS float) as z, MakePoint(CAST(x AS float),CAST(y AS float)) FROM dtm_phase1_vm_15m_inside" C:/Users/Administrator/Documents/surcos/dtm_phase1_vm_15m_inside.shp C:/Users/Administrator/Documents/surcos/dtm_phase1_vm_15m_inside.csv

1

I know the question was about QGIS, but R's raster package has the function rasterToPoints, which converts the raster to a matrix, with every row, representing the pixel's coordinates and value. From here you can convert to dataframe and then to a SpatialPointsDataFrame, export to shapefile and be on your way.

library(raster)
library(sp)

tst_ras <- raster('/path/to/raster.tif')
pointdf <- as.data.frame(rasterToPoints(tst_ras))
xy <- pointdf[,c(1,2)]

spdf <- SpatialPointsDataFrame(coords = xy, data = pointdf,
                               proj4string = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
shapefile(spdf, '/path/to/new/shape.shp')
Momchill
  • 284
  • 2
  • 9
-2

Raster -> Conversion -> Polygonize (Raster to vector)

http://hub.qgis.org/wiki/17/Raster_to_vector_conversion

Will do this.

Rob Lodge
  • 837
  • 11
  • 27
  • But Polygonize only convert raster to polygon. its not convert it into point. i wanted to convert DEM into point to get value of each pixel. – suyogpatwardhan Nov 13 '13 at 09:07