3

Question

Before (some) spatial analysis, we need to make sure the coordinate reference systems of the layers are the same. I am doing intersect with two layers. I did that under a coordinate before. If I change the coordinate, will the result also be changed?

Details

I use r language for GIS analysis, especially the package sf.

Before spatial analysis, I first define the CRS used for the data analysis flow.

my_crs <- 6668
# 6668 is the EPSG id of the geographical coordinate system JGD 2011
# which is basically the same as WGS 84

Then I have two sf data, one is point data (which is about 10000 points), and another one is polygon data. Let's say their names are "my_point" and "my_polygon". Then I want to get the points intersecting with the polygon, so:

my_inter <- st_intersection(my_point, my_polygon)

I wonder if I change the my_crs into another one, for example, my_crs <- 6676 (6676 is a projected coordinate reference system), then I do my_inter <- st_intersection(my_point, my_polygon). I found the results changed a little bit. I wonder why is that.

nmtoken
  • 13,355
  • 5
  • 38
  • 87
Kang
  • 49
  • 3
  • 1
    Yes, CRS affects the location of the intersection. Take for example a rectangle created in a geographic coordinate system and then project it to UTM it becomes a trapezoid, likewise data that is clipped in the geographic coordinate system would no longer match the edges of the trpezoid. The difference between two projected coordinate systems isn't likely to be as pronounced but it will still be more than 0. – Michael Stimson Jun 08 '23 at 02:50
  • @MichaelStimson Thank you for your reply. I understand that the shape of a polygon changes when its CRS is transformed into another. I wonder if the topological relationship between two layers (especially between a point layer and a polygon layer) will change or not. For example, if a point was inside the rectangle under a coordinate, will it still be inside the rectangle when their coordinate systems are both transformed into a projected coordinate system? Or it is possible that this point will be outside the rectangle after the transformation? – Kang Jun 08 '23 at 03:53
  • 1
    Yes, the number of points within a polygon can change if they're very near the edge and/or your polygon is made up from very long sections between vertices. You can minimise the effect by densifying the polygon https://gis.stackexchange.com/questions/29578/automatically-adding-vertices-to-lines-every-x-meters-using-qgis before projecting, this will make the straight lines bend with the transformation in an attempt to keep topological relationships. – Michael Stimson Jun 08 '23 at 04:05
  • 2
    The result could be changed, but there are a ton of potential complications based on which CRS is used, and what you are measuring, and at what resolution. That leads to the seminal work on fractals that asks, "How long is the coast of Britain?" (Mandelbrot). – Vince Jun 08 '23 at 04:08
  • @MichaelStimson Thank you (again) for your answer. That helps a lot. According to your replies, a curve (with more vertices) might become a straight line after projection. That will exclude the points which had been inside the polygon (or vice versa). Does it mean it is better to use a local geographic coordinate (in this case, JGD 2011, unit: degree) rather than make the projection (transform to EPSG:6676 - JGD2011 / Japan Plane Rectangular CS VIII, unit: meter)? – Kang Jun 08 '23 at 04:40
  • @Vince Thank you for your answer. In my case, I want to get the intersection between points and a circle. Same as the last reply to MichaelStimson, does it means it is better to use a local geographic coordinate rather than make the projection? – Kang Jun 08 '23 at 04:42
  • 1
    No, use the native projection of the polygons, any kind of projection will introduce uncertainty. Points can be projected as there are no straight lines to worry about so I'd project the points to match the polygon coordinate reference system. – Michael Stimson Jun 08 '23 at 04:53
  • 1
    See also the good images in https://gis.stackexchange.com/questions/461265/polygons-no-longer-completely-overlap-after-reprojection. Algorithms often reproject just the existing vertices without doing densification and that can lead into errors in spatial relationships if the properly reprojected geometry should have curved lines between vertices. Your case with a point and a circle is not so error prone. The point will be projected accurately and circle has plenty of vertices. – user30184 Jun 08 '23 at 06:25
  • As you're working in R, you probably just run the code and have no visual control. I would advice you to load your data (both in inital and reprojected version) to a software where you have visual control, e.g. QGIS and inspect the data to get a feeling of what is happening in the background. See also https://gis.stackexchange.com/a/392248/88814 for another image of how shapes might change with reprojection: points between black and red line will intersect or not, depending on the projection. – Babel Jun 08 '23 at 07:39

1 Answers1

1

According to the replies in the comments, here is a conclusion. But as pointed out by @Jeffrey Evans below, it is a short but not absolutely correct answer. A short answer is, yes, changing CRS will change the results of spatial analysis. In this case, we have a point layer and a polygon layer, and we make a intersect analysis of the two layers. If we change the CRS before this analysis, the result will also be changed, i.e., some points previously in the polygon might be outside the polygon after the CRS change. The change has an impact, especially on the points near the polygon edge. Therefore, before spatial analysis, one should determine the CRS first.

Kang
  • 49
  • 3
  • The short answer is yes there will be differences. However, it is not a straightforward as your summary. I have looked at uncertainty associated reprojecting lat/long total-station control points to UTM and found, with horizontal and vertical datums, the error to be sub-centimeter. This was for points so, planar geometries, like polygons and lines, will exhibit distortion but, as pointed out, can be controlled by having more vertices (points) representing the features. I cannot think of a transformation that would result in features matching in one projection but not another. – Jeffrey Evans Jun 13 '23 at 15:35