[R-sig-Geo] Sampling random plots
Roger Bivand
Roger.Bivand at nhh.no
Fri Oct 26 10:35:16 CEST 2007
On Fri, 26 Oct 2007, Gerald Jurasinski wrote:
> Dear List,
>
> Could someone please help me, with a tiny question?
>
> I have read in a shapefile with readShapePoly:
> sr <- readShapePoly("study_region")
>
> It just contains of one polygon.
>
> As i would like to sample random locations inside i do:
> > sr.pts <- sample.Polygon(sr, 60)
You can just do spsample(sr, ...), which will traverse your object to get
to the single Polygon, sr is what class(sr) says.
>
> However, the function tells me, that there is no "area" slot in the
> object:
> Error in getPolygonAreaSlot(x) : no Slot of name "area" for this
> object of class "SpatialPolygonsDataFrame".
>
> But when looking at the object, there is a slot called "area" (see
> below). Do i have to convert the sr object to another spatial object
> which can better be handled by package sp functions (because it was
> read in with a maptools function)? And by the way, why there is no
> rgdal binary for mac on CRAN?
>
Because the external dependencies for the many OSX versions and platforms
are too complicated for the CRAN OSX builder to support. Please follow the
instructions on:
http://www.sal.uiuc.edu/tools/tools-sum/rgeo/rgeo-detail/map-packages-on-cran
to build from source. 32-bit Windows is simpler to support because there
are fewer moving targets, and Uwe Ligges has been very generous in helping
to automate the build process.
Roger
>
> > sr
> An object of class SpatialPolygonsDataFrame
> Slot "data":
> Id
> 0 0
>
> Slot "polygons":
> [[1]]
> An object of class Polygons
> Slot "Polygons":
> [[1]]
> An object of class Polygon
> Slot "labpt":
> [1] 4510732 6009121
>
> Slot "area":
> [1] 250264.9
>
> Slot "hole":
> [1] FALSE
>
> Slot "ringDir":
> [1] 1
>
> Slot "coords":
> [,1] [,2]
> [1,] 4510328 6008870
> [2,] 4510339 6008963
> [3,] 4510347 6009007
> [4,] 4510371 6009123
> [5,] 4510386 6009155
> [6,] 4510427 6009198
> [7,] 4510456 6009218
> [8,] 4510536 6009269
> [9,] 4510590 6009324
> [10,] 4510655 6009395
> [11,] 4510704 6009380
> [12,] 4510752 6009358
> [13,] 4510899 6009300
> [14,] 4511018 6009246
> [15,] 4511127 6009077
> [16,] 4511246 6009065
> [17,] 4511343 6009053
> [18,] 4511213 6008975
> [19,] 4511176 6008970
> [20,] 4511123 6008980
> [21,] 4511077 6009002
> [22,] 4511007 6009021
> [23,] 4510939 6009028
> [24,] 4510866 6009021
> [25,] 4510790 6009007
> [26,] 4510723 6008985
> [27,] 4510643 6008953
> [28,] 4510579 6008934
> [29,] 4510510 6008921
> [30,] 4510420 6008893
> [31,] 4510328 6008870
>
>
>
> Slot "plotOrder":
> [1] 1
>
> Slot "labpt":
> [1] 4510732 6009121
>
> Slot "ID":
> [1] "0"
>
> Slot "area":
> [1] 250264.9
>
>
>
> Slot "plotOrder":
> [1] 1
>
> Slot "bbox":
> min max
> r1 4510328 4511343
> r2 6008870 6009395
>
> Slot "proj4string":
> CRS arguments: NA
>
>
>
>
>
> Dr. Gerald Jurasinski
> Landscape Ecology and Site Evaluation
> Institute for Management of Rural Areas
> Faculty of Agricultural and Environmental Sciences
> University of Rostock
> Justus-von-Liebig-Weg 6
> 18059 Rostock
> Germany
>
> gerald.jurasinski at uni-rostock.de
> http://www.auf.uni-rostock.de/loe
> +49 381 4983225 (tel)
> +49 381 4983222 (fax)
>
>
>
> [[alternative HTML version deleted]]
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list