Plot line with points at given distance
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ricco Blass
le 18 Fév 2022
Commenté : Ricco Blass
le 26 Fév 2022
Hi all,
I need to find a way to plot markers along a line (river course; attached file) with a given distance, e.g. each 500m.
Is there a way to extract these values. The find function does not work in this situation since I only get an empty double column vector. I've used the TopoToolbox before, so the dataset is a STREAMobj which might be diffucult to read for one who hasn't the toolbox installed.
I tried to plot new points with spacing, but since the river is not smoothed and also should not be, point spacing starts and every new edge.
plot(Facet1)
hold on
spacing = 500;
plot(Facet1(1:spacing:end,1),'ro')
In advance thanks for your help.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/902430/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/902430/image.png)
4 commentaires
Voss
le 18 Fév 2022
Ah, I see. I thought all the toolboxes were available here, so that's good to know.
Réponse acceptée
Wolfgang Schwanghart
le 25 Fév 2022
Since you are working with TopoToolbox, you might want to use the function getlocation. If you have a STREAMobj S, then you can retrieve points at a distance of 500 m as follows:
DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif');
FD = FLOWobj(DEM);
S = STREAMobj(FD,'minarea',1000);
S = klargestconncomps(trunk(S));
[x,y,val] = getlocation(S,[0:500:max(S.distance)]);
plot(S)
hold on
plot(x,y,'ok','MarkerFaceColor',[.5 .5 .5])
axis image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/907320/image.png)
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!