필터 지우기
필터 지우기

Convert .shp file to .mat file

조회 수: 14 (최근 30일)
SUSHMA MB
SUSHMA MB 2015년 3월 26일
댓글: guodong zhao 2022년 11월 6일
How can i convert a shape file into a matlab file?

답변 (1개)

Danhay
Danhay 2016년 5월 23일
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
guodong zhao
guodong zhao 2022년 11월 6일
you are welcome!thanks,he maybe not liv.... but i need

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

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by