Raster
In [1]:
Copied!
import biospat.mapping as biospat_ipyleaflet
import biospat.mapping as biospat_ipyleaflet
Adding Raster Data to a Map¶
In [2]:
Copied!
url = "https://github.com/opengeos/data/blob/main/landsat/2020.tif?raw=true"
url = "https://github.com/opengeos/data/blob/main/landsat/2020.tif?raw=true"
In [3]:
Copied!
ucayali_river_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
ucayali_river_map.add_raster(url, name="Ucayali River", colormap="viridis", opacity=0.7)
ucayali_river_map
ucayali_river_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
ucayali_river_map.add_raster(url, name="Ucayali River", colormap="viridis", opacity=0.7)
ucayali_river_map
Out[3]:
In [4]:
Copied!
pucallpa_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
pucallpa_map.add_raster(url, name="Pucallpa Raster", colormap="viridis", opacity=0.7)
coordinates = [(-8.3802, -74.5467)]
pucallpa_map.add_markers(coordinates, name="Pucallpa")
pucallpa_map.add_layer_control()
pucallpa_map
pucallpa_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
pucallpa_map.add_raster(url, name="Pucallpa Raster", colormap="viridis", opacity=0.7)
coordinates = [(-8.3802, -74.5467)]
pucallpa_map.add_markers(coordinates, name="Pucallpa")
pucallpa_map.add_layer_control()
pucallpa_map
Out[4]:
Incorporating Different Raster Bands¶
In [5]:
Copied!
raster_bands = "https://github.com/opengeos/data/blob/main/landsat/2020.tif?raw=true"
raster_bands = "https://github.com/opengeos/data/blob/main/landsat/2020.tif?raw=true"
In [6]:
Copied!
# All bands together
all_bands_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
all_bands_map.add_raster(raster_bands, name="landsat")
all_bands_map.add_layer_control() # Add layer control to the map
all_bands_map
# All bands together
all_bands_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
all_bands_map.add_raster(raster_bands, name="landsat")
all_bands_map.add_layer_control() # Add layer control to the map
all_bands_map
Out[6]:
In [7]:
Copied!
import rasterio
src = rasterio.open(raster_bands)
src.meta
import rasterio
src = rasterio.open(raster_bands)
src.meta
Out[7]:
{'driver': 'GTiff', 'dtype': 'uint8', 'nodata': 0.0, 'width': 697, 'height': 377, 'count': 4, 'crs': CRS.from_wkt('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"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]'), 'transform': Affine(0.0008084837557075694, 0.0, -74.72249415376068, 0.0, -0.0008084837557075694, -8.282107593468341)}
In [8]:
Copied!
# Only the infrared band (band 4) from the Landsat image
one_band_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
one_band_map.add_raster(
raster_bands,
indexes=4,
name="Infrared Band",
opacity=0.7,
)
one_band_map.add_layer_control()
one_band_map
# Only the infrared band (band 4) from the Landsat image
one_band_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="300px")
one_band_map.add_raster(
raster_bands,
indexes=4,
name="Infrared Band",
opacity=0.7,
)
one_band_map.add_layer_control()
one_band_map
Out[8]:
Adding an Image to a Map¶
In [9]:
Copied!
image_map = biospat_ipyleaflet.Map(center=[39.8283, -98.5795], zoom=4, height="600px")
image_map.add_image(
"https://brand.utk.edu/wp-content/uploads/2019/02/University-CenteredLogo-RGB.png",
bounds=[[30.2606, -88.5652], [38.9606, -79.2762]],
opacity=0.8,
name="UTK",
)
image_map.add_image(
"https://github.com/anytko/anytko.github.io/blob/main/website_photo.png?raw=true",
bounds=[[17, -145], [30, -136]],
name="Bio",
)
image_map.add_layer_control()
image_map
image_map = biospat_ipyleaflet.Map(center=[39.8283, -98.5795], zoom=4, height="600px")
image_map.add_image(
"https://brand.utk.edu/wp-content/uploads/2019/02/University-CenteredLogo-RGB.png",
bounds=[[30.2606, -88.5652], [38.9606, -79.2762]],
opacity=0.8,
name="UTK",
)
image_map.add_image(
"https://github.com/anytko/anytko.github.io/blob/main/website_photo.png?raw=true",
bounds=[[17, -145], [30, -136]],
name="Bio",
)
image_map.add_layer_control()
image_map
Out[9]:
Adding a Video to a Map¶
In [10]:
Copied!
video_map = biospat_ipyleaflet.Map(center=(-40.9006, 174.8860), zoom=5, height="600px")
video_url = "https://github.com/rocksdanister/weather/blob/main/resources/hero.mp4"
video_map.add_image(video_url, bounds=[[-40, 178], [-45, 182]], name="Weather App")
video_map.add_layer_control()
video_map
video_map = biospat_ipyleaflet.Map(center=(-40.9006, 174.8860), zoom=5, height="600px")
video_url = "https://github.com/rocksdanister/weather/blob/main/resources/hero.mp4"
video_map.add_image(video_url, bounds=[[-40, 178], [-45, 182]], name="Weather App")
video_map.add_layer_control()
video_map
Out[10]:
Adding a Web Mapping Service (WMS) Layer to a Map¶
In [11]:
Copied!
wms_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="600px")
wms_url = "https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WMSServer?"
wms_map.add_wms_layer(
url=wms_url,
layers="NLCD_Canopy",
name="Canopy Cover",
format="image/png",
transparent=True,
opacity=0.7,
)
wms_map.add_layer_control()
wms_map
wms_map = biospat_ipyleaflet.Map(center=[40, -100], zoom=4, height="600px")
wms_url = "https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WMSServer?"
wms_map.add_wms_layer(
url=wms_url,
layers="NLCD_Canopy",
name="Canopy Cover",
format="image/png",
transparent=True,
opacity=0.7,
)
wms_map.add_layer_control()
wms_map
Out[11]: