How to Crop India shape file from Global shapefile
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Poulomi Ganguli
el 30 de Ag. de 2020
Comentada: Poulomi Ganguli
el 31 de Ag. de 2020
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 comentarios
KSSV
el 31 de Ag. de 2020
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.
Respuesta aceptada
KSSV
el 31 de Ag. de 2020
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Map Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!