Skip to content

Commit

Permalink
Do not inject CRS directly into attributes
Browse files Browse the repository at this point in the history
There are more notebooks yet to be fixed
  • Loading branch information
Kirill888 committed Jul 7, 2020
1 parent 3a167f8 commit 39c0532
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Frequently_used_code/Contour_extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"from affine import Affine\n",
"from datacube.utils.geometry import CRS\n",
"from datacube.utils.geometry import assign_crs\n",
"\n",
"sys.path.append('../Scripts')\n",
"from dea_datahandling import load_ard\n",
Expand Down Expand Up @@ -154,8 +154,7 @@
"\n",
"# Modify CRS and transform attributes into a format that is\n",
"# consistent with data loaded from `dc.load`\n",
"elevation_array.attrs['crs'] = CRS(elevation_array.crs[-9:])\n",
"elevation_array.attrs['transform'] = Affine(*elevation_array.transform)\n",
"elevation_array = assign_crs(elevation_array)\n",
"\n",
"# Print the data\n",
"print(elevation_array)"
Expand Down
6 changes: 3 additions & 3 deletions Scripts/dea_spatialtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from skimage.measure import find_contours
from shapely.geometry import LineString, MultiLineString, shape
from datacube.helpers import write_geotiff
from datacube.utils.geometry import CRS, Geometry
from datacube.utils.geometry import CRS, Geometry, assign_crs


def xr_vectorize(da,
Expand Down Expand Up @@ -296,8 +296,8 @@ def xr_rasterize(gdf,
name=name if name else None)

# Add back crs if xarr.attrs doesn't have it
if 'crs' not in xarr.attrs:
xarr.attrs['crs'] = str(crs)
if xarr.geobox is None:
xarr = assign_crs(xarr, str(crs))

if export_tiff:
print(f"Exporting GeoTIFF to {export_tiff}")
Expand Down

0 comments on commit 39c0532

Please sign in to comment.