[R-sig-Geo] Odp: Unexpected elevation value when using extract() on RasterLayer
Kamil Konowalik
konno_kazuma at mailplus.pl
Wed Oct 11 07:45:22 CEST 2017
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: 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'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: nelson.wisc.edu nelson.wisc.edu #click Download a GIS grid of this data (ESRI ArcView Format) ll<-cbind(-171.7706,-13.86472) #coordinates are inland in Samoa # www.google.com www.google.com °51'53.0%22S+171°46'14.2%22W require(raster) #read hdr.adf file elev<-raster("/...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<-"/...PATH.../elevation/ x<-new("GDALReadOnlyDataset",d 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 stat.ethz.ch stat.ethz.ch
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list