Filter löschen
Filter löschen

How can i extract all the values inside shapefile feature overlaying a raster?

2 Ansichten (letzte 30 Tage)
Hello all;
I have a shapefile with lots of polygon features in it. what i need is a way to extract each of the pixel values with in each feature and output a histogram for these values. The image is a Geotif.
So basically to put in perspective the code must do;
  1. select one polygon feature inside the shape file,
  2. Overlay it with the Raster Geotif,
  3. get the Geotif pixel values for the selected feature,
  4. write the pixel values in excel for the specific OBJECTID,
  5. iterate to the next feature in the shapefile and repeat steps through 1-4 until end of shapefile features.
Any help and guidance is much appreciated.
Kind Regards.
  1 Kommentar
ÖMER
ÖMER am 18 Okt. 2023
I know everyone is looking for this kind of iteration;
for i=1:numel(NDShapeFile)
OBJECTID = NDShapeFile(i).OBJECTID; % Extract OBJECTID of each feature in the shapefile
OBJECTIDSTR = num2str(OBJECTID);
%OBJECTID Testing OBJECTID Value Works
shapewrite(NDShapeFile(i),append(OBJECTIDSTR,'.shp')); % Write each feature in the shapefile as an external shape
%Raster Value Extraction is going to go here
%NDShapeFile(i);
delete(append(OBJECTIDSTR,'.dbf'),append(OBJECTIDSTR,'.shp'),append(OBJECTIDSTR,'.shx'));
end

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by