Borrar filtros
Borrar filtros

How to define geographicGrid in matlab code?

46 visualizaciones (últimos 30 días)
Devendra
Devendra el 29 de Mzo. de 2024
Comentada: Cris LaPierre el 24 de Abr. de 2024 a las 13:05
I am using following matlab code to extract data but it is giving some error.
img_file = 'c:\data\4MARCH24_BAND7_SUBSET.dat'
img = hypercube(img_file);
shapefile = 'c:\data\Achi Khurd.shp';
S = shaperead(shapefile);
%remove small triangles and squares
coord_lengths = arrayfun(@(s) numel(s.X), S);
not_useful_mask = coord_lengths < 10;
S(not_useful_mask) = [];
polygon = polyshape({S.X}, {S.Y});
% Create a logical mask
[Z,R] = readgeoraster(img_file);
[lat,lon] = geographicGrid(R);
[Lon, Lat] = meshgrid(lon, lat);
logical_mask = reshape(isinterior(polygon, Lon(:), Lat(:)), size(Lon));
% Use the logical mask to extract data
extracted_data = img(logical_mask);
disp(extracted_data);
It is giving following error
Incorrect number or types of inputs or outputs for function geographicGrid.
Error in Test (line 14)
[lat,lon] = geographicGrid(R);
I am attaching the data also in order to run the above mentioned matlab code.
I would be thankful for suggesting me to fix it.
Deva

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 29 de Mzo. de 2024
Ultimately, the issue is because your input to geographicGrid is the wrong data type.
geographicGrid expects the input to be a GeographicCellsReference or GeographicPostingsReference object (see here). However, if you inspect the class of your variable R in the Workspace, you will see it is a MapCellsReference object.
Basically, your data file does not contain the data format you expect.
You can compare the difference between the two as well as see their corresponding object functions on their respective doc pages.
  23 comentarios
Devendra
Devendra el 24 de Abr. de 2024 a las 12:40
Editada: Devendra el 24 de Abr. de 2024 a las 12:41
I have put across the question of customizing enviwrite code to larger MATLAB community but so far nobody has responded in last two days. Actually I want to customize enviwrite matlab code for reading my map_info and produce ENVI header file containing map_info and projection_info. Please suggest me whom should I approach to get it coustomized for my purpose. I would appreciate your kind suggestions and would be highly obliged to you.
Devendra
Cris LaPierre
Cris LaPierre el 24 de Abr. de 2024 a las 13:05
Sorry. It can take a while, especially if the topic is niche. I'm afraid this is not an area where I consider myself an expert. I do not know who to direct you to, and I am unfamiliar with the topics you are asking about.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by