[R-sig-Geo] Distribute points along lines
Roger Bivand
Roger.Bivand at nhh.no
Sun Jul 5 15:56:20 CEST 2009
On Sun, 5 Jul 2009, Agustin Lobo wrote:
> Roger,
>
> Roger Bivand wrote:
>
>> so a proportion in [0,1], but it seems to work backwards at present, with
>> an offset of 0 anchoring to the final, not the first, point.
>
> Would it be too hard adding the offset to the first point? And actually
> ordering the points starting from the initial point of the line?
The problem was that sp:::sample.Line() was not handling a zero-length
line segment (two identical consecutive coordinates in a Line object)
properly, provoking an error when offset was set to 0.
I've committed changes to sourceforge:
cvs -z3 \
-d:pserver:anonymous at r-spatial.cvs.sourceforge.net:/cvsroot/r-spatial \
co -P sp
(all one line), then
R CMD INSTALL sp
to try out. I have also reversed the meaning of offset for lines, 0 is now
the start coordinate of the Line object. If possible, could you please
check out the revision, install it from source, and try it - it resolves
the problem for your case as far as I can tell.
>
>>
>>> I'm actually trying to set real field sampling sites, so this matters. The
>>> best would be being able to set the first point in the line and then the
>>> nb of points for random sites (as it is currently done) and the length
>>> interval for regular sampling.
>>>
>>> By now I can adjust the nb. of points for the interval I want if the
>>> length of the line is known, but how can I calculate the length of the
>>> lines? calcLength requires another type of spatial object.
>>
>> calcLength() is in PBSmapping. Adding a length slot to Line objects is an
>> option, or rather providing length methods which would be less invasive.
>> I'll take a look.
>
> Thanks, please let me know. By now I measure the actual length in qgis.
There are LineLength(), LinesLength(), and SpatialLinesLengths()
functions in sp, more used internally than exposed, but should be OK. I've
converted LineLength() to use C code, so they can now also measure lengths
in km even if the data are in geographical coordinates (assuming WGS84),
as in spDistsN1().
Roger
>
> Agus
>
>
--
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