Home > Enterprise >  How to tell if a shape file (.shp) contains planar geometry or not
How to tell if a shape file (.shp) contains planar geometry or not

Time:06-09

I am trying to use the st_intersection() command to find the intersection area between two polygons, as follows:

poly.3 <- st_intersection(poly.1, poly.2)

I get the following warning:

Warning: attribute variables are assumed to be spatially constant throughout all geometries
although coordinates are longitude/latitude, st_intersection assumes that they are planar

Although I processed the polygons previously to ensure that they are spatially constant (poly.2 <- st_transform(poly.2, st_crs(poly.1))), how can I tell if the coordinates are planar or not?

If I run st_crs(poly.1) I get the following:

Coordinate Reference System:
  User input: WGS 84 
  wkt:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["latitude",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["longitude",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]

Furthermore, if they turn out not to be planar, how would I make them planar?

Thanks so much for your help.

EDIT: Through previous googling, I found someone's suggestion to use sf_use_s2(FALSE), which, while disabling the warning message, doesn't seem to solve the underlying issue of miscalculating the intersection.

CodePudding user response:

You are looking for this https://r-spatial.github.io/sf/reference/st_is_longlat.html EPSG:4326 is non planar, just st_transform(obj, 3857) or any other projection should work.

  •  Tags:  
  • r sf
  • Related