[R-sig-Geo] strange srtm3 query in geonames package
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Sun Nov 22 20:02:53 CET 2009
On Sun, Nov 22, 2009 at 6:23 PM, Michael Denslow
<michael.denslow at gmail.com> wrote:
> Dear r-sig-geo and Barry,
>
> I am getting a strange value when doing a query using the function
> GNsrtm3 in the geonames package.
> Here is the code.
>
> library(geonames)
> GNsrtm3(34.63874,-79.10111) # outside Lumberton North Carolina USA!
>
>
> srtm3 lng lat
> 1 -32768 -79.10111 34.63874
>
> Warning message:
> In readLines(u) :
> incomplete final line found on
> 'http://ws.geonames.org/srtm3JSON?lat=34.63874&lng=-79.10111'
>
>
> I think the elevation value should be around 47 meters. The geonames
> website says 'ocean areas have been masked as "no data" and have been
> assigned a value of -32768'.
> http://www.geonames.org/export/web-services.html#srtm3
> I tried adjusting the lat, long values to query some nearby cells but
> I still get -32768.
>
> Are these kinds of errors common in this dataset? Any suggestions?
> I am would actually prefer to get an average elevation for the county
> (Robeson) but am settling for the county centroid at this point.
I don't really know the details of the srtm3 data set, but I do see
that geonames has two other DEM datasets - ASTER and GTOPO30. There's
a function for GTOPO30 in geonames, but not ASTER. It's easy enough to
write though:
> GNaster=function(lat,lng){return(as.data.frame(geonames:::getJson("astergdemJSON",list(lat=lat,lng=lng))))}
and I may include it in a new release (as well as getting rid of
those end-of-line warnings). These two services agree with themselves
and with you pretty well for your test location:
> GNgtopo30(34.63874,-79.10111)
gtopo30 lng lat
1 46 -79.10111 34.63874
> GNaster(34.63874,-79.10111)
astergdem lng lat
1 47 -79.10111 34.63874
For an 'average' elevation you might be better off sampling many
locations over your polygon.
Barry
More information about the R-sig-Geo
mailing list