Project

General

Profile

« Previous | Next » 

Revision 1518de60

Added by Benoit Parmentier over 8 years ago

modifying gclip polygons and points function for use in the assessment

View differences:

climate/research/oregon/interpolation/global_product_assessment_part1_functions.R
208 208
  return(date_str)
209 209
}
210 210

  
211
gClip <- function(shp, bb, keep.attribs=TRUE,outDir=NULL,outSuffix=NULL){
211
gClip <- function(shp, bb, keep.attribs=TRUE,outDir=NULL,outSuffix=NULL,write=FALSE){
212 212
  #Purpose: clipping SpatialPolygonsDataFrame using another SpatialPolygonsDataFrame 
213 213
  #shp: input shapefile that we would like to clip
214 214
  #bb: input shapefile used for clipping, can be and extent raster object, matrix of coordinates 
......
269 269

  
270 270
  }
271 271
  
272
  #Writeout shapefile (default format for now)
273
  infile_new.shape <- paste("clipped_spdf",outSuffix,".shp",sep="")
274
  writeOGR(new.shape,dsn= outDir,layer= sub(".shp","",infile_new.shape), 
272
  if(write==TRUE){
273

  
274
    #Writeout shapefile (default format for now)
275
    infile_new.shape <- paste("clipped_spdf",outSuffix,".shp",sep="")
276
    writeOGR(new.shape,dsn= outDir,layer= sub(".shp","",infile_new.shape), 
275 277
           driver="ESRI Shapefile",overwrite_layer="TRUE")
278
  }
279

  
276 280
  
277 281
  return(new.shape)
278 282
}
......
349 353
  col_mfrow <- 1
350 354
  row_mfrow <- 1
351 355
  
352
  png_filename <- paste("Figure_ac_metrics_map_stations_l_",station_type_name,"_",model_name,"_",y_var_name,"_",date_processed,
356
  png_filename <- paste("Figure_ac_metrics_map_stations_location_",station_type_name,"_",model_name,"_",y_var_name,"_",date_processed,
353 357
                       "_",out_suffix,".png",sep="")
354 358
  png(filename=png_filename,
355 359
        width=col_mfrow*res_pix,height=row_mfrow*res_pix)

Also available in: Unified diff