Skip to content

Commit

Permalink
fixed raster properties example and changed reprojection
Browse files Browse the repository at this point in the history
  • Loading branch information
grallewellyn committed Dec 12, 2024
1 parent 32d322e commit ad075eb
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions docs/python-usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -397,22 +397,37 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1073741824 536870912\n",
"1024 512\n",
"EPSG:4326\n",
"| 0.00, 0.00,-180.00|\n",
"| 0.00,-0.00, 90.00|\n",
"| 0.35, 0.00,-180.00|\n",
"| 0.00,-0.35, 90.00|\n",
"| 0.00, 0.00, 1.00|\n",
"3\n",
"(1, 2, 3)\n"
"4\n",
"(1, 2, 3, 4)\n"
]
}
],
"source": [
"proj4326 = 'https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?\\\n",
"version=1.3.0&service=WMS&request=GetMap&\\\n",
"format=image/jpeg&STYLE=default&bbox=-90,-180,90,180&CRS=EPSG:4326&\\\n",
"HEIGHT=512&WIDTH=512&TIME=2021-11-25&layers=MODIS_Terra_SurfaceReflectance_Bands143'\n",
"with rasterio.open(proj4326) as src:\n",
"# Save a global extents tiff file\n",
"# Connect to GIBS WMS Service\n",
"wms = WebMapService('https://gibs.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi?', version='1.3.0')\n",
"\n",
"# Configure request for MODIS_Terra_SurfaceReflectance_Bands143\n",
"img = wms.getmap(layers=['MODIS_Terra_SurfaceReflectance_Bands143'], # Layers\n",
" srs='epsg:4326', # Map projection\n",
" bbox=(-180,-90,180,90), # Bounds\n",
" size=(1024, 512), # Image size\n",
" time='2021-11-25', # Time of data\n",
" format='image/tiff', # Image format\n",
" transparent=True) # Nodata transparency\n",
"\n",
"# Save output TIFF to a file\n",
"out = open('global.tiff', 'wb')\n",
"out.write(img.read())\n",
"out.close()\n",
"\n",
"# Access properties of geospatial raster file \n",
"with rasterio.open(\"global.tiff\") as src:\n",
" print(src.width, src.height)\n",
" print(src.crs)\n",
" print(src.transform)\n",
Expand Down Expand Up @@ -744,7 +759,7 @@
"outputs": [],
"source": [
"# Here you can set the new projection to whatever you like \n",
"dst_crs = 'EPSG:9822'\n",
"dst_crs = 'EPSG:6933'\n",
"\n",
"# Save a global extents tiff file\n",
"# Connect to GIBS WMS Service\n",
Expand Down

0 comments on commit ad075eb

Please sign in to comment.