Skip to content

Commit

Permalink
Allow downloading OpenRailwaysMap without background
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Pechnikov committed May 18, 2024
1 parent 47454a2 commit a04de47
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pygmtsar/pygmtsar/XYZTiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,18 @@ def download_openstreetmap(self, geometry, zoom, filename=None, **kwargs):
kwargs['url'] = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
return self.download(geometry, zoom, filename, **kwargs)

def download_openrailwaymap(self, geometry, zoom, filename=None, **kwargs):
kwargs['url'] = 'https://mt1.google.com/vt/lyrs=r&x={x}&y={y}&z={z}'
def download_openrailwaymap(self, geometry, zoom, filename=None, background='Mapnik', **kwargs):
import xarray as xr
if background is None:
# [abc]
kwargs['url'] = 'https://a.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png'
tiles = self.download(geometry, zoom, filename, **kwargs)
tiles = xr.concat([tiles, 255*(tiles.sum('band') != 0)], dim='band')
return tiles
elif background == 'Mapnik':
kwargs['url'] = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
else:
raise ValueError('Expected background "Mapnik" or None')
return self.download(geometry, zoom, filename, **kwargs)

def download(self, geometry, zoom, filename=None, url='https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}', n_jobs=8, skip_exist=True, debug=False):
Expand Down

0 comments on commit a04de47

Please sign in to comment.