GetDomainCoordsProj: 'GetDomainCoordsProj' collects and reprojects spatial data...

Description Usage Arguments Value See Also Examples

View source: R/visualize_domain.R

Description

Handle the projection and datum iformation associated with WRF-Hydro geo and hydro grid files.

Usage

1
GetDomainCoordsProj(file, proj4Str = "+proj=longlat +datum=WGS84")

Arguments

file

A path/name to a geo or hydro domain file.

proj4Str

the desired output projection.

Value

An sp::SpatialPoints object.

See Also

Other domain: VisualizeChanNtwk, VisualizeDomain, VisualizeSpatial

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## See the vignette "WRF Hydro Domain and Channel Visualization", for details. 
## set your test case path
## Not run: 
hydroFile<- '~/WRF_Hydro/TESTING/TEST_FILES/FRNG/2015-12-04_20:08:06.b8e1e01c4cc2/STD/DOMAIN/Fulldom_hires_netcdf_file_2015_11_20.nc'
hydroCoords <- GetDomainCoordsProj(hydroFile)
str(hydroCoords)
hydroCoords <- as.data.frame(hydroCoords)
Calculate/Plot the error of the longitude and latitidue coords in the Fulldom file
hydroCoords$latFile <- as.vector(ncdump(hydroFile,'LATITUDE', q=TRUE))
hydroCoords$lonFile <- as.vector(ncdump(hydroFile,'LONGITUDE', q=TRUE))
hydroCoords$latErr <- lat-hydroCoords$lat
hydroCoords$lonErr <- lon-hydroCoords$long
summary(hydroCoords$latErr)
summary(hydroCoords$lonErr)
theMap <- ggmap::get_map(location=c(lon=mean(hydroCoords$long)-.5,
                                    lat=mean(hydroCoords$lat))+.2, zoom = 13)
ggmap::ggmap(theMap) + geom_point(data=hydroCoords, aes(x=lonFile, y=latFile),size=1)
ggmap::ggmap(theMap) + geom_point(data=hydroCoords, aes(x=long, y=lat),size=.5)
## test for unique pairs in lat/long
testLon <- hydroCoords$long
testLat <- hydroCoords$lat
tally=list()
for(i in 1:300) {
  matches <- (testLon[(i+1):length(testLat)] == testLon[i] &
              testLat[(i+1):length(testLat)] == testLat[i]   )
  whMatch <- which(matches)+i  
  if(length(whMatch)) {
    for(j in 1:length(whMatch)) tally[[length(tally)+1]] <- c(i,whMatch)
    print(i)
    print(length(tally))
  }
}

## End(Not run) #dontrun

mccreigh/rwrfhydro documentation built on Feb. 28, 2021, 1:53 p.m.