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?
-
How many points do you want to get? One for every raster cell, or on a regular grid, or only local max/min values?– AndreJCommented Nov 13, 2013 at 9:07
-
one for every raster cell. I used ArcGIS tool (Ratser to point) but i wanted to calculate using QGIS– suyogpatwardhanCommented Nov 13, 2013 at 9:08
8 Answers
QGIS 3.4
There tool is a Raster pixels to points tool newly added in QGIS 3.4 (Oct./2018).
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).
-
It is now 2024 and this works extremely well and is really, really fast!– i.i.k.Commented May 15 at 8:49
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).
-
-
Qgis 3.18: this is now under
SAGA/Vector<->Raster/Raster values to points
– annebCommented Oct 20, 2021 at 11:43
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:
-
I tried this But it is very time consuming for large size dataset. Commented Nov 13, 2013 at 9:15
-
1You can reduce the number of points with the second tutorial.– AndreJCommented Nov 13, 2013 at 9:17
-
1The second link is apparently no more available. Could you upload a new one? Thanx a lot @suyogpatwardhan– JanitaCommented Jun 15, 2016 at 8:34
-
1
GRASS-GIS-tool r.to.vect will do it. Select point as output. You have to install GRASS-GIS for that.
-
1Inside QGIS, you will find it in the processing toolbox as well. Make sure to select Feature type
point
.– AndreJCommented Aug 19, 2015 at 10:39
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.
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
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')
Raster -> Conversion -> Polygonize (Raster to vector)
http://hub.qgis.org/wiki/17/Raster_to_vector_conversion
Will do this.
-
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. Commented Nov 13, 2013 at 9:07