# RE: [OpenMap Users] watershed area

From: Chapman, Martin <MChapman_at_sanz.com>
Date: Mon, 29 Nov 2004 22:42:27 -0700

Andrea,

First, if openmap doesn't have a DEM driver you're going to have to write one. It's similiar in concept to a DTED but the file format is different. There are a lot of open source packages that probably have a DEM driver implementation that you can look at, or, you could use an opensource DEM specific driver. I think I've seen some java ones around on the web. If not, check the usgs.gov site for links to one.

A DEM basically has an upper left point, an x-scaling and a y-scaling. Then it has a grid of numbers called "posts" that are the elevation values in feet or meters. The post values are either float or short (i think, see usgs eros data center home page for file spec). It also has a projection id and a few other things in the header. In order to plot the data on a map you have to interpolate the lat/lon of the elevation value based on the upper left point and the x and y scaling. In other words, if you want to plot cell (2, 2) of the elevation grid then your lon = UL.Lon + (XScale * 2). I'm not sure if you need to determine how many degrees longitude for the latitude but if you do that code is on NIMA's home page in the Nautical calculator section.

Second, This may be way off, but I would think the following strategy "might" work for determining watershed area:

1. Load the elevation values (posts) from a DEM file into a grid class you make that can hold a 2D array of Point objects. The Point class should be able to hold a lat, lon, and an elevation value (You could subclass the OMPoint class if the DTED layer didn't already have a class that did that and call it OMElevationPoint or something).

2. Loop though each Point in your grid class and calculate the lat/lon for that elevation point using the formula listed above.

3. Loop through the points again, but this time for every elevation that was less than a given height (your water level) make that value equal your height value.

4. Loop through again and any point that has an elevation greater than your water level, set to null.

Now your grid cells will be grouped together in one or more groups of cells that are your water level. All other values should be null.

5. Loop though your points again, this time setting all interior points to null (points that don't have any adjacent null points) to null. You'll probably have to make a new grid in this operation so as not to set any exterior points to null as you loop.

6. Now, your grid should have non-null cells that create one or more polylines when connected. Loop through one more time and create a set of OMPolygons from cells that have adjacent non-null values.

7. Finally, calculate the area of each polygon.

Needless to say, some of the loop operations listed above can be condensed into less iterations, but I listed them seperately for the sake of clarity.

That is my best guess at the moment. Commit it back to source if you write it please...I'll use it...and let me know if you come up with a better strategy.

Thanks,
Martin

-----Original Message-----
Sent: Mon 11/29/2004 5:12 PM
To: openmap-users_at_bbn.com
Cc:
Subject: [OpenMap Users] watershed area
Hi Don,
The algorithms to calculate watershed area are based on elevation data. I
would need a grid of elevation data to perform slope, flow paths and
draining area calculations.

Cheers,
Andrea

-----Messaggio originale-----
Da: owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com] Per
conto di Don Dietrick
Inviato: luned́ 29 novembre 2004 22.03
A: Andrea Leone
Cc: openmap-users_at_bbn.com
Oggetto: Re: [OpenMap Users] FW: distance along set of lines

Hi Andrea,

What's your criteria for designating a watershed area based on
elevation data?

Just so you know, the TerrainLayer uses DTED data instead of DEM, but
that should be OK, too.

- Don

On Nov 28, 2004, at 11:45 AM, Andrea Leone wrote:

> Hi people,
>
> Does somebody have some idea on how to delineate watershed areas using
> DEM data in OpenMap.
>
> I guess that the Terrain layer could be a good starting point.
>
>
>
>
>
> Thank you,
>
> Cheers, Andrea.
>
>
>
>
>
>
>

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

```--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe
openmap-users"]
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
```
Received on Tue Nov 30 2004 - 00:44:08 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:06 EDT