Unexpected elevation value when using extract() on RasterLayer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
mn
Reply | Threaded
Open this post in threaded view
|

Unexpected elevation value when using extract() on RasterLayer

mn
Hi Everyone,

I'm fairly new to using R to analyze geo data and am getting some
unexpected values when I try to extract elevation data from a RasterLayer
using lat/long.  I've downloaded some global elevation data (ESRI ArcView
Format) from here:

http://nelson.wisc.edu/sage/data-and-models/atlas/maps.php?datasetid=28&includerelatedlinks=1&dataset=28

And have read it in using raster and rgdal.  I then am trying to extract()
the elevation at specific lat/longs and have been getting some strange
values.  For instance, I try to get the elevation for a point in Samoa
(-13.86472, -171.77.06), and an elevation of -129m is returned, which is
incorrect.  Any idea why this might be?  I'm not sure where I'm going wrong
(or if this specific RasterLayer does not deal well with smaller land
masses and truly does say it is -129m)? I've tried it two different ways
(below).

Thanks very much for any help.

All the best,

-Matt.


#download elevation data from:
http://nelson.wisc.edu/sage/data-and-models/atlas/maps.php?datasetid=28&includerelatedlinks=1&dataset=28

#click Download a GIS grid of this data (ESRI ArcView Format)


ll<-cbind(-171.7706,-13.86472)

#coordinates are inland in Samoa

#https://www.google.com/maps/place/13
°51'53.0%22S+171°46'14.2%22W/@-13.86472,-171.8034302,13z/data=!4m5!3m4!1s0x0:0x0!8m2!3d-13.86472!4d-171.7706


require(raster)

#read hdr.adf file

elev<-raster("/...PATH.../elevation/elevation/hdr.adf")

elev


#class       : RasterLayer

#dimensions  : 2160, 4320, 9331200  (nrow, ncol, ncell)

#resolution  : 0.08333333, 0.08333333  (x, y)

#extent      : -180, 180, -90, 89.99999  (xmin, xmax, ymin, ymax)

#coord. ref. : NA

#data source :
/...PATH.../atlas_of_the_biosphere_13sep2017/elevation/elevation/hdr.adf

#names       : hdr

#values      : -10376, 7320  (min, max)

#attributes  :

#           ID COUNT

# from: -10376     1

# to  :   7320     1



extract(elev,ll)

#-129


####Alternatively, read in...

require(rgdal)

#from
https://gis.stackexchange.com/questions/132403/how-to-read-adf-files-into-r

dpath<-"/...PATH.../elevation/elevation"

x<-new("GDALReadOnlyDataset",dpath)

getDriver(x)

#An object of class "GDALDriver"

#Slot "handle":

#<pointer: 0x60000032ac80>


getDriverLongName(getDriver(x))

#[1] "Arc/Info Binary Grid"


xx<-asSGDF_GROD(x)

elevation <- raster(xx)

elevation


#class       : RasterLayer

#dimensions  : 2160, 4320, 9331200  (nrow, ncol, ncell)

#resolution  : 0.08333333, 0.08333333  (x, y)

#extent      : -180, 180, -90, 89.99999  (xmin, xmax, ymin, ymax)

#coord. ref. : NA

#data source : in memory

#names       : band1

#values      : -10376, 7320  (min, max)


extract(elevation,ll)


#-129

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Odp: Unexpected elevation value when using extract() on RasterLayer

Kamil Konowalik
Hi Matt,  the result
you got is correct according to your dataset. You can check it quickly for
example in QGis. You need to change the source - the map you are using is in a
very coarse resolution (you can see its accurracy by looking at the
highest point which should be around 8848 m and in your map is 7320 m). You
should look for a more detailed map like for example SRTM data (I think there are multiple sources to download it). Otherwise you may also try
&#34;elevatr&#34; package in R.   Good luck!  Kamil     Dnia 10 października 2017 22:04 Matthew Nelsen &lt;[hidden email]&gt; napisał(a):  Hi Everyone,   I&#39;m fairly new to using R to analyze geo data and am getting some  unexpected values when I try to extract elevation data from a RasterLayer  using lat/long.  I&#39;ve downloaded some global elevation data (ESRI ArcView  Format) from here:   nelson.wisc.edu nelson.wisc.edu   And have read it in using raster and rgdal.  I then am trying to extract()  the elevation at specific lat/longs and have been getting some strange  values.  For instance, I try to get the elevation for a point in Samoa  (-13.86472, -171.77.06), and an elevation of -129m is returned, which is  incorrect.  Any idea why this might be?  I&#39;m not sure where I&#39;m going wrong  (or if this specific RasterLayer does not deal well with smaller land  masses and truly does say it is -129m)? I&#39;ve tried it two different ways  (below).   Thanks very much for any help.   All the best,   -Matt.    #download elevation data from:  nelson.wisc.edu nelson.wisc.edu   #click Download a GIS grid of this data (ESRI ArcView Format)    ll&lt;-cbind(-171.7706,-13.86472)   #coordinates are inland in Samoa   # www.google.com www.google.com  °51&#39;53.0%22S+171°46&#39;14.2%22W    require(raster)   #read hdr.adf file   elev&lt;-raster(&#34;/...PATH.../elev   elev    #class       : RasterLayer   #dimensions  : 2160, 4320, 9331200  (nrow, ncol, ncell)   #resolution  : 0.08333333, 0.08333333  (x, y)   #extent      : -180, 180, -90, 89.99999  (xmin, xmax, ymin, ymax)   #coord. ref. : NA   #data source :  /...PATH.../atlas_of_the_biosp   #names       : hdr   #values      : -10376, 7320  (min, max)   #attributes  :   #           ID COUNT   # from: -10376     1   # to  :   7320     1     extract(elev,ll)   #-129    ####Alternatively, read in...   require(rgdal)   #from  gis.stackexchange.com gis.stackexchange.com   dpath&lt;-&#34;/...PATH.../elevation/   x&lt;-new(&#34;GDALReadOnlyDataset&#34;,d   getDriver(x)   #An object of class &#34;GDALDriver&#34;   #Slot &#34;handle&#34;:   #&lt;pointer: 0x60000032ac80&gt;    getDriverLongName(getDriver(x)   #[1] &#34;Arc/Info Binary Grid&#34;    xx&lt;-asSGDF_GROD(x)   elevation &lt;- raster(xx)   elevation    #class       : RasterLayer   #dimensions  : 2160, 4320, 9331200  (nrow, ncol, ncell)   #resolution  : 0.08333333, 0.08333333  (x, y)   #extent      : -180, 180, -90, 89.99999  (xmin, xmax, ymin, ymax)   #coord. ref. : NA   #data source : in memory   #names       : band1   #values      : -10376, 7320  (min, max)    extract(elevation,ll)    #-129   [[alternative HTML version deleted]]   ______________________________  R-sig-Geo mailing list   [hidden email]  stat.ethz.ch stat.ethz.ch

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
mn
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected elevation value when using extract() on RasterLayer

