Creating mask from coastline
Ältere Kommentare anzeigen
I'm trying to create a mask from coastline data, which is a N x 2 array of the points, however I'm having trouble actually creating the mask. I've tried using the inpolygon function as an alternative, but it's coming up empty. Here is the part of the code:
C=load('costatotal.dat'); % loading the coastal data
C=C(~isnan(C)); % taking out the NaNs as they don't work in deg2utm
C=reshape(C,numel(C)/2,2); % reshapes
[x_c,y_c]=deg2utm(C(:,2),C(:,1)); % C(:,2)=latitude , C(:,1)=longitude
[X,Y]=meshgrid(linspace(min(xo),max(xo),N),linspace(min(yo),max(yo),N)); % creates a mesh grid that contains the lats and longs of the query points
[in]=inpolygon(X,Y,x_c,y_c); % inpolygon is testing to see if the query points are within the coastline
4 Kommentare
Sara
am 6 Aug. 2014
maybe attach the inputs...
Roseanne
am 7 Aug. 2014
Sara
am 7 Aug. 2014
- Are xo,yo the coordinates or a rectangular area in lat lon coordinates or UTM?
- What do you mean with 40 by 40? cells, km, degrees?
- Is what you want to do extracting the points that lie within an area defined with xo,yo from the coordinates in C? In this case you can do:
k = find(x_c >= min(xo) & x_c <= max(xo) & y_c >= min(yo) & y_c <= max(yo));
x_c = x_c(k);
y_c = y_c(k);
Note, this line in your code may be in the wrong if the lat and the lon are not NaN's at the same time:
C=C(~isnan(C)); % taking out the NaNs as they don't work in deg2utm
Roseanne
am 8 Aug. 2014
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 20 Aug. 2014
0 Stimmen
Wow - so complicated. Too bad you don't have the Image Processing Toolbox where you could simply use poly2mask(). Very simple - one line of code.
Kategorien
Mehr zu Geometric Geodesy finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!