I'm a software engineer at CivicActions and am doing some research on
behalf of Conservation Strategy Fund for a tool which will be
available to general public to calculate data about an arbitrary
number of proposed hydro-electric power stations.
The idea is that the tool will accept a line representing the dam wall
(which is probably imprecise), and an elevation of the surface of the
reservoir. The tool will then accurately find the line representing
the dam wall (making the assumption that there is only one dam wall
and that it is approximately straight) and use SRTM3 and/or GEOTOPO30
data to "follow a contour line" and find the approximate polygon that
most accurately represents the surface of the reservoir. From this,
the tool can make estimates about the volume of the proposed
reservoir, the bio-mass of the vegetation that will be inundated in
the reservoir and the environmental costs.
Geoname's SRTM web service
(http://ws.geonames.org/srtm3?lat=-1.086809&lng=-80.134964) provides
the data in an appropriate and accessible format, however the
algorithm will need to make thousands of sequential requests and would
take days to process one reservoir if this data is only available as a
web service. We would need to have a service similar to
ws.geonames.org/srtm3 available on the same machine as the algorithm
that finds the polygon.
How might I go about re-creating this service on our own machines?
Are there specialists who would be able to do this for us in a more
efficient manner? Who should I contact to get an estimate?
Currently we don't have funding but are in the process of applying for
a grant from Google and are confident that we have a good chance at
winning it. This aspect of the system is currently the highest-risk
part and makes it difficult to budget the project and know what size
grant we should request.
I have reviewed the SRTM data at
ftp://e0srp01u.ecs.nasa.gov/srtm/version2/, and my first steps, if we
can not find someone more experienced in this domain to do it for us,
would be to write code that parses this data into a Postres or MySQL
database with 3 indexed columns; latitude, longitude, elevation. Then
I could then query the data for pixels in a containing box at the
specified elevation +/- 100m, or find the line representing the edge
of the lake by interpolating the elevations of neighbouring pixels and
finding the direction which gives the targeted elevation.
I'm sure that this, parts of this or similar problems have been solved
before and am looking to avoid re-inventing the wheel. Please let me
know of any services, individuals or resources that may be of value to
us.
Thanks,
Bevan/
--
Changing the world, one node at a time | CivicActions | http://CivicActions.com
Drupal, Usability, Open Source, Tech | http://Drupal.geek.nz |
http://Twitter.com/BevanR
Gtalk be...@civicactions.net | YIM rudgy_m_nz | AIM b.rudge | skype b.rudge
Thanks,
Bevan/
Thanks,
Bevan/
On Tue, Dec 9, 2008 at 3:14 PM, Bevan Rudge <b.r...@gmail.com> wrote:
>> How might I go about re-creating this service on our own machines?
>> Are there specialists who would be able to do this for us in a more
>> efficient manner? Who should I contact to get an estimate?
I've re-created the SRTM elevation look-up on my machine, using the raw
SRTM binary files and PHP. The files take up quite a bit of disk space,
but the time taken to find the elevation of a point is pretty small. Since
the data is well-organised in the files, it's very quick to work out which
file to read, and which part of it to read, then to get the elevation
value. I don't think putting it in a DB will help, unless you want to run
queries more complicated than "how high is this point?".
I don't have a contour-generating algorithm written, but might have some
useful pointers.
HTH,
Anthony
--
www.fonant.com - Quality web sites
> I've re-created the SRTM elevation look-up on my machine, using the raw
> SRTM binary files and PHP. The files take up quite a bit of disk space,
> but the time taken to find the elevation of a point is pretty small. Since
> the data is well-organised in the files, it's very quick to work out which
> file to read, and which part of it to read, then to get the elevation
> value.
Would you be willing to share this code on a GPL license or otherwise?
The fact it's PHP is a bonus for us.
> I don't think putting it in a DB will help, unless you want to run
> queries more complicated than "how high is this point?".
It's likely that it will be convenient to query the data in other
ways, such as; "what points in a containing box are at elevation X +/-
Y?" And "what are the coordinates and elevations of the Z points
closest to point W?" where W is an arbitrary point not where an SRTM
data point is.
Thanks!
> Would you be willing to share this code on a GPL license or otherwise?
> The fact it's PHP is a bonus for us.
Here's my PHP class to extract elevation data from the (uncompressed) SRTM
files:
<?php
class SrtmReader
{
public static function heightForPoint(GeoPoint $point)
{
$latinput = $point->latitude;
$lnginput = $point->longitude;
$lat_degree = floor($latinput);
$lng_degree = floor($lnginput);
$lat_letter = ($latinput>=0)?'N':'S';
$lng_letter = ($lnginput>=0)?'E':'W';
$lng_tilenum = abs($lng_degree);
$lat_tilenum = abs($lat_degree);
$filename =
$lat_letter.sprintf('%02d',$lat_tilenum).$lng_letter.sprintf('%03d',$lng_tilenum).".hgt";
$dirname = substr($filename,0,2);
$filename = '/home/sites/dem/'.$dirname.'/'.$filename;
//echo $filename;
if (!file_exists($filename)) return;
$col = round(($lnginput-$lng_degree)*1200);
$row = 1200 - round(($latinput-$lat_degree)*1200);
$fp = fopen($filename,'r');
fseek($fp,(2402*$row)+($col*2));
$h = fread($fp,2);
$heights = unpack('n',$h); // 'n' returns unsigned short (always
16 bit, big endian byte order)
$height = $heights[1]; // result of unpack() indexes from 1,
not zero.
if ($height>32767) $height -= 65536; // make signed
if ($height==-32768) return;
return $height;
}
}
?>
The function returns NULL if the SRTM file for the location doesn't
exists, or if the height for the point is -32768m (e.g. no data).
Please feel free to make use of it, tidy it, find bugs and fix them, etc :)
...and let me know of any useful changes! And perhaps mention
ajcar...@fonant.com in the credits somewhere?
>> I don't think putting it in a DB will help, unless you want to run
>> queries more complicated than "how high is this point?".
>
> It's likely that it will be convenient to query the data in other
> ways, such as; "what points in a containing box are at elevation X +/-
> Y?" And "what are the coordinates and elevations of the Z points
> closest to point W?" where W is an arbitrary point not where an SRTM
> data point is.
In which case a DB may well be useful. There are an awfully large number
of data points though!
Cheers!
Not sure, but they tend to appear in mountainous regions, I think where a
peak has hidden a valley point from the Space Shuttle's radar.
> What I was trying to ask is what is the format of the GeoPoint $point?
>> From looking at the code I assume that it is simply an object with two
> properties, latitude and longitude, such as the Google Maps API
> GLatLng object. Is this assumption correct?
Yes :)
Sorry, have been busy over the last few days, but I was planning to answer
your question at some point...
I should probably re-write the function to just have $latitude and
$longitude arguments, which would be usable without having to construct
and object first. This is just how it is in my code, where I like to use
objects to get some encapsulation and argument type-checking in PHP.
There is no interpolation :)