[GRASS-user] How to find intersection of two lines

Moritz Lennert mlennert at club.worldonline.be
Sat Mar 22 17:24:18 EDT 2008


On 21/03/08 15:51, Jarek Jasiewicz wrote:
> Moritz Lennert wrote:
>> On 20/03/08 17:15, Jarek Jasiewicz wrote:
>>> Moritz Lennert wrote:
>>>> On 20/03/08 11:17, Jarosław Jasiewicz wrote:
>>>>> Hi I have lots of raster, thinned lines and second raster with with 
>>>>> one line. I must find all points where second line intersect with 
>>>>> lines on first raster
>>>>> it is very simple:
>>>>>
>>>>> r.mapcalc points=if(raster_two==1&&raster_one==1,1,null())
>>>>>
>>>>> but there is one exception:
>>>>>
>>>>> AB
>>>>> BA
>>>>>
>>>>> when lines intersect with 45 grades. There is intersection but 
>>>>> without common point. Naither buffor nor grow is not a solution 
>>>>> because I need exactly one point lying exactly on line from raster one
>>>>>
>>>>> Any Ideas
>>>>
>>>> Either ressample your rasters to coarser resolution to make them 
>>>> coincide, or convert to vector and use a combination of v.patch + 
>>>> v.clean (e.g. v.clean input=lines1 output=lines2 err=points tool=break)
>>>>
>>>> Moritz
>>> thanks for ansfer
>>> I tried it with similar way (v.patch +v.clean + topology report) but 
>>> it is not it. I need EXACT coordinates of pixels on intersection do 
>>> to transfer it to another program
>>
>> The map points (created with the parameter err=points) should contain 
>> exactly these points. Obviously this only works if you can create 
>> correct vector lines from your raster.
>>
>> See example here:
>> http://geog-pc40.ulb.ac.be/grass/misc/intersections.html
>>
>> Moritz
> yes, but real (single prescision) coordinates of the point are not exact 
> of coordinates of pixel,
> 
> for example:
> point: x=3567891.36345671, y=x=6564456.8176236
> pixel: x=3567891.36357892, y=x=6564456.8339658
> 
> but, v.to.rast and r.to.vect solve that problem

It would be interesting to know where the difference comes from... 
AFAIK, coordinates are always coded at the same precision, both for 
raster and vector, but I might be wrong.

Just out of curiosity: what types of units are you working in for such a 
precision to make sense ?

Moritz


More information about the grass-user mailing list