[R-sig-Geo] Outline of Study area

Brian Oney zenlines at gmail.com
Sun Dec 19 20:16:45 CET 2010


Hello,
I guess questions without merit do not merit answers. So I missed one 
thing in the GRASS library. I didn't need to use r.thin before using 
r.to.vect.
This is how it works (so it hopefully doesn't have to be asked again):
# some raster
range[!is.na(range)] <- 1
writeRaster(range,paste(path,"range_template.asc", sep=""),overwrite=T)

initGRASS("C:/Program_Files_x86/GRASS-65-SVN", home=tempdir(), 
gisDbase=gisDbase, SG=sgdf,location=ssp, mapset="maps", override=T)

execGRASS("r.in.gdal", flags=c("e","o","overwrite"), parameters=list(
         input=paste(path,"range_template.asc", sep=""),
         output="mat"
         ))

execGRASS("r.to.vect", flags=c("s"), parameters=list(input="mat", 
output="rangepoly", feature="area"))
execGRASS("v.out.ogr", flags=c("e"), parameters=list(input="rangepoly", 
type="area",
     dsn=shpbase, olayer=paste("ssprange",sep=""), format="ESRI_Shapefile"))

Hope this is helpful in the future. It would be nice to have it is R but 
I guess we have this great interface to GRASS too. Thanks Roger!
Brian



On 12/18/2010 3:07 PM, Brian Oney wrote:
> Hi List,
> I am mosaicking several maps of different areas and I would like to 
> make an outline of the different study areas for plotting etc.. I have 
> played around extensively in GRASS and R and still don't have what I 
> need. I would like to do it in R because, at the moment, I am a 
> windows slave, and windows slaves are especially disadvantaged in GRASS.
>
> # In R I have tried:
> rast[!is.na(rast)] <- 1
> rasterToPolygons(rast, function(x) !is.na(x)) # This just overwhelmed 
> my computer and gave me lots of little polygons
>
>
> #Trying the same after using aggregate also did not help speed.
> #So say that I am satisfied with the product from raster to polygons.
> #Then I use:
> unionSpatialPolygons(polyrange, IDs=somethingsane) # And it takes an 
> additional several hours time as well as excludes my islands.
>
> Does anyone have suggestion to create an outline in a reasonable 
> amount of time?
> I would greatly appreciate it!
>
> Regards,
> Brian
>
>
>
>
>
>



More information about the R-sig-Geo mailing list