Borrar filtros
Borrar filtros

Convert .shp file to .mat file

14 visualizaciones (últimos 30 días)
SUSHMA MB
SUSHMA MB el 26 de Mzo. de 2015
Comentada: guodong zhao el 6 de Nov. de 2022
How can i convert a shape file into a matlab file?

Respuestas (1)

Danhay
Danhay el 23 de Mayo de 2016
Hello Sushma, I am not sure if you still need this, but this is what I use:
%%
% Read the shapefile into matlab as well as the boundaries
shp_res = shaperead(data.shp);
x1 = round(shp_res.BoundingBox(1,1))-1;
x2 = round(shp_res.BoundingBox(2,1))+1;
y1 = round(shp_res.BoundingBox(1,2))-1;
y2 = round(shp_res.BoundingBox(2,2))+1;
%%
% get the length of the lon lat using a resolution of 0.1
[lon, lat]=meshgrid(x1:0.1:x2,y1:0.1:y2);
lon1(:,1) = lon(1,:); lat1(:,1) = lat(:,1);
x4 = length(lon1); y4 = length(lat1);
Z = randn(x4,y4);
%%
% create the mat file
R = makerefmat('RasterSize',size(Z'),'Lonlim',[a1 a2],'Latlim',[b1 b2]);
mat_data = vec2mtx(shp_res.Y,shp_res.X,Z',R,'filled');
  1 comentario
guodong zhao
guodong zhao el 6 de Nov. de 2022
you are welcome!thanks,he maybe not liv.... but i need

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by