TopoToolbox

The Big Tujunga stream network
The Big Tujunga stream network

What is TopoToolbox?

TopoToolbox provides a set of Matlab functions that support the analysis of relief and flow pathways in digital elevation models. The major aim of TopoToolbox is to offer helpful analytical GIS utilities in a non-GIS environment in order to support the simultaneous application of GIS-specific and other quantitative methods.

Who should use TopoToolbox?

TopoToolbox is not a click & go software. You should be familiar with Matlab and its programming syntax. If you feel well versed in Matlab, you will like TopoToolbox for its versatility, functionality and ability to be customized.

Where can I find a documentation?

Until now there is no full documentation of TopoToolbox. Yet, you’ll find a help section in (nearly) each function including syntax, input and output arguments, and an example. This blog is intended as an additional resource of more comprehensive examples. In addition, you might want to take a look at two papers about TopoToolbox published in Environmental Modelling and Software and Earth Surface Dynamics.

Where can I report bugs or suggestions for enhancement?

You found a bug? Sorry for the inconvenience. Please tell me more about it here. The same holds for enhancement requests. I cannot guarantee that I’ll have the time to deliver, but I’ll do my best to keep TopoToolbox up-to-date.

How can I stay informed about updates?

There is no mailing list. All news about TopoToolbox will be posted in this blog. Just set up a RSS-feed.

 

Advertisements

34 thoughts on “TopoToolbox

    Jean-Marie AUGUSTIN said:
    May 3, 2015 at 12:41 pm

    Hi,
    I have just discovered you toolbox which seems very interesting. I am the developer of a software suite written in Matlab language (SonarScope : http://flotte.ifremer.fr/fleet/Presentation-of-the-fleet/On-board-software/SonarScope http://fr.mathworks.com/company/newsletters/articles/developing-and-deploying-sonar-and-echosounder-data-analysis-software.html)
    I would be very interested to propose DEM processings using TopoToolbox in SonarScope.
    In addition to SonarScope I developped a 3DViewer based on Nasa World Wind that could interest you. If you are interested in getting copies of these software suites please tell me,

    Jean-Marie Augustin, Ifremer, France augustin@ifremer.fr

    Martine Collaud Coen said:
    August 25, 2016 at 11:28 am

    Hi,
    I do use TopoToolbox since several months and have a Problem with the coor2ind function. There is almost always a shift between the IX linear index calculated by coor2ind leading to an error between 0 and 50 on IX. If I plot on the topography the x,y coordinate (latitude and longitude), the shift can be visualised. Up to now I always plot them and caculate manually the shift. I have now to make calculation for a whole grid. Do you have a solution ?
    Martine

    wschwanghart responded:
    August 25, 2016 at 1:56 pm

    Hi Martine, I do not fully understand the error. coord2ind snaps x and y coordinates to the center of the nearest cell, and returns this cell’s linear index. Thus, there will usually always a shift between the x and y coordinates that you supply to coord2ind, and those coordinates that you obtain from ind2coord.

    Without knowing exactly your application, would the function GRIDobj/interp do the job? This function interpolates values in a grid to your coordinates.

    Best, Wolfgang

    Martine Collaud Coen said:
    August 25, 2016 at 2:28 pm

    Hi Wolfgang,

    I do not know if I’m doing something wrong. But coord2ind does not give me the nearest cell, but sometimes some 10 to 30 cells before or after the real cell. So that I implemented my Points with latitude, longitude and with the number of cells that have to be shifted to have the real Point. For example, using
    IX=coord2ind(X,Y, lon_st, lat_st),
    Figure
    imagesc(DEM1);
    hold on;
    plot(lon_st,lat_st,’xc’);
    [xx1,yy1]=ind2coord(DEM1,IX);
    plot(xx1,yy1,’ow’);

    then I Count on the map the difference d and if I plot

    [xx2,yy2]=ind2coord(DEM1,IX+d);
    plot(xx2,yy2,’ow’);

    then xx2 and yy2 are on the right place.

    d can be up to 45 sometimes. There is gridcells where this shift is small, then it increases and becomes suddently negatives and then decrease again. I asked my self is this can be due to a wrong rounding of the coordinates.
    I hope that you understand my Problem and many thanks for your answer
    Best regards
    Martine

    wschwanghart responded:
    August 26, 2016 at 7:34 am

    Hi Martine,
    quite difficult to judge from distance. But following possible errors come to my mind:
    – Do the GRIDobj and lon_st, lat_st share the same coordinates?
    – isequal(DEM.size,size(DEM.Z))
    If that doesn’t help, please write me an email (http://www.geo.uni-potsdam.de/mitarbeiterdetails/show/421/Wolfgang_Schwanghart.html).

    Best regards, Wolfgang

    Francisco Peña said:
    November 4, 2016 at 5:05 pm

    Hi Wolfgang,
    I’m very interested in using your software as part of my PhD research.
    I’ve recently downloaded Topotoolbox and I have experience some issues using basic commands during the 1st tutorial such as crop, resample or imageschs. For instance, after writing the command imageschs(DEM,min(gradient8(DEM),1)) I received the following error:
    ??? Undefined function or method ‘narginchk’ for input arguments of type ‘double’.

    Error in ==> GRIDobj.min at 5
    narginchk(1, 2)

    The paths have been correctly assigned so basically I don’t understand what I’m doing wrong.
    Could you please provide some advice in order to solve the problem?
    Thank you in advance,
    Francisco

    floodriskgis said:
    November 4, 2016 at 5:26 pm

    Dear Wolfgang,
    I’m very interested in using your software for my PhD research project.
    I recently downloaded Topotoolbox and unfortunately I’ve experienced some issues during the 1st tutorial.
    This happens when using the command >> imageschs(DEM,min(gradient8(DEM),1))
    ??? Undefined function or method ‘narginchk’ for input arguments of type ‘double’.

    Error in ==> GRIDobj.min at 5
    narginchk(1, 2)
    The paths were added correctly and I’ve followed the user guide step-by-step.
    Could you please provide some advice to solve this issue?
    Thanks in advance,

    Francisco Peña
    email- francisco.pena@unistrapg.it
    website- http://warredoc.unistrapg.it/

    wschwanghart responded:
    November 4, 2016 at 6:36 pm

    Dear Francisco,

    I guess that these issues arise due to an outdated version of matlab. narginchk was introduced in 2011b (https://de.mathworks.com/help/matlab/ref/narginchk.html). It seems your version is older than that.

    Best, Wolfgang

    ahmed said:
    November 26, 2016 at 12:01 pm

    Hi There, I have just start to work on TopoToolbox that i worked on TecDEM and stream profiler. Kindly I would like to ask if there someone in the UK working on TopoToolbox to contact him and see how to work. Another question is there a window appears to to choose the function(similler to TecDEM) or i have to write a command for each process in the MATLAB window.

    Many thanks

    VBuford said:
    December 4, 2016 at 3:43 am

    Hi there,

    I am currently using topotools to run ksn analyses. My tif is from Peru, so both negative lat and long. When I run the ksn help matlab code, and I get to L86 (the STATS section), I get this error:
    Error using histc
    Edge vector must be monotonically non-decreasing.

    Error in slopearea (line 141)
    [~,ix] = histc(a,edges);
    Do you have any idea why this is ocurring or how to fix this?

      wschwanghart responded:
      December 4, 2016 at 9:30 pm

      Hi, I had this issue before. It happened because a user worked with a geographic coordinate system (latitude, longitude). Please work with projected coordinate systems (e.g. UTM) with the horizontal and vertical coordinates having the same unit, e.g. [m]. You can use the function

      DEM = reproject2utm(DEM);

      Hope this works out. Please let me know if it doesn’t.
      Best regards, Wolfgang

        Ramendra Sahoo said:
        March 28, 2017 at 4:51 am

        Dear Wolfgang, I have recently started using topotoolbox for my research, which mainly focuses on quantitative attributes of drainage network. I was going through the userguide_XX.m files for acquaintance with the available functions. One of the example in that is the derivation of flow direction (both single and multiple) from a dem(baranja_hill.mat). Upon executing the line 28, I got an error message. Following are the line and the associated error message.

        load baranja_hill
        demf = fillsinks(dem);
        Undefined function ‘fillsinks’ for input arguments of type ‘double’.

        Later I checked and saw that ‘fillsinks’ use a GRIDobj as an input. Also, in case of the ‘flowdir’ function, I tried both the ‘GRIDobj’ type argument and ‘double’ type argument. For both of them, it returns the same type of error.

        Kindly look into this. I am using MATLAB R2015a, and I have licenses for both image processing and mapping toolbox. Please help me with the proble.

        Regards
        Ramendra

    wschwanghart responded:
    March 28, 2017 at 7:37 am

    Dear Ramendra, many thanks for your comment. You are right. The baranja_hill.mat contained the matrices X,Y and dem as they were used by TopoToolbox before we introduced GRIDobj. I have now updated the file which now contains the GRIDobj. At the same time, I realized that userguide_2_flats.m is completely outdated and incompatible with version 2 of TopoToolbox. At has been a while since I have looked at these files. Thanks for these hints!
    Best regards, Wolfgang

      Ramendra Sahoo said:
      March 28, 2017 at 8:25 am

      Dear Wolfgang, thank you for addressing my concern. I have downloaded the latest work-in-progress copy of topotoolbox only. But as per your suggestion, I again downloaded it and checked for the banjara_hills file. The same problem persists and there is no GRIDobj type file. And can you also kindly check the ‘flowdir’ tool, as it is taking neither mat file nor GRIDobj file as input. All the examples concerning the flowdir function has shown a mat file as input. But it is throwing the same error.
      ‘Undefined function ‘fillsinks’ for input arguments of type ‘double’.’

      Regards
      Ramendra

    Ramendra Sahoo said:
    March 28, 2017 at 9:36 am

    Dear Wolfgang, thank you very much. All the confusions seems to have been sorted out for now.

    Thanks and Regards
    Ramendra

    Ramendra Sahoo said:
    April 4, 2017 at 10:09 am

    Dear Wolfgang, can you kindly suggest any way to write a 2-d matrix into a geotiff file? I have been trying to do that using the geotiifwrite. But the function doesn’t perform consistently and throws some errors now and then.

    Regards
    Ramendra

      wschwanghart responded:
      April 8, 2017 at 8:06 pm

      Dear Ramendra, without seeing the error message, it is difficult to help out here. Unless you are writing a GRIDobj to a geotiff, please check the help of geotiffwrite (https://de.mathworks.com/help/map/ref/geotiffwrite.html ). It might also help to take a look at the code of GRIDobj2geotiff.
      Best regards, Wolfgang

    Caterina Samela said:
    May 4, 2017 at 1:54 pm

    Dear Wolfgang, thanks for these super-useful functions! Can you kindly suggest me the proper one to extract the main channel (e.g. the longest one) in a pre-identified river network?

      wschwanghart responded:
      May 4, 2017 at 2:09 pm

      Hi Caterina, thanks for your kind comment! trunk is the function you need.
      Best regard, Wolfgang

    Sotiris Karalis said:
    July 9, 2017 at 10:32 am

    Wolfgang Hi!
    I am going through the TTLEM_usersguide_1_intro, to see what is in there, but when i give

    p = ttlemset

    i get an error saying
    …….
    Undefined function ‘addParameter’ for input arguments of type ‘inputParser’.

    Error in ttlemset (line 160)
    addParameter(p,’TimeSpan’,2000000,@(x) isscalar(x) && x>0);

    Error in TTLEM_usersguide_1_intro (line 138)
    p = ttlemset %#ok show parameters
    ………………
    What is it that i am doing wrong?
    Thank you in advance!

    Sotiris Karalis

      wschwanghart responded:
      July 10, 2017 at 11:19 am

      Hi Sotiris, replace all calls to addParameter by addParamValue. addParamValue was replaced a couple of years ago with addParameter. Hope this works.
      Best regards, Wolfgang

        Sotiris Karalis said:
        July 11, 2017 at 12:06 pm

        Thank you Wolfgang! I followed your instructions and run all 3 simulations in TTLEM, which are very impressive i must add! Fyi i don’t see the box depicting the status of the simulation, but this is not a problem. Is it because i have MATLAB 2012b?

        Now i have a new question regarding TTbox usersguide1 and 2. In particular, when i give

        plotdz(S,DEM)
        i get:
        ………..
        Attempt to reference field of non-structure array.

        Error in STREAMobj/plotdz (line 102)
        colororderindex = mod(ax.ColorOrderIndex, size(ax.ColorOrder,1));
        ……….
        What is the problem now?

        Warm regars.
        Sotiris

    wschwanghart responded:
    July 11, 2017 at 12:15 pm

    Hi Sotiris, sorry for those problems. I guess that you downloaded topotoolbox from here: https://github.com/csdms-contrib/topotoolbox . Yet, this repository is not as frequently updated as my own repository, where this bug should be removed: https://github.com/wschwanghart/topotoolbox

    Cheers, W

      Sotiris Karalis said:
      July 12, 2017 at 7:37 am

      Hi Wolfgang, even though i downloaded from the other site, the same problem remains..
      How can i resolve it?
      Could you please give instructions? This is a very usefull function..

      Warm Regards
      Sotiris

        wschwanghart responded:
        July 12, 2017 at 8:35 am

        Hi Sotiris, ah, that seems also a problem related to an older version of MATLAB. MATLAB changed its graphics engine with version 2014b (?). With this change, axes and lines have become objects rather than handles with meaningless numbers. Let me fix this in a minute.

        wschwanghart responded:
        July 12, 2017 at 8:49 am

        Sotiris, plotdz should be able to run on versions before 2014b now. Note, however, that I do not have an old version of MATLAB to test the changes. In addition, other functions may have similar backward compatibility issues that I won’t be able to resolve.
        Cheers, Wolfgang

    Sotiris Karalis said:
    July 12, 2017 at 6:31 pm

    Thanks Wolfgang. Probably it’s time to update..
    I ll get back to you when i ll start a real world application with my data!
    Good job!
    Sotiris

    Saleh Alqahtani said:
    August 17, 2017 at 2:13 pm

    Hi,
    Thanks for the great program.
    I have tried to use the topotoolbox functions on a DSM tif file from a drainage basin I’m working on. I am trying to calculate the ksn for the basin streams but the result map shows overlapping ksn values even at very local scale. I used the STREAMobj2mapstruct function to have the ksn values generalised for 10km long segments of the stream but the map stays the same.
    I am not expert in matlab so I appreciate that the mistake might be a trivial one to avoid.
    Thanks
    Saleh

      wschwanghart responded:
      August 18, 2017 at 6:51 am

      Saleh, thanks for your comment. Without seeing the code, I am unfortunately unable to resolve this issue. However, please check the new function STREAMobj/aggregate (https://github.com/wschwanghart/topotoolbox/blob/master/%40STREAMobj/aggregate.m). Alternatively, you can also use STREAMobj/smooth with a large value of K (e.g. K=100) to smooth your ksn values along the river network.
      Best, Wolfgang

        Saleh Alqahtani said:
        August 21, 2017 at 10:13 am

        HI Wolfgang. Thanks for your reply and sorry for my late reply. I have tried it again and it worked on DEM data I got from another source but for the same region.
        Thanks
        Saleh

        Saleh Alqahtani said:
        August 24, 2017 at 10:37 am

        Hi dear Wolfgang,
        May I ask if there is a way to extract the ks and theta values for just one stream instead of all of the streams in one drainage catchment? And the same also about plotting the elevation vs distance for just one stream?
        Best, Saleh

    wschwanghart responded:
    August 24, 2017 at 11:03 am

    Hi Saleh, sure, this is possible. You just need to adjust your stream network so that it contains only one stream. You can do this interactively using the modify function:
    Sn = modify(S,’interactive’,’reach’);
    Alternatively, construct a one-stream STREAMobj as follows:
    S = STREAMobj(FD,’channelheads’,IX);
    where IX can be obtained from the channelhead coordinates x, y and the function IX = coord2ind(DEM,x,y).
    Best, Wolfgang

      Saleh Alqahtani said:
      August 25, 2017 at 10:15 am

      Brilliant.. the Sn worked very well.. Many thanks Wolfgang

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s