-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
axis order in GDAL >= 2.5.0 #1033
Comments
This is all exploration; I'm not sure this, or anything, is needed at all.
I think that sp-facing code stays with GIS-order (easting, northing), and I'll have to fix rgdal to stabilise that. For sf, the established revdep codebase is smaller, and we know much less about future incoming data. If future incoming data will expect axis order to be respected, we may need to handle that, converting to GIS-order late ( |
I'm still trying to get my head around the simplest things, like why with gdal 2.5.0dev1 > st_transform(st_sfc(st_point(0:1), crs = 4326), 3857)
Geometry set for 1 feature
geometry type: POINT
dimension: XY
bbox: xmin: 0 ymin: 111325.1 xmax: 0 ymax: 111325.1
epsg (SRID): 3857
proj4string: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs
POINT (0 111325.1) did not assume lat/long, and > st_crs(4326)
Coordinate Reference System:
EPSG: 4326
proj4string: "+proj=longlat +datum=WGS84 +no_defs" |
Indeed, for 4326 EPSG itself says:
on http://www.epsg-registry.org/ querying code 4326. |
Example in r-spatial/discuss#28 |
Hoho! We can now swap axes: library(sf)
# Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1
p1 = st_point(c(7,52))
p2 = st_point(c(-30,20))
st_sfc(p1, p2, crs = 4326) %>%
st_transform(pipeline = "+proj=pipeline +step +proj=axisswap +order=2,1")
# Geometry set for 2 features
# geometry type: POINT
# dimension: XY
# bbox: xmin: 20 ymin: -30 xmax: 52 ymax: 7
# geographic CRS: WGS 84
# epsg (SRID): 4326
# POINT (52 7)
# POINT (20 -30) |
This I now can get my head around: library(sf)
# Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1
# load the nc dataset, EPSG 4326, which is stored with long-lat coordinates:
nc = read_sf(system.file("gpkg/nc.gpkg", package="sf"))
st_bbox(nc)
# xmin ymin xmax ymax
# -84.32385 33.88199 -75.45698 36.58965
# swap the coordinates to lat-long, respecting EPSG 4326 authority:
nc = st_transform(nc, pipeline = "+proj=pipeline +step +proj=axisswap +order=2,1")
# verify:
st_bbox(nc) # x=first, y=second
# xmin ymin xmax ymax
# 33.88199 -84.32385 36.58965 -75.45698
# instrument sf such that it respects EPSG authority axis order (i.e., lat long for 4326):
st_axis_order(authority_compliant = TRUE)
# now transform to NC state plane:
nc.sp = st_transform(nc, 2264)
# plot:
plot(nc.sp[,1], axes = TRUE, graticule = TRUE) # good with the commit to I guess this can be closed now. |
I did speculate in https://r-spatial.github.io/spdep/articles/sids.html that sids is actually
|
That is what I see in > st_crs(nc)
Coordinate Reference System:
User input: NAD27
wkt:
GEOGCRS["NAD27",
DATUM["North American Datum 1927",
ELLIPSOID["Clarke 1866",6378206.4,294.978698213898,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
USAGE[
SCOPE["unknown"],
AREA["North America - NAD27"],
BBOX[7.15,167.65,83.17,-47.74]],
ID["EPSG",4267]] |
Should sf worry about axis order? See rfc 73.
The text was updated successfully, but these errors were encountered: