@@ -138,9 +138,9 @@ def load_tile_map(
138138 ... raster.rio.crs.to_string()
139139 'EPSG:3857'
140140 """
141- # The CRS of the returned image. Use the tile provider's CRS if available.
142- # Otherwise, default to EPSG:3857.
143- _default_crs = getattr (source , "crs" , "EPSG:3857" )
141+ # The CRS of the source tile provider. If the source is a TileProvider object, use
142+ # its crs attribute if available. Otherwise, default to EPSG:3857.
143+ _source_crs = getattr (source , "crs" , "EPSG:3857" )
144144
145145 if not _HAS_CONTEXTILY :
146146 msg = (
@@ -150,9 +150,9 @@ def load_tile_map(
150150 )
151151 raise ImportError (msg )
152152
153- if crs != _default_crs and not _HAS_RIOXARRAY :
153+ if crs != _source_crs and not _HAS_RIOXARRAY :
154154 msg = (
155- f"Package `rioxarray` is required if CRS is not '{ _default_crs } '. "
155+ f"Package `rioxarray` is required if CRS is not '{ _source_crs } '. "
156156 "Please use `python -m pip install rioxarray` or "
157157 "`mamba install -c conda-forge rioxarray` to install the package."
158158 )
@@ -198,10 +198,10 @@ def load_tile_map(
198198
199199 # If rioxarray is installed, set the coordinate reference system.
200200 if hasattr (dataarray , "rio" ):
201- dataarray = dataarray .rio .write_crs (input_crs = _default_crs )
201+ dataarray = dataarray .rio .write_crs (input_crs = _source_crs )
202202
203- # Reproject raster image from EPSG:3857 to specified CRS, using rioxarray .
204- if crs != _default_crs :
203+ # Reproject raster image from the source CRS to the specified CRS.
204+ if crs != _source_crs :
205205 dataarray = dataarray .rio .reproject (dst_crs = crs )
206206
207207 return dataarray
0 commit comments