[R-sig-Geo] Unexpected elevation value when using extract() on RasterLayer

Matthew Nelsen mpnelsen at gmail.com
Wed Oct 11 18:59:57 CEST 2017


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 <konno_kazuma at mailplus.pl>
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 <mpnelsen at gmail.com>
> 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
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list