ggplot2 - Getting Error while plotting contour map as (Error in if (any(h <= 0)) stop("bandwidths must be strictly positive") : in R -


for below data

       > head(df)        date longitude latitude elevation max.temperature min.temperature precipitation     wind relative.humidity    solar  ro      1 2014-07-01   77.1875  7.96184     -9999          27.725          26.673  16.115560560 8.395378         0.8132272 23.08192 yes      2 2014-07-02   77.1875  7.96184     -9999          27.931          26.897   0.700378560 8.062267         0.8074675 21.48473 yes      3 2014-07-03   77.1875  7.96184     -9999          28.179          26.686   0.000000000 9.465022         0.8107901 24.14900  no      4 2014-07-04   77.1875  7.96184     -9999          27.657          26.545   0.003433226 9.397203         0.8195020 23.42036 yes      5 2014-07-05   77.1875  7.96184     -9999          27.157          26.490   1.541518560 8.903047         0.8385059 23.90545 yes      6 2014-07-06   77.1875  7.96184     -9999          27.308          26.481   0.000000000 8.617348         0.8205267 23.96318  no 

i have created map using ggmap

     > precip_map<-get_map(location="india",maptype="satellite",zoom=12)          map url : http://maps.googleapis.com/maps/api/staticmap?center=india&zoom=12&size=640x640&scale=2&maptype=satellite&language=en-en&sensor=false       > ggmap(precip_map, extent = "device") + geom_point(aes(x = longitude, y = latitude), colour = "red",       +     alpha = 0.1, size = 2, data = df)       warning message:     in loop_apply(n, do.ply) :     removed 1106 rows containing missing values (geom_point). 

drawn contour map

    > ggmap(precip_map, extent = "device") + geom_density2d(data = df,      +     aes(x = longitude, y = latitude), size = 0.3) + stat_density2d(data = df,      +     aes(x = longitude, y = latitude, fill = ..level.., alpha = ..level..), size = 0.01,      +     bins = 16, geom = "polygon") + scale_fill_gradient(low = "green", high = "red",      +     guide = false) + scale_alpha(range = c(0, 0.3), guide = false)       error in if (any(h <= 0)) stop("bandwidths must strictly positive") :       missing value true/false needed      error in if (any(h <= 0)) stop("bandwidths must strictly positive") :       missing value true/false needed      in addition: warning message:      in loop_apply(n, do.ply) :      removed 1106 rows containing non-finite values (stat_density2d).      warning message:      in loop_apply(n, do.ply) :      removed 1106 rows containing non-finite values (stat_density2d). 

i dont know lacking.. new mapping.. please assist me. also, want plot df$precipitation in contour map.

the lat, long values same across entire dataset. hence, variance in both lat , long direction zero, bandwidth kernel density estimate (kde) can't calculated.

hence, getting error bandwidths must strictly positive.

for calculating 2-d kdes, variance in both x , y direction need positive. getting error twice in case variance in both directions 0.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -