Skip to content

Commit 475ae4f

Browse files
authored
Merge pull request #100 from bmcandr/fix/ep6-use-pyproj-crs
Switch from WKT to pyproj's CRS class
2 parents 5e8eaec + 533d4c4 commit 475ae4f

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

_episodes/06-raster-reproject.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,52 @@ grid_mapping: spatial_ref
6767
~~~
6868
{: .output}
6969

70-
To read the spatial reference in the output you click on the icon “Show/Hide attributes” on the right side of the `spatial_ref` row. You can also print the Well-known Text projection string.
70+
To view the CRS information for this dataset in the interactive `repr`, click on document icon on the right side of the `spatial_ref` row.
71+
72+
As we showed in [the previous lesson]({{site.baseurl}}/05-raster-structure#view-raster-coordinate-reference-system-crs-in-python), we can also use the `CRS` class from the `pyproj` library to view the CRS:
7173

7274
~~~
73-
surface_HARV.rio.crs.wkt
75+
from pyproj import CRS
76+
77+
CRS(surface_HARV.rio.crs)
7478
~~~
7579
{: .language-python}
7680

7781
~~~
78-
'PROJCS["WGS 84 / UTM zone 18N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-75],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32618"]]'
82+
<Derived Projected CRS: EPSG:32618>
83+
Name: WGS 84 / UTM zone 18N
84+
Axis Info [cartesian]:
85+
- [east]: Easting (metre)
86+
- [north]: Northing (metre)
87+
Area of Use:
88+
- undefined
89+
Coordinate Operation:
90+
- name: UTM zone 18N
91+
- method: Transverse Mercator
92+
Datum: World Geodetic System 1984
93+
- Ellipsoid: WGS 84
94+
- Prime Meridian: Greenwich
7995
~~~
8096
{: .output}
8197

8298
We can see the datum and projection are UTM zone 18N and WGS 84 respectively. UTM zone 18N is a regional projection with an associated coordinate system to more accurately capture distance, shape and/or area around the Harvard Forest.
8399

84100
~~~
85-
terrain_HARV.rio.crs.wkt
101+
CRS(terrain_HARV.rio.crs)
86102
~~~
87103
{: .language-python}
88104

89105
~~~
90-
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]'
106+
<Geographic 2D CRS: EPSG:4326>
107+
Name: WGS 84
108+
Axis Info [ellipsoidal]:
109+
- Lat[north]: Geodetic latitude (degree)
110+
- Lon[east]: Geodetic longitude (degree)
111+
Area of Use:
112+
- undefined
113+
Datum: World Geodetic System 1984
114+
- Ellipsoid: WGS 84
115+
- Prime Meridian: Greenwich
91116
~~~
92117
{: .output}
93118

0 commit comments

Comments
 (0)