Created
January 18, 2021 00:44
-
-
Save shoover/42ab0543c417e2c04144dedf9290c940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compose a street map and weather radar into an image. | |
# | |
# Map GIS export from ArcGIS. Query f=html to view a sample exported image and form to tweak parameters. | |
# https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer/export?bbox=-15165054.230000%2C2294608.041000%2C-6778397.876000%2C6947666.110000&bboxSR=&layers=&layerDefs=&size=3440%2C1440&imageSR=102100&format=png32&transparent=false&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=html | |
# | |
# Radar GIS export from NOAA. | |
# https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Observations/radar_base_reflectivity/MapServer/export?bbox=-15165054.230000%2C2294608.041000%2C-6778397.876000%2C6947666.110000&bboxSR=&layers=&layerDefs=&size=3440%2C1440&imageSR=102100&format=png32&transparent=true&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=html | |
# | |
# Use the same bounding box, image spatial reference, and size for both requests so the layers align. | |
# I grabbed a reference continental US bounding box from https://digital.weather.gov/staticpages/mapservices.php: | |
# -15165054.230000,2294608.041000,-6778397.876000,6947666.110000. | |
mkdir -force work | |
mkdir -force final | |
$map = "work\conus-map.png" | |
$radar = "work\conus-radar.png" | |
$radarMapUpdate = "final\conus-map-radar1.png" | |
$radarMap = "final\conus-map-radar.png" | |
# Get the map only if it doesn't exist. This is a 9MB file and downloads slowly. | |
if (-not (Test-Path $map)) { | |
Invoke-WebRequest -Uri "https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer/export?bbox=-15165054.230000%2C2294608.041000%2C-6778397.876000%2C6947666.110000&bboxSR=&layers=&layerDefs=&size=3440%2C1440&imageSR=102100&format=png32&transparent=false&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=image" -OutFile $map | |
} | |
# Get the latest radar | |
Invoke-WebRequest -Uri "https://idpgis.ncep.noaa.gov/arcgis/rest/services/NWS_Observations/radar_base_reflectivity/MapServer/export?bbox=-15165054.230000%2C2294608.041000%2C-6778397.876000%2C6947666.110000&bboxSR=&layers=&layerDefs=&size=3440%2C1440&imageSR=102100&format=png32&transparent=true&dpi=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&rotation=&datumTransformations=&layerParameterValues=&mapRangeValues=&layerRangeValues=&f=image" -OutFile $radar | |
# Compose to a temp file | |
# 1. Compose both images with the map as the base layer and add transparency on the radar layer | |
# 2. Annotate the date and time | |
$date = Get-Date -Format "dddd MM/dd/yyyy hh:mm tt" | |
& magick convert $map '(' $radar -normalize +level 0,60% ')' -compose over -composite -fill black -pointsize 52 -annotate +80+1280 $date $radarMapUpdate | |
# Update the main copy. Keep both copies because it seems like Windows sometimes doesn't switch | |
Copy-Item $radarMapUpdate -Destination $radarMap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment