R/rangeFiles-methods.R

Defines functions selectShpFiles

Documented in selectShpFiles

setGeneric("rangeFiles", function(object, ...)   					standardGeneric("rangeFiles") )


setMethod("rangeFiles",  
		signature = "rangeFiles", 
		definition = function(object, ...){
		dir.list = list.files(object@dir, recursive = TRUE, full.names = TRUE, pattern = ".shp$")
	
	if(object@polygons.only){
		nfo = lapply(dir.list, getinfo.shape)
		is.poly =  unlist(lapply(nfo, function(x) x$type == 5))
		dir.list = dir.list[is.poly]
		}
	
	if(object@ogr) 
		res = data.frame(dsn = dirname(dir.list), layer = gsub(".shp", "", basename(dir.list)), stringsAsFactors = FALSE) else
		res = dir.list
		res
	} 
)


#user level function
selectShpFiles <- function(dir,  ...) {
	rangeFiles(new("rangeFiles", dir =dir, ...))
	}

Try the rangeMapper package in your browser

Any scripts or data that you put into this service are public.

rangeMapper documentation built on May 2, 2019, 5 p.m.