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

조회 수: 6 (최근 30일)
ÖMER
ÖMER 2023년 10월 18일
댓글: ÖMER 2023년 10월 18일
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
ÖMER
ÖMER 2023년 10월 18일
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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by