How can I convert some pixels of a satellite image (raster) into point (shapefile)?
5 views (last 30 days)
Show older comments
I have a raster image (satellite image) that I need to convert some pixels (for example, pixels >1) in the image to point (shapefile). How can I do this?
0 Comments
Answers (1)
gmflores
on 11 Oct 2022
Read the image and select some pixels (uses Mapping Toolbox)
[img,R] = readgeoraster('boston.tif','OutputType','double','Bands',1);
idx = find(img < 5);
Get the location of the pixels (X, Y), create a mappoint vector, and write the shapefile
[X,Y] = meshgrid(linspace(R.XWorldLimits(1), R.XWorldLimits(2), R.RasterSize(2)), linspace(R.YWorldLimits(1), R.YWorldLimits(2), R.RasterSize(1)));
shp = mappoint(X(idx), Y(idx), 'pixValue', img(idx));
shapewrite(shp,'boston_points');
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!