diff --git a/Task 9.ipynb b/CartopyImages.ipynb
similarity index 100%
rename from Task 9.ipynb
rename to CartopyImages.ipynb
diff --git a/FoliumImageOverlay.ipynb b/FoliumImageOverlay.ipynb
new file mode 100644
index 0000000..1134ab6
--- /dev/null
+++ b/FoliumImageOverlay.ipynb
@@ -0,0 +1,104 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import folium\n",
+ "import numpy as np\n",
+ "\n",
+ "image = np.zeros((61, 61))\n",
+ "image[0, :] = 1.0\n",
+ "image[60, :] = 1.0\n",
+ "image[:, 0] = 1.0\n",
+ "image[:, 60] = 1.0"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "m = folium.Map([37, 0], zoom_start=2)\n",
+ "\n",
+ "folium.raster_layers.ImageOverlay(\n",
+ " image=image,\n",
+ " bounds=[[0, -60], [60, 60]],\n",
+ " colormap=lambda x: (0, 1, 0, x),\n",
+ ").add_to(m)\n",
+ "\n",
+ "folium.Marker(\n",
+ " [-60, -30]\n",
+ " , popup = 'Northing(?)'\n",
+ " , tooltip = 'Northing(?)'\n",
+ ").add_to(m)\n",
+ "\n",
+ "folium.Marker(\n",
+ " [10, -180]\n",
+ " , popup = 'Easthing(?)'\n",
+ " , tooltip = 'Easthing'\n",
+ ").add_to(m)\n",
+ "\n",
+ "folium.Marker(\n",
+ " [0, -60]\n",
+ " , popup = 'Northing(?)'\n",
+ " , tooltip = 'Northing(?)'\n",
+ ").add_to(m)\n",
+ "\n",
+ "folium.Marker(\n",
+ " [60, 60]\n",
+ " , popup = 'Easthing(?)'\n",
+ " , tooltip = 'Easthing(?)'\n",
+ ").add_to(m)\n",
+ "\n",
+ "\n",
+ "m"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.5.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/Folium_2.ipynb b/Folium_2.ipynb
index c3dc283..7ff0fe4 100644
--- a/Folium_2.ipynb
+++ b/Folium_2.ipynb
@@ -24,18 +24,19 @@
},
{
"cell_type": "code",
- "execution_count": 55,
+ "execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "-180.0 10.0\n",
- "-180.0 -60.0\n",
- "-30.0 -60.0\n",
- "-30.0 10.0\n",
- "([-60.0, -30.0], [10.0, -180.0])\n"
+ "10.0 -180.0\n",
+ "-60.0 -180.0\n",
+ "-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"
]
}
],
@@ -62,8 +63,8 @@
" for py in yarr:\n",
" x=gt[0]+(px*gt[1])+(py*gt[2])\n",
" y=gt[3]+(px*gt[4])+(py*gt[5])\n",
- " ext.append([x,y])\n",
- " print (x,y)\n",
+ " ext.append([y,x])\n",
+ " print (y,x)\n",
" yarr.reverse()\n",
" return ext\n",
"\n",
@@ -92,45 +93,23 @@
"gt=ds.GetGeoTransform()\n",
"cols = ds.RasterXSize\n",
"rows = ds.RasterYSize\n",
+ "\n",
"ext=GetExtent(gt,cols,rows)\n",
+ "print(\"ext = \" + str(ext))\n",
"\n",
"src_srs=osr.SpatialReference()\n",
"src_srs.ImportFromWkt(ds.GetProjection())\n",
"# tgt_srs=osr.SpatialReference()\n",
- "# tgt_srs.ImportFromEPSG(4326)\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",
- "\n",
- "geo_fix = geo_ext\n",
- "geo_fix[0] = geo_fix[0][::-1]\n",
- "geo_fix[2] = geo_fix[2][::-1]\n",
- "extent = geo_fix[2], geo_fix[0]\n",
- "print(extent)\n"
+ "print(\"geo_ext = \" + str(geo_ext))"
]
},
{
"cell_type": "code",
- "execution_count": 58,
- "metadata": {},
- "outputs": [
- {
- "ename": "AttributeError",
- "evalue": "'tuple' object has no attribute 'reverse'",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mextent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreverse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'reverse'"
- ]
- }
- ],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 56,
+ "execution_count": 41,
"metadata": {
"scrolled": false
},
@@ -138,20 +117,24 @@
{
"data": {
"text/html": [
- ""
+ ""
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 56,
+ "execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"m = folium.Map(\n",
- " control_scale=True \n",
+ " location = [-22, -114]\n",
+ " , zoom_start = 1\n",
+ " , control_scale = True \n",
+ "# , tiles = 'Stamen Terrain'\n",
+ "# , crs = 'EPSG4326'\n",
")\n",
"\n",
"data = matplotlib.pyplot.imread(image)\n",
@@ -160,11 +143,99 @@
"# [[lat_min, lon_min], [lat_max, lon_max]]\n",
"m.add_child(raster_layers.ImageOverlay(\n",
" data\n",
- "# , bounds = [[-60.0000000000000000, -30.0000000000000000], [10.0000000000000000, -180.0000000000000000]]\n",
- " , bounds = extent\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",
")\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",
+ ").add_to(m)\n",
+ "\n",
+ "\n",
+ "\n",
+ "m"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "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"
+ }
+ ],
+ "source": [
+ "vars(m)"
]
},
{