How to extract data through the shapefile (India) from global precipitation data.

M
Malakai · Oct 28, 2020 · 2.1K views
Question
I have shapefile for Indian region. Actually, I want to extract Indian region data through this shapefile froml data. Please help me for doing this.
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Nov 20, 2025

YOu need to read about inpolygon. This function helps you to extract what you want.

shapefile = 'India_Shapefile\ind_state_2000.shp' ;

S = load('global_data.mat') ;
C = shaperead(shapefile) ;
N = length(C) ;

lon = S.lon ; lat = S.lat ;
P = S.prc ;
[X,Y] = meshgrid(lon,lat) ;

iwant = cell(N,2) ;
for i =1:N

      Cx = C(i).X ; Cy = C(i).Y ;
      idx = inpolygon(X(:),Y(:),Cx',Cy') ;
      P1 = P(:,:,1)' ;
      iwant{i,1} = P1(idx) ;
      P2 = P(:,:,2)' ;
      iwant{i,2} = P2(idx) ;
  end
100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!