How to Crop India shape file from Global shapefile

조회 수: 7 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2020년 8월 30일
댓글: Poulomi Ganguli 2020년 8월 31일
Hello:
I have two shapefiles: global shapefiles of landuse map and India administrative boundary shapefile. Is it possible to clip/crop the India region using shapefile of India from global shapefile?
The shapefile for India is available in this link: http://otlet.sims.berkeley.edu/imls/world/IND/IND_ADM0.shp
I have attached the global shape file (in Zip) here.
  댓글 수: 4
KSSV
KSSV 2020년 8월 31일
There is no .dbfread file in the zip folder. And the link given downloads on .shp file. To read shape file it needs all supporting files.
Poulomi Ganguli
Poulomi Ganguli 2020년 8월 31일
There is a .dbf file in the zip folder. For India shapefile with all supporting files are available in this link: https://otlet.berkeley.edu/imls/world/IND/
Kindly consider files associated with IND_ADM0.shp
For global shape file, please download from this link, if the zipped file does not load associated files: https://datacatalog.worldbank.org/dataset/world-maps-k%C3%B6ppen-geiger-climate-classification/resource/274ce998-385d-403b-8196
Please let me know if you have any further issues.

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

채택된 답변

KSSV
KSSV 2020년 8월 31일
shpFile1 = "c1976_2000.shp" ;
shpFile2 = "IND_ADM1.SHP" ;
S1 = shaperead(shpFile1) ;
S2 = shaperead(shpFile2) ;
P1 = [[S1(:).X]' [S1(:).Y]'] ;
P2 = [[S2(:).X]' [S2(:).Y]'] ;
N = length(S2) ;
%% Get the points from gloabl file from given Indian file
% Remove NaN's from P1
idx = isnan(P1(:,1)) ;
P = cell(N,1) ; % required matrix
% Get the points lying inside shapefile2 from shape shapefile1
for i = 1:N
i
P2i = [[S2(i).X]' [S2(i).Y]'] ;
idx = isnan(P2i(:,1)) ;
P2i(idx,:) = [] ;
idx = inpolygon(P1(:,1), P1(:,2),P2i(:,1),P2i(:,2)) ;
P{i} = P1(idx,:) ;
end
P = cell2mat(P) ;
plot(P2(:,1),P2(:,2),'.b')
hold on
plot(P(:,1),P(:,2),'.r')
  댓글 수: 3
KSSV
KSSV 2020년 8월 31일
With the points use boundary. Read about the function boundary.
Poulomi Ganguli
Poulomi Ganguli 2020년 8월 31일
could you please show how it could be done here?

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

추가 답변 (0개)

카테고리

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