Convert .shp file to .mat file

7 ビュー (過去 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 Center および File ExchangeOceanography and Hydrology についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by