diff --git a/Folium_2.ipynb b/Folium_2.ipynb index 7ff0fe4..cb989de 100644 --- a/Folium_2.ipynb +++ b/Folium_2.ipynb @@ -2,12 +2,22 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# pip install colorcet" + ] + }, + { + "cell_type": "code", + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import folium\n", "import matplotlib\n", + "import colorcet\n", "from matplotlib.pyplot import imread\n", "from matplotlib.colors import Normalize\n", "from folium import raster_layers" @@ -15,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -24,7 +34,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -36,7 +46,7 @@ "-60.0 -30.0\n", "10.0 -30.0\n", "ext = [[10.0, -180.0], [-60.0, -180.0], [-60.0, -30.0], [10.0, -30.0]]\n", - "geo_ext = [[0.17453292519943298, -3.141592653589794], [-1.0471975511965979, -3.141592653589794], [-6679169.447596415, -3503549.843504376], [1113194.9079327357, -3503549.843504376]]\n" + "geo_ext = [[10.0, -180.0], [-60.0, -180.0], [-60.0, -30.0], [10.0, -30.0]]\n" ] } ], @@ -100,8 +110,8 @@ "src_srs=osr.SpatialReference()\n", "src_srs.ImportFromWkt(ds.GetProjection())\n", "# tgt_srs=osr.SpatialReference()\n", - "tgt_srs.ImportFromEPSG(3857)\n", - "# tgt_srs = src_srs.CloneGeogCS()\n", + "# tgt_srs.ImportFromEPSG(3857)\n", + "tgt_srs = src_srs.CloneGeogCS()\n", "\n", "geo_ext=ReprojectCoords(ext,src_srs,tgt_srs)\n", "print(\"geo_ext = \" + str(geo_ext))" @@ -109,7 +119,73 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Driver: GTiff/GeoTIFF\r\n", + "Files: /notebooks/resources/gpm/gpm_1d.20190531.tif\r\n", + "Size is 1500, 700\r\n", + "Coordinate System is:\r\n", + "GEOGCS[\"WGS 84\",\r\n", + " DATUM[\"WGS_1984\",\r\n", + " SPHEROID[\"WGS 84\",6378137,298.2572326660159,\r\n", + " AUTHORITY[\"EPSG\",\"7030\"]],\r\n", + " AUTHORITY[\"EPSG\",\"6326\"]],\r\n", + " PRIMEM[\"Greenwich\",0],\r\n", + " UNIT[\"degree\",0.0174532925199433],\r\n", + " AUTHORITY[\"EPSG\",\"4326\"]]\r\n", + "Origin = (-180.000000000000000,10.000000000000000)\r\n", + "Pixel Size = (0.100000000000000,-0.100000000000000)\r\n", + "Metadata:\r\n", + " AREA_OR_POINT=Area\r\n", + " TIFFTAG_DATETIME=2019:06:01 13:35:13\r\n", + " TIFFTAG_DOCUMENTNAME=/NRTPUB/imerg/gis/2019/05/3B-HHR-L.MS.MRG.3IMERG.20190531-S233000-E235959.1410.V06B.1day.tif\r\n", + " TIFFTAG_IMAGEDESCRIPTION=DOI=10.5067/GPM/IMERG/3B-HH-L/06 DOIauthority=http://dx.doi.org/ DOIshortName=3IMERGHH_LATE Unit=0.1(mm) ScaleFactor=10\r\n", + " TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)\r\n", + " TIFFTAG_SOFTWARE=IDL 8.7.2, Harris Geospatial Solutions, Inc.\r\n", + " TIFFTAG_XRESOLUTION=100\r\n", + " TIFFTAG_YRESOLUTION=100\r\n", + "Image Structure Metadata:\r\n", + " COMPRESSION=LZW\r\n", + " INTERLEAVE=BAND\r\n", + "Corner Coordinates:\r\n", + "Upper Left (-180.0000000, 10.0000000) (180d 0' 0.00\"W, 10d 0' 0.00\"N)\r\n", + "Lower Left (-180.0000000, -60.0000000) (180d 0' 0.00\"W, 60d 0' 0.00\"S)\r\n", + "Upper Right ( -30.0000000, 10.0000000) ( 30d 0' 0.00\"W, 10d 0' 0.00\"N)\r\n", + "Lower Right ( -30.0000000, -60.0000000) ( 30d 0' 0.00\"W, 60d 0' 0.00\"S)\r\n", + "Center (-105.0000000, -25.0000000) (105d 0' 0.00\"W, 25d 0' 0.00\"S)\r\n", + "Band 1 Block=1500x2 Type=UInt16, ColorInterp=Gray\r\n" + ] + } + ], + "source": [ + "!gdalinfo '/notebooks/resources/gpm/gpm_1d.20190531.tif'" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/bin/sh: 1: gdal_edit: not found\r\n" + ] + } + ], + "source": [ + "!gdal_edit -colorinterp_1 alpha /notebooks/resources/gpm/gpm_1d.20190531.tif" + ] + }, + { + "cell_type": "code", + "execution_count": 10, "metadata": { "scrolled": false }, @@ -117,13 +193,13 @@ { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ - "" + "" ] }, - "execution_count": 41, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -131,10 +207,9 @@ "source": [ "m = folium.Map(\n", " location = [-22, -114]\n", - " , zoom_start = 1\n", + " , zoom_start = 2\n", " , control_scale = True \n", - "# , tiles = 'Stamen Terrain'\n", - "# , crs = 'EPSG4326'\n", + " , tiles = 'Stamen Terrain'\n", ")\n", "\n", "data = matplotlib.pyplot.imread(image)\n", @@ -144,96 +219,33 @@ "m.add_child(raster_layers.ImageOverlay(\n", " data\n", " , opacity = 0.7\n", - "# , bounds = [[-60, -30], [10, -180]]\n", - "# , bounds = [[10, -180], [-60, -30]]\n", - "# , bounds = [[10, -30], [-60, -180]]\n", " , bounds = [ext[2], ext[0]]\n", - "# , bounds = [[0.17453292519943298, -3.141592653589794], [-6679169.447596415, -3503549.843504376]]\n", " , mercator_project = True\n", + "# , colormap = lambda x: (1, 0, 0, x)\n", + " , colormap = colorcet.cm.bmw\n", ")\n", " )\n", "\n", - "# folium.Marker(\n", - "# ext[2]\n", - "# , popup = '-60, -30'\n", - "# , tooltip = '-60, -30'\n", - "# ).add_to(m)\n", - "\n", - "# folium.Marker(\n", - "# ext[0]\n", - "# , popup = '10, -180'\n", - "# , tooltip = '10, -180'\n", - "# ).add_to(m)\n", - "\n", - "# folium.Marker(\n", - "# [10, -30]\n", - "# , popup = '10, -30'\n", - "# , tooltip = '10, -30'\n", - "# ).add_to(m)\n", - "\n", - "# folium.Marker(\n", - "# [-60, -180]\n", - "# , popup = '-60, -180'\n", - "# , tooltip = '-60, -180'\n", - "# ).add_to(m)\n", - "\n", "folium.Marker(\n", - " [-8399737.89, -20037508.34]\n", - " , popup = 'uh...'\n", - " , tooltip = 'uh...'\n", + " ext[2]\n", + " , popup = str(ext[2])\n", + " , tooltip = str(ext[2])\n", ").add_to(m)\n", "\n", - "\n", + "folium.Marker(\n", + " ext[0]\n", + " , popup = str(ext[0])\n", + " , tooltip = str(ext[0])\n", + ").add_to(m)\n", "\n", "m" ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'_children': OrderedDict([('openstreetmap',\n", - " ),\n", - " ('image_overlay_029dcef611864ab69a5251c1e152a267',\n", - " ),\n", - " ('marker_1f4d013e5998403a9052985742ec7dd6',\n", - " )]),\n", - " '_env': ,\n", - " '_id': '264585f73b94452ca1f725f3a674fe99',\n", - " '_name': 'Map',\n", - " '_parent': ,\n", - " '_png_image': None,\n", - " 'control_scale': True,\n", - " 'crs': 'EPSG3857',\n", - " 'global_switches': ,\n", - " 'height': (100.0, '%'),\n", - " 'left': (0.0, '%'),\n", - " 'location': [-22, -114],\n", - " 'max_bounds': False,\n", - " 'max_lat': 90,\n", - " 'max_lon': 180,\n", - " 'min_lat': -90,\n", - " 'min_lon': -180,\n", - " 'no_wrap': False,\n", - " 'objects_to_stay_in_front': [],\n", - " 'png_enabled': False,\n", - " 'position': 'relative',\n", - " 'top': (0.0, '%'),\n", - " 'width': (100.0, '%'),\n", - " 'world_copy_jump': False,\n", - " 'zoom_control': True,\n", - " 'zoom_start': 1}" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "vars(m)" ] @@ -251,15 +263,6 @@ "# print(data.shape)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "!gdalinfo '/notebooks/resources/gpm/gpm_1d.20190531.tif'" - ] - }, { "cell_type": "code", "execution_count": null, @@ -291,7 +294,10 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "q = lambda x: (0, 0, 0, 0)\n", + "print(q(9))" + ] }, { "cell_type": "code",