Skip to content

Commit

Permalink
Merge of ensino and pythonverse in my repos.
Browse files Browse the repository at this point in the history
I deleted my original repo "ensino" and merged all programs here
  • Loading branch information
andrebelem authored May 18, 2022
1 parent d190b08 commit ea34288
Show file tree
Hide file tree
Showing 8 changed files with 2,249 additions and 1 deletion.
227 changes: 227 additions & 0 deletions Brasil3D sobre mapa antigo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "754b7bd1",
"metadata": {},
"source": [
"![](http://observatoriooceanografico.org/wp-content/uploads/elementor/thumbs/logo-o2-2-p31vla9ib17i85olifd4l1xk0e5lktrkal6u0s4c6o.png)<br>\n",
"# <center>Mapa do Brasil em relevo</center><br>\n",
"\n",
"Criado por [A.L. Belém](mailto:andrebelem@id.uff.br) @ [Observatório Oceanográfico](http://www.observatoiriooceanografico.uff.br) 2021 (versão 1) para disciplina de **Mudanças Climáticas e seus Impactos** (e para quem mais se interessar)<br>\n",
"[![DOI](https://zenodo.org/badge/342919527.svg)](https://zenodo.org/badge/latestdoi/342919527)\n",
"###### Última atualização: 16 de Junho de 2021.\n",
"<br>\n",
"Esse notebook foi construido com o objetivo de testar as possibilidades do Geemap para construção de mapas. Não é necessário saber todo o código de cabeça, mas ao menos você pode usar esse notebook para \"copiar\" algumas soluções quando for necessário.<br>\n",
"\n",
"Use preferencialmente o Jupyter Notebook com o `geemap` e o `ee` instalado."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "26b448bc",
"metadata": {},
"outputs": [],
"source": [
"# importa todas as bibliotecas necessárias\n",
"import ee\n",
"import geemap\n",
"import geemap.colormaps as cm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "84478a45",
"metadata": {},
"outputs": [],
"source": [
"# A autenticação só é necessária uma vez para usar o ee\n",
"#ee.Authenticate()\n",
"\n",
"# iniciar o acesso\n",
"ee.Initialize()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "75f015fd",
"metadata": {},
"outputs": [],
"source": [
"# cria um fundo branco com base em uma layer existente (não necessariamente você precisa fazer isso)\n",
"blank = ee.Image('NOAA/NGDC/ETOPO1').select('bedrock');\n",
"blank = blank.multiply(0) # blank background"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "92b0f817",
"metadata": {},
"outputs": [],
"source": [
"# separa um retângulo de interesse. Esse retângulo foi extraido da linha posterior ao mapa com Map.draw_last_feature\n",
"AOI = ee.Feature({'type': 'Feature',\n",
" 'geometry': {'geodesic': False,\n",
" 'type': 'Polygon',\n",
" 'coordinates': [[[-84.023438, -36.738884],\n",
" [-84.023438, 13.410994],\n",
" [-33.75, 13.410994],\n",
" [-33.75, -36.738884],\n",
" [-84.023438, -36.738884]]]},\n",
" 'properties': {}})"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "e2c0282c",
"metadata": {},
"outputs": [],
"source": [
"# escolhe o dataset de elevação\n",
"elevation = ee.Image('USGS/SRTMGL1_003');\n",
"\n",
"exaggeration = 200; # aqui controla o exagero vertical.\n",
"azimuth = 30 # azimute da fonte de luz\n",
"zenith = 65 # elevação da fonte de luz é 90 - azimuth\n",
"hillshade = ee.Terrain.hillshade(elevation.multiply(exaggeration), azimuth, 90-zenith);\n",
"\n",
"# versão 2 - fazendo um hillshade para o mapa antigo também, com um exagero menor\n",
"exaggeration2 = 100; # aqui controla o exagero vertical.\n",
"hillshade2 = ee.Terrain.hillshade(elevation.multiply(exaggeration), azimuth, 90-zenith);\n",
"\n",
"fao_gaul = ee.FeatureCollection(\"FAO/GAUL/2015/level1\")\n",
"Brasil = fao_gaul.filter(ee.Filter.eq('ADM0_NAME', 'Brazil'))\n"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "b719d34f",
"metadata": {},
"outputs": [],
"source": [
"# cortesia - Um mapa antigo da América do Sul registrado usando georeferencer\n",
"# há uma pequena distorção na costa, mas...é o preço da evolução\n",
"basemap = ee.Image('users/andrebelem/AmericaDoSul_oldmap')\n",
"vizParams = {\n",
" 'bands': ['b1', 'b2', 'b3'],\n",
" 'min': 0,\n",
" 'max': 253,\n",
" 'gamma': [0.95, 1.1, 1],\n",
" 'opacity': 0.5, # mude a opacidade se desejar. \n",
"};"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "bdf93cff",
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6a2c629b546342b59c68de8702e0aa9f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[-12.7261, -54.6657], controls=(WidgetControl(options=['position', 'transparent_bg'], widget=HBox(c…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Constroi o mapa com base no centro do Brasil. Mude como desejar.\n",
"\n",
"Map = geemap.Map(center=(-12.7261,-54.6657),zoom=4)\n",
"Map.add_basemap('Esri Shaded Relief')\n",
"Map.addLayer(blank, {'bands': ['bedrock'], 'min': 0, 'max': 0, 'palette': ['white'], 'opacity': 0.7}, 'background')\n",
"Map.addLayer(AOI,{'outline_color':'black'},'AOI') # linha ao redor do mapa\n",
"Map.addLayer(basemap.clip(AOI),vizParams,'AS')\n",
"Map.addLayer(hillshade2.clip(AOI), {'bands': ['hillshade'], 'min': 0, 'max': 255, 'palette': cm.palettes.gray, 'opacity': 0.3}, 'Map Hillshade')\n",
"\n",
"dem_cm = cm.palettes.gist_earth_r\n",
"\n",
"Map.addLayer(Brasil,{'outline_color':'gray','opacity':0.8},'Brasil') # linha ao redor do Brasil\n",
"\n",
"Map.addLayer(elevation.clip(Brasil), {'bands': ['elevation'], 'min': 0, 'max': 1500, 'palette': dem_cm}, 'elevation')\n",
"Map.addLayer(hillshade.clip(Brasil), {'bands': ['hillshade'], 'min': 0, 'max': 255, 'palette': cm.palettes.gray, 'opacity': 0.6}, 'ETOPO1 Hillshade')\n",
"\n",
"Map"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "c9b1de30",
"metadata": {},
"outputs": [],
"source": [
"# para extrair um novo retângulo AOI, desenhe sobre o mapa acima e descomente as linhas abaixo.\n",
"\n",
"#aa = Map.draw_last_feature\n",
"#aa.getInfo()"
]
}
],
"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.9.4"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added Brasil3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ea34288

Please sign in to comment.