How to create a chloropleth map using the mean of the shapefiles sub-fields from a raster file?

조회 수: 1 (최근 30일)
I am trying to create a chloropleth map which would show the means over the sub-regions of the shapefile using a raster file (the raster file is attached here and named as "Raster.mat". The raster file's latitude and longitude are attached here as "RasterLat.mat" and "RasterLon.mat", respectively. The shapefile is attached as "District_Boundaries.zip" with this question. Kindly help me with the same.
Thanks.

답변 (1개)

KSSV
KSSV 2022년 11월 21일
편집: KSSV 2022년 11월 21일
  댓글 수: 1
Abhishek Chakraborty
Abhishek Chakraborty 2022년 11월 21일
Hi. I tried running the code as per the suggestions but I am unable to get any results. Here is my code:
shapefile = 'C:\Users\District_Boundaries.shp' ;
S = shaperead(shapefile) ;
N = length(S) ;
for i = 1:N
plot(S(i).X,S(i).Y)
hold on
end
info=geotiffinfo("F:\India\Result.tif");
[x,y]=pixcenters(info); % x is Long and y is Lat
[X,Y]=meshgrid(x,y);
data = load("C:\Users\Abhishek\Downloads\Raster.mat") ;
[nx,ny,d] = size(data) ;
%%Extract data
iwant = cell(d,N) ;
for i =1:d
A = data(:,:,i) ;
for j = 1:N
idx = inpolygon(X(:),Y(:),S(i).X,S(i).Y) ;
iwant{i,j} = A(idx) ;
end
end

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by