mn
Thanks a lot, Kamil!  That makes a lot of sense.  I really appreciate your
help!

Best,

-Matt.

On Wed, Oct 11, 2017 at 12:45 AM, Kamil Konowalik <[hidden email]>
wrote:

> Hi Matt,
>
> the result you got is correct according to your dataset. You can check it
> quickly for example in QGis. You need to change the source - the map you
> are using is in a very coarse resolution (you can see its accurracy by
> looking at the highest point which should be around 8848 m and in your map
> is 7320 m). You should look for a more detailed map like for example SRTM
> data (I think there are multiple sources to download it). Otherwise you may
> also try "elevatr" package in R.
>
> Good luck!
>
> Kamil
>
>
>
> Dnia 10 października 2017 22:04 Matthew Nelsen <[hidden email]>
> napisał(a):
>
> Hi Everyone,
>
> I'm fairly new to using R to analyze geo data and am getting some
> unexpected values when I try to extract elevation data from a RasterLayer
> using lat/long.  I've downloaded some global elevation data (ESRI ArcView
> Format) from here:
>
> http://nelson.wisc.edu/sage/data-and-models/atlas/maps.php?datasetid=28&
> includerelatedlinks=1&dataset=28
>
> And have read it in using raster and rgdal.  I then am trying to extract()
> the elevation at specific lat/longs and have been getting some strange
> values.  For instance, I try to get the elevation for a point in Samoa
> (-13.86472, -171.77.06), and an elevation of -129m is returned, which is
> incorrect.  Any idea why this might be?  I'm not sure where I'm going wrong
> (or if this specific RasterLayer does not deal well with smaller land
> masses and truly does say it is -129m)? I've tried it two different ways
> (below).
>
> Thanks very much for any help.
>
> All the best,
>
> -Matt.
>
>
> #download elevation data from:
> http://nelson.wisc.edu/sage/data-and-models/atlas/maps.php?datasetid=28&
> includerelatedlinks=1&dataset=28
>
> #click Download a GIS grid of this data (ESRI ArcView Format)
>
>
> ll<-cbind(-171.7706,-13.86472)
>
> #coordinates are inland in Samoa
>
> #https://www.google.com/maps/place/13
> °51'53.0%22S+171°46'14.2%22W/@-13.86472,-171.8034302,13z/
> data=!4m5!3m4!1s0x0:0x0!8m2!3d-13.86472!4d-171.7706
>
>
> require(raster)
>
> #read hdr.adf file
>
> elev<-raster("/...PATH.../elevation/elevation/hdr.adf")
>
> elev
>
>
> #class       : RasterLayer
>
> #dimensions  : 2160, 4320, 9331200  (nrow, ncol, ncell)
>
> #resolution  : 0.08333333, 0.08333333  (x, y)
>
> #extent      : -180, 180, -90, 89.99999  (xmin, xmax, ymin, ymax)
>
> #coord. ref. : NA
>
> #data source :
> /...PATH.../atlas_of_the_biosphere_13sep2017/elevation/elevation/hdr.adf
>
> #names       : hdr
>
> #values      : -10376, 7320  (min, max)
>
> #attributes  :
>
> #           ID COUNT
>
> # from: -10376     1
>
> # to  :   7320     1
>
>
>
> extract(elev,ll)
>
> #-129
>
>
> ####Alternatively, read in...
>
> require(rgdal)
>
> #from
> https://gis.stackexchange.com/questions/132403/how-to-read-
> adf-files-into-r
>
> dpath<-"/...PATH.../elevation/elevation"
>
> x<-new("GDALReadOnlyDataset",dpath)
>
> getDriver(x)
>
> #An object of class "GDALDriver"
>
> #Slot "handle":
>
> #<pointer: 0x60000032ac80>
>
>
> getDriverLongName(getDriver(x))
>
> #[1] "Arc/Info Binary Grid"
>
>
> xx<-asSGDF_GROD(x)
>
> elevation <- raster(xx)
>
> elevation
>
>
> #class       : RasterLayer
>
> #dimensions  : 2160, 4320, 9331200  (nrow, ncol, ncell)
>
> #resolution  : 0.08333333, 0.08333333  (x, y)
>
> #extent      : -180, 180, -90, 89.99999  (xmin, xmax, ymin, ymax)
>
> #coord. ref. : NA
>
> #data source : in memory
>
> #names       : band1
>
> #values      : -10376, 7320  (min, max)
>
>
> extract(elevation,ll)
>
>
> #-129
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo