How to compare two Digital Elevation Models (DEMs) in R.
#-------------------------------------------------------------------------
#Creating a reproducible example
library(raster)
#simulating raster_1
f = system.file("external/test.grd", package="raster")
DEM_1 = raster(f)
#simulating raster_2
DEM_2 = DEM_1
# replacing values from raster_1 to create a new raster sample (raster_2)
DEM_2[(DEM_2>500 & DEM_2<900)] = 550
DEM_2[(DEM_2>200 & DEM_2<300)] = 500
#-------------------------------------------------------------------------
# Comparison 1 (DEM_3 resulted from subtracting DEM_2 from DEM_1)
DEM_3 = DEM_1 - DEM_2
par(mfrow=c(1,3))
plot(DEM_1, main = "DEM_1")
plot(DEM_2, main = "DEM_2")
plot(DEM_3, main = "DEM_3 = DEM_1 - DEM_2")
dev.off()
#-------------------------------------------------------------------------
#Comparison 2 (histogram)
hist(DEM_1, prob=T, main="DEM_1", xlab="")
hist(DEM_2, prob=T, main="DEM_2", xlab="")
hist(DEM_3, prob=T, main="DEM_3 = DEM_1 - DEM_2", xlab="")
par(mfrow=c(1,1))
standard_deviation = sd(c(as.matrix(DEM_3)),na.rm=T)
dev.off()
#-------------------------------------------------------------------------
#comparison 3 (RMSE)
library(hydroGOF)
DEM_1_matrix = c(as.matrix(DEM_1))
DEM_2_matrix = c(as.matrix(DEM_2))
rmse = rmse(DEM_1_matrix,DEM_2_matrix)
rmse
[1] 135.3675 # this is the root mean squared error (RMSE) result.
See @whuber's answer on Comparing two TINs created using ArcGIS for Desktop? for a theoretical insight about this issue.
One way to extract the points from adf is to open this adf file in QGIS and export it to a .xyz format and then use this file to match ur point to the point in the .xyz file
other way is to convert this adf file to a tif file using QGIS and then import this file to POSTGIS database using raster2pgsql command line tool.
this is how u import raster data (tif) to postgis
Install postgresql with postgis plugin
open command line and navigate to bin folder of postgresql normaly is it located here C:\Program Files\PostgreSQL\9.3\bin
STEP 1:
raster2pgsql -F -I -M -C "PATH of tif file with extension" public.your_tablename > your_output_file.sql
STEP 2 (in the same directory)
excute the following
psql -U postgresql_database_Username -d Database_name -W -f your_output_file.sql
your_output_file.sql is the file generated in step 1.
importing raster file to postgis is one time process n den u can use this raster table generated after importing ur tif file from the database for ur future raster queries
after this is done
u can use the postgis function (ST_Value) to get the pixel value of the raster u imported
*
SELECT ST_VALUE(e.rast, ST_SetSRID(St_MakePoint(Your_Longitude, Your_Latitude ), 4326))
FROM Your_Imported_raster_table_Name e
WHERE ST_Intersects(e.rast, ST_SetSRID(St_MakePoint(Your_Longitude, Your_Latitude), 4326));
*
Hope this will help you..
i would suggest that u go for 2nd method.
Best Answer
Band interleaved by line (BIL) files and it's associated header file (HDR) are raster format files. The PRJ file is a projection file, telling a GIS software application where in space to draw the file.
I don't know how to read the BIL file with an Android friendly library but you could use something like QGIS to convert the BIL file to another file format.
Here are some links: From ESRI, US Government info on BIL