I have a function that takes a point and compares it with lines that are stored in PostGIS and then gets the line closest to the point. Initially I did not transform the data because I did not think that it would matter when I want to get the minimum distance. I thought that small distances (up to 100m) would not need transformation but I was wrong! Sometimes it gets a line that is not the closest one even if the compared distances are 1.2m and 2.5m. I discovered that and I re-designed the SQL command to transform the point and line to the local UTM zone and now its working fine.
I would appreciate it if someone could explain to me how is this possible at such a small scale. Why did PostGIS think that a line 2.5m away from my point is closer than a line 1.2m away? Perhaps an emphasis on UNITS vs metric unit usage?
Thank you for your time and effort! Regards, A