-1

I'm new to R and I'm trying to make a pollution model in R and GIS.

I have this code:

setwd("D:/+gis/hranice")
library("foreign", lib.loc="D:/Program Files/R/R-3.1.1/library")
y <- read.csv("distancematrix.csv",header=T,sep= ",")             #load distance matrix
sub_districts <- read.dbf("ku_pl.dbf")            #load sub_district data

#Set-Up and Assumptions
length <- 3550                     #sets width of distance matrix 
width <- 9                    #sets length of distance matrix 
x <- matrix(0,length,width)       #ground level concentration (micro-g/m^3)
Q <- 1000                        #assume source strength 
s <- 9                           #assume 10 stacks per firm all at the same height
alpha <- .008                     #assumes neutral horizontal dispersion
beta <- .006                      #assumes neutral vertical dispersion
u <- 3                           #assumes constant wind speed in all directions
PM_before <- 0                    #sets initial PM Level Vector Before Intervention
PM_after <- 0                     #sets initial PM Level Vector After Intervention
PM_data <- 0                      #Sets initial value for final data
set.seed(1)                       #saves specific randomized values on next line
H <- 100    #random stack heights between 5 and 30 meters

#Gaussian Plume Model
for (j in 1:width) {
  for (i in 1:length) {
    x[i,j] <- (Q*s / (pi*(y[i,j]*alpha/((1+.0001*y[i,j])^.5)*(y[i,j]*beta/(1+.00015*y[i,j])^.5))*u))*
  (exp(-.5*(H[j]/(y[i,j]*beta/(1+.00015*y[i,j])^.5))^2))
  }
}

PM_before <- rowSums(x)*1000 #sum over all industry contributions to PM, convert from g to mg
PM_after <- .60 * PM_before #assume the treatment reduces PM to 60% original concentration
PM_data <- cbind(sub_districts,PM_before,PM_after)
write.dbf(PM_data, "ku_pl.dbf")`  

And if I run this model i get this message

Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

What is it telling to me ? It works fine with one source but not with this.

Spacedman
  • 92,590
  • 12
  • 140
  • 224
ABCD
  • 138
  • 6
  • 1
    Your code runs based on a data file we don't have. Please post the data or a minimum part of it so we have a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – Molx Mar 25 '15 at 15:59
  • I've only ever seen that error when trying to plot all-missing data - eg `plot(NA,NA)` but I see no plotting here. What line generates the error? – Spacedman Mar 25 '15 at 16:56

1 Answers1

-1

You might be dividing by zero somewhere...

 > 1/0
 [1] Inf

 > -1/0
 [1] -Inf
kpie
  • 9,588
  • 5
  • 28
  • 50