r - How to extract specific values from a DEM (digital elevation model)? -


i'm trying calculate elevation data hiking routes, using open data (avoiding licensing constraints google).

i able read public dem of country (with 10-metres resolution) using readgdal (from package rgdal), , proj4string(mygrid) gives me:

"+proj=utm +zone=32 +datum=wgs84 +units=m +no_defs +ellps=wgs84 +towgs84=0,0,0" 

the beginning of .asc file is:

ncols         9000  nrows         8884  xllcorner     323256,181155  yllcorner     4879269,74709  cellsize      10  nodata_value  -9999  978 998 1005 1008 1012 1016 1020 1025 .....  .....  ..... 400 megabytes of elevation values ....  .....  

all need pick grid elevation data specific nodes of route, able calculate elevation gain, negative slope, min/max altitude...

i bring routes data openstreetmap, using nice package osmar, data table of route this:

    routeid nodeid  lat         lon 1   -13828  -8754   45.36743    7.753664 2   -13828  -8756   45.36762    7.753878 3   -13828  -8758   45.36782    7.754344 4   -13828  -8760   45.36794    7.754541 .... 

but i've no idea how transform latitude/longitude coordinates in dem coordinate reference system, , how bring corresponding grid values (doing sort of average of nearest points?)

all documentation i've found googling render grid maps, not extract values them.

any appreciated!

cheers, mb

p.s. second question should be: "having several grid-tiles, if route across 2 or more tiles? merge them, reference both..."

don't transform dem. transform points. dem projected on regular grid. if re-project may not be. instead, make spatial points osm data:

require(sp); coordinates(my.osm.points) <- long + lat 

then transform them coordinate reference system of dem (note may need set crs of points first. can this:

#  set pojection information points proj4string(my.osm.points) <- crs("+proj=longlat +datum=wgs84 +ellps=wgs84")  #  transform them new.points <- sptransform( my.osm.points , proj4string( mygrid ) ) 

then @ using sp::over or raster::extract values of dem @ point locations.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -