Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

121 changes: 46 additions & 75 deletions samples/02_power_users_developers/openstreetmap_exploration.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.9"
},
"widgets": {
"state": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,25 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!conda install -c anaconda pillow -y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!conda install -c conda-forge imageio -y"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -71,7 +89,7 @@
"\n",
"import arcgis\n",
"from arcgis.gis import GIS\n",
"from arcgis import geometry\n",
"from arcgis import geometry, geocode\n",
"from arcgis.raster.functions import apply"
]
},
Expand All @@ -84,7 +102,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -107,7 +125,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -125,7 +143,7 @@
" </a>\n",
" <br/>Landsat multispectral and multitemporal imagery with on-the-fly renderings and indices for visualization and analysis. The Landsat 8 imagery in this layer is updated daily and is directly sourced from the Landsat on AWS collection.<img src='https://geosaurus.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/imagery16.png' style=\"vertical-align:middle;\">Imagery Layer by esri\n",
" <br/>Last Modified: December 19, 2019\n",
" <br/>0 comments, 259,890 views\n",
" <br/>0 comments, 378,680 views\n",
" </div>\n",
" </div>\n",
" "
Expand All @@ -134,7 +152,7 @@
"<Item title:\"Multispectral Landsat\" type:Imagery Layer owner:esri>"
]
},
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -178,6 +196,24 @@
"rgb_collection = apply(landsat, 'Natural Color with DRA')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"g = geocode('Hirakund reservoir, Odisha', out_sr=3857)[0]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"extent = g.get('extent')"
]
},
{
"cell_type": "code",
"execution_count": 14,
Expand All @@ -198,54 +234,50 @@
}
],
"source": [
"m = gis.map('Hirakund reservoir, Odisha', 10)\n",
"m.basemap = 'imagery'\n",
"\n",
"m = gis.map()\n",
"m.basemap = 'satellite'\n",
"m.extent = extent\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": 7,
"cell_type": "markdown",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
" 'xmin': 9251479.106444037,\n",
" 'ymin': 2433602.2844587043,\n",
" 'xmax': 9401907.17810932,\n",
" 'ymax': 2494751.907086869}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"extent = m.extent\n",
"extent"
"## Function to create collection of images with desired time intervals"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Function to create collection of images with desired time intervals"
"The function below creates an array of images with the desired time intervals. If a user specifies 'm' then the images in the selected collection will be consolidated on a monthly basis i.e. all the images of the specified extent will be mosaicked monthly and if the user specifies 'y' as the interval then the images in the selected collection will be consolidated on yearly basis."
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"The function below creates an array of images with the desired time intervals. If a user specifies 'm' then the images in the selected collection will be consolidated on a monthly basis i.e. all the images of the specified extent will be mosaicked monthly and if the user specifies 'y' as the interval then the images in the selected collection will be consolidated on yearly basis."
"from functools import lru_cache\n",
"\n",
"@lru_cache(maxsize=50)\n",
"def load_font():\n",
" try:\n",
" if system()=='Windows':\n",
" return ImageFont.truetype(\"arial.ttf\", 30)\n",
" elif system()=='Linux':\n",
" return ImageFont.truetype(\"~/.fonts/truetype/dejavu/DejaVuSans.ttf\", 30)\n",
" else:\n",
" return ImageFont.truetype(\"Arial.ttf\", 30)\n",
" except:\n",
" return ImageFont.load_default()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -263,12 +295,7 @@
" save_folder='.', \n",
" save_file=img_name)\n",
" img = Image.open(img_name).convert('RGB')\n",
" if system()=='Windows':\n",
" font = ImageFont.truetype(\"arial.ttf\", 30)\n",
" elif system()=='Linux':\n",
" font = ImageFont.truetype(\"~/.fonts/truetype/dejavu/DejaVuSans.ttf\", 30)\n",
" else:\n",
" font = ImageFont.truetype(\"Arial.ttf\", 30)\n",
" font = load_font()\n",
" draw = ImageDraw.Draw(img)\n",
" draw.text((550, 0),str(j)+\"-\"+str(i),(255,255,255),font=font)\n",
" images.append(img)\n",
Expand All @@ -285,12 +312,7 @@
" save_folder='.', \n",
" save_file=img_name)\n",
" img = Image.open(img_name).convert('RGB')\n",
" if system()=='Windows':\n",
" font = ImageFont.truetype(\"arial.ttf\", 30)\n",
" elif system()=='Linux':\n",
" font = ImageFont.truetype(\"~/.fonts/truetype/dejavu/DejaVuSans.ttf\", 30)\n",
" else:\n",
" font = ImageFont.truetype(\"Arial.ttf\", 30)\n",
" font = load_font()\n",
" draw = ImageDraw.Draw(img)\n",
" draw.text((550, 0),str(i),(255,255,255),font=font) \n",
" images.append(img)\n",
Expand Down Expand Up @@ -400,7 +422,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
"version": "3.7.9"
}
},
"nbformat": 4,
Expand Down