Here is one way to calculate the slope of a stream (and long profile) from a coarse DEM.
(1) If the DEM is huge, clip it to only the area of interest, to speed up the processing. You can do this by creating a polygon outlining the area, adding it to the map, and then using extract by mask (Spatial Analyst, Extraction, Extract by Mask).
(2) It may help to visualize things by making a Hillshade.
(3) Under Spatial Analyst, Hydrology, there are three steps.
(a) Fill
(b) Flow direction
(c) Flow accumulation
(4) Now you want to extract the stream by choosing an upstream point, then selecting all points with a flow accumulation greater than that value, using the conditional to turn the map to 0s and 1s to delineate the stream, and then turn that stream into a vector.
Map algebra, Single Output Map
Conditional
Hydrology
Stream to feature (may be optional and affect choice in Step 5)
(5) Select equally spaced points along this line either by using Hawth’s tools / Geospatial Modeling Environment or this previous post.
(6) Extract Values to Points, Export data
(7) You can open the .dbf in Excel or Gnumeric to inspect the slope.
There’s also this:
Tarboton, D. G., R. L. Bras, and I. Rodriguez-Iturbe. 1991. On the Extraction of Channel Networks from Digital Elevation Data. Hydrological Processes. 5: 81-100.
Monday, October 25, 2010
Monday, October 18, 2010
macro in perl
This is one way to write a macro in perl.
Useful if you want to use perl to manipulate files in the directory, and then run sac commands on them. The sac is run all at once after the if/elsif statements are completed.
macro: A sequence of commands stored for later use in an application
# count number of files in directory
$dir = '.';
@files = <$dir/*>;
$count = @files;
print "numfiles: $count \n";
#######################
# to run sac commands, write to sac macro and run
open(scratch1,'>sacmacro');
# set initial counter
$x = 1;
foreach $fn (<*BHZ*.SAC>){
if ($x==1){
$fnout=$fn . '.merge';
print scratch1 "r $fn \n";
print "read first file: $fn \n";
$x++;
} elsif ($x < $count) {
print scratch1 "merge $fn \n";
print "merge $fn \n";
$x++;
} elsif ($x == $count) {
print scratch1 "merge $fn \n";
print scratch1 "w $fnout \n";
print "merge $fn \n";
}
} # ends the foreach
close(scratch1);
# now run the sac macro
# within the ` `, until EOF, all lines are executed in sac
`sac << EOF
m sacmacro
q
EOF`;
Useful if you want to use perl to manipulate files in the directory, and then run sac commands on them. The sac is run all at once after the if/elsif statements are completed.
macro: A sequence of commands stored for later use in an application
# count number of files in directory
$dir = '.';
@files = <$dir/*>;
$count = @files;
print "numfiles: $count \n";
#######################
# to run sac commands, write to sac macro and run
open(scratch1,'>sacmacro');
# set initial counter
$x = 1;
foreach $fn (<*BHZ*.SAC>){
if ($x==1){
$fnout=$fn . '.merge';
print scratch1 "r $fn \n";
print "read first file: $fn \n";
$x++;
} elsif ($x < $count) {
print scratch1 "merge $fn \n";
print "merge $fn \n";
$x++;
} elsif ($x == $count) {
print scratch1 "merge $fn \n";
print scratch1 "w $fnout \n";
print "merge $fn \n";
}
} # ends the foreach
close(scratch1);
# now run the sac macro
# within the ` `, until EOF, all lines are executed in sac
`sac << EOF
m sacmacro
q
EOF`;
Wednesday, October 13, 2010
Clip a Raster to a polygon - GIS
Make a new polygon with the shape you want.
Toolbox:
Data Management Tools>Raster>Raster Processing>Clip
Your raster in the "input raster"
Your polygon is the Output Extent
(check the "Use Input Features for Clipping Geometry (Optional)" box)
Toolbox:
Data Management Tools>Raster>Raster Processing>Clip
Your raster in the "input raster"
Your polygon is the Output Extent
(check the "Use Input Features for Clipping Geometry (Optional)" box)
signal processing
spectrogram
h = figure;
Nwin=2048;
Twin=Nwin*dt;
[dum,f,t,p] = spectrogram(y,Nwin,0,[],1/dt,'yaxis');
surf(t,f,10*log10(abs(p)),'EdgeColor','none');
periodogram
making an envelope
envelope
downsample
upsample
diff
h = figure;
Nwin=2048;
Twin=Nwin*dt;
[dum,f,t,p] = spectrogram(y,Nwin,0,[],1/dt,'yaxis');
surf(t,f,10*log10(abs(p)),'EdgeColor','none');
periodogram
making an envelope
envelope
downsample
upsample
diff
Labels:
matlab
Tuesday, October 12, 2010
ftp-ing things
some things that i forget:
lcd: change local directory
prompt: turn off interactive prompting (if you want to mget everything but not be asked every time)
mget: get things and put them in the local directory
if not using the command line i like fileziilla
lcd: change local directory
prompt: turn off interactive prompting (if you want to mget everything but not be asked every time)
mget: get things and put them in the local directory
if not using the command line i like fileziilla
Tuesday, October 5, 2010
symbolic/soft links
in unix,
ln -s [directory or file]
to point to a directory or file and have it show up in the directory listing but not have the files copied there.
useful if you have files in multiple places (data folders, etc.) but you want them to all show up in one place.
ln -s [directory or file]
to point to a directory or file and have it show up in the directory listing but not have the files copied there.
useful if you have files in multiple places (data folders, etc.) but you want them to all show up in one place.
Friday, October 1, 2010
mac vs. pc, matlab version
There are a bunch of reasons why a matlab script written for a pc might not work on mac and vice versa. Here are some examples (some (most) content contributed from loopy):
1. dir function to display directory listing (like ls in unix)
On a pc, you'll get this:
>> dir
. .. pathdef.m
. stands for "this directory" and .. stands for "directory above"
As far as I know, mac does not do this, but just starts with the regular file names. A lot of times I want to cycle though files in a directory, so I'll create an array with all of the file names, populating it with dir. On my pc, I start at n=3 to skip . and .. but on a mac it should start at n=1. Or I should write some better code that just skips . and ..
2. for some reason my mac version never runs out of memory, whereas on the pc some of my scripts always run out of memory. same computer hardware, but the software handles memory differently.
3. folder / \ are different, and sometimes it cares, sometimes it doesn't.
4. mac can't write to excel files - there might be some individually written codes out there to handle this. [note: ugh who would write to .xls?]
5. writing pdfs in pc usually makes them sideways, or 90 degrees off, the mac version.
If there are any others out there please post.
1. dir function to display directory listing (like ls in unix)
On a pc, you'll get this:
>> dir
. .. pathdef.m
. stands for "this directory" and .. stands for "directory above"
As far as I know, mac does not do this, but just starts with the regular file names. A lot of times I want to cycle though files in a directory, so I'll create an array with all of the file names, populating it with dir. On my pc, I start at n=3 to skip . and .. but on a mac it should start at n=1. Or I should write some better code that just skips . and ..
2. for some reason my mac version never runs out of memory, whereas on the pc some of my scripts always run out of memory. same computer hardware, but the software handles memory differently.
3. folder / \ are different, and sometimes it cares, sometimes it doesn't.
4. mac can't write to excel files - there might be some individually written codes out there to handle this. [note: ugh who would write to .xls?]
5. writing pdfs in pc usually makes them sideways, or 90 degrees off, the mac version.
If there are any others out there please post.
Labels:
matlab
Subscribe to:
Posts (Atom)