How to retrieve multiband data using shape file?
I have kept the data and shape file on following link
https://drive.google.com/drive/folders/1bnXx0V4V_yfUyWDfKFSxJWlNcWbApuxY?usp=sharing
I am using the code for extracting seven band data as follows;
% Get image info:
DataFile=’C:working_bptbandsBagpat_7Bands.dat’
[Z,R] = readgeoraster(DataFile);
disp(size(Z));
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
ShapeFile=’C:working_bptbandsBAGHPAT.shp’
S = shaperead(ShapeFile);
info = shapeinfo(ShapeFile);
crs = info.CoordinateReferenceSystem;
[S(1).lon,S(1).lat] = projinv(crs,S(1).X,S(1).Y);
% Remove trailing nan from shapefile
rx = S(1).lon(1:end-1);
ry = S(1).lat(1:end-1);
logical_mask = inpolygon(S(1).lon,S(1).lat,rx,ry);
% Use the logical mask to extract data
extracted_data = Z(logical_mask);
disp(extracted_data);
it is giving following informations
DataFile =
‘C:working_bptbandsBagpat_7Bands.dat’
5490 5490 7
ShapeFile =
‘C:working_bptbandsBAGHPAT.shp’
disp(size(extracted_data));
1 9
OR
ShapeFile =
‘C:working_bptbandsBAGHPAT.shp’
disp(extracted_data);
1794 1842 1829 1858 1934 1968 2315 2635 2578
My target is to retrieve the data from seven band data of dimensions
number of lines = 5490
number of samples = 5490
number of bands =7
and dimensions of output file are supposed to be
number of lines =1153
number of samples = 1315
number of bands =7
I request you to kindly look on it and suggest me how to get seven band data using shape file.I have kept the data and shape file on following link
https://drive.google.com/drive/folders/1bnXx0V4V_yfUyWDfKFSxJWlNcWbApuxY?usp=sharing
I am using the code for extracting seven band data as follows;
% Get image info:
DataFile=’C:working_bptbandsBagpat_7Bands.dat’
[Z,R] = readgeoraster(DataFile);
disp(size(Z));
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
ShapeFile=’C:working_bptbandsBAGHPAT.shp’
S = shaperead(ShapeFile);
info = shapeinfo(ShapeFile);
crs = info.CoordinateReferenceSystem;
[S(1).lon,S(1).lat] = projinv(crs,S(1).X,S(1).Y);
% Remove trailing nan from shapefile
rx = S(1).lon(1:end-1);
ry = S(1).lat(1:end-1);
logical_mask = inpolygon(S(1).lon,S(1).lat,rx,ry);
% Use the logical mask to extract data
extracted_data = Z(logical_mask);
disp(extracted_data);
it is giving following informations
DataFile =
‘C:working_bptbandsBagpat_7Bands.dat’
5490 5490 7
ShapeFile =
‘C:working_bptbandsBAGHPAT.shp’
disp(size(extracted_data));
1 9
OR
ShapeFile =
‘C:working_bptbandsBAGHPAT.shp’
disp(extracted_data);
1794 1842 1829 1858 1934 1968 2315 2635 2578
My target is to retrieve the data from seven band data of dimensions
number of lines = 5490
number of samples = 5490
number of bands =7
and dimensions of output file are supposed to be
number of lines =1153
number of samples = 1315
number of bands =7
I request you to kindly look on it and suggest me how to get seven band data using shape file. I have kept the data and shape file on following link
https://drive.google.com/drive/folders/1bnXx0V4V_yfUyWDfKFSxJWlNcWbApuxY?usp=sharing
I am using the code for extracting seven band data as follows;
% Get image info:
DataFile=’C:working_bptbandsBagpat_7Bands.dat’
[Z,R] = readgeoraster(DataFile);
disp(size(Z));
p = R.ProjectedCRS;
[x,y] = worldGrid(R);
[lon,lat] = projinv(p,x,y);
ShapeFile=’C:working_bptbandsBAGHPAT.shp’
S = shaperead(ShapeFile);
info = shapeinfo(ShapeFile);
crs = info.CoordinateReferenceSystem;
[S(1).lon,S(1).lat] = projinv(crs,S(1).X,S(1).Y);
% Remove trailing nan from shapefile
rx = S(1).lon(1:end-1);
ry = S(1).lat(1:end-1);
logical_mask = inpolygon(S(1).lon,S(1).lat,rx,ry);
% Use the logical mask to extract data
extracted_data = Z(logical_mask);
disp(extracted_data);
it is giving following informations
DataFile =
‘C:working_bptbandsBagpat_7Bands.dat’
5490 5490 7
ShapeFile =
‘C:working_bptbandsBAGHPAT.shp’
disp(size(extracted_data));
1 9
OR
ShapeFile =
‘C:working_bptbandsBAGHPAT.shp’
disp(extracted_data);
1794 1842 1829 1858 1934 1968 2315 2635 2578
My target is to retrieve the data from seven band data of dimensions
number of lines = 5490
number of samples = 5490
number of bands =7
and dimensions of output file are supposed to be
number of lines =1153
number of samples = 1315
number of bands =7
I request you to kindly look on it and suggest me how to get seven band data using shape file. how to retrieve multiband data using shape file? MATLAB Answers — New Questions