0

我有一个 SpatialPolygonsDataFrame 对象(polUTM),其中包含每个纬度/经度位置的值。我想在绘图上对每个配色方案的值进行颜色编码。到目前为止,这是我的对象和代码:

polUTM is...
class : SpatialPolygonsDataFrame 
features : 6278 
extent   : 709.9431, 2785.146, 3068.771, 4119.979  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=14 +datum=WGS84 +units=km +no_defs +ellps=WGS84 +towgs84=0,0,0 
variables: 1
names    : layer 
min values  : 35 
max values  : 45 

minDbzValue = 35    #yellow; 40 - gold; 45 - orange; 50 - red; 55 - med red; 60 - dk red
ncolors = 7
colors = brewer.pal(n = ncolors, name="Spectral")
colorRanges = 65 - cumsum(rep_len(1,ncolors))*5
plot( polUTM )

它将来自 polUTM 的数据放置在地图上正确的位置,其值 v = f( lon, lat ) 为 35、40、45 dBZ 作为颜色编码的点。

为这个增量添加了代码 (FWIW)。

xmnValue = pixelToLonFxn( ext.rr@xmin, coeff ) 
xmxValue = pixelToLonFxn( ext.rr@xmax, coeff ) 
ymnValue = pixelToLatFxn( ext.rr@ymax, coeff )
ymxValue = pixelToLatFxn( ext.rr@ymin, coeff )
rr2 = raster(nrows=nrow(imageData ), ncols=ncol(imageData ), xmn=xmnValue, xmx=xmxValue, ymn=ymnValue, ymx=ymxValue )
values( rr2 ) = (values( imageData ) - 7 ) * 5
rr2[rr2<minDbzValue]  <- NA
pol < - rasterToPolygons(rr2, fun=function(x){ x >= minDbzValue } )
pol2 = spTransform( pol, "+proj=utm +zone=14 +datum=WGS84 +units=km" )
ptsUTM = SpatialPoints( pol2 )
coords = ptsUTM@coords
n = length( pol2@data$layer )
wxData = data.frame( x = numeric( n ), y = numeric( n ), z = numeric( n ),  c = character( n ), stringsAsFactors = FALSE )
wxData$x = coords[,1]
wxData$y = coords[,2]
wxData$z = pol2@data$layer
wxData$c = colors[ match( wxData$z, colorRanges ) ]
xmnValue = pixelToLonFxn( ext.rr@xmin, coeff ) 
xmxValue = pixelToLonFxn( ext.rr@xmax, coeff ) 
ymnValue = pixelToLatFxn( ext.rr@ymax, coeff )
ymxValue = pixelToLatFxn( ext.rr@ymin, coeff )
rr2 = raster(nrows=nrow(imageData ), ncols=ncol(imageData ), xmn=xmnValue, xmx=xmxValue, ymn=ymnValue, ymx=ymxValue )
values( rr2 ) = (values( imageData ) - 7 ) * 5
rr2[rr2<minDbzValue]  <- NA 
pol <- rasterToPolygons(rr2, fun=function(x){ x >= minDbzValue } )
pol2 = spTransform( pol, "+proj=utm +zone=14 +datum=WGS84 +units=km" )
ptsUTM = SpatialPoints( pol2 )
coords = ptsUTM@coords
n = length( pol2@data$layer )
wxData = data.frame( x = numeric( n ), y = numeric( n ), z = numeric( n ), c = character( n ), stringsAsFactors = FALSE )
wxData$x = coords[,1]
wxData$y = coords[,2]
wxData$z = pol2@data$layer
wxData$c = colors[ match( wxData$z, colorRanges ) ]

CONUS 蜂窝,多普勒 wx 雷达 (35-45 dBZ),飞行(BOS 到 ATL)

4

0 回答 0