El mapeo geoespacial de variables ambientales es clave para comprender los hábitats y, en este caso, los hábitats urbanos. Hemos investigado en mapas de temperatura almacenados en la nube con Raspberrys y un servidor de Istsos, esta vez hemos acoplado un sensor GPS para hacer un mapa de temperatura urbano a partir de los datos descargados del servidor Istsos. Este tutorial muestra el procedimiento para recuperar los datos, convertirlos en un marco de datos de geopandas, exportarlos como un archivo de forma ESRI y comprender la relación de distribución de temperatura con la cobertura terrestre.
@gidahatari Ejemplo de la toma de temperatura geoespacial en una plataforma cloud y llamando los datos desde Python
♬ sonido original - gidahatari
#import required packages
from requests.auth import HTTPBasicAuth
from requests.packages.urllib3.exceptions import InsecureRequestWarning
import matplotlib.pyplot as plt
import requests, json, os, math
from dotenv import load_dotenv
import pandas as pd
import geopandas as gpd
import folium
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
#load credentials
load_dotenv('envViewer.txt')
user = os.getenv('ISTSOSUSER')
password = os.getenv('ISTSOSPASSWORD')
auth = HTTPBasicAuth(user, password)
#set istsos urls
url = 'https://apps.hatarilabs.com/istsos'
service = 'temperature'
procedure = 'genericGeoSensor'
off = 'tempnetwork'
#define dates
beginTime = "2023-06-15T00:00:00-05:00"
endTime = "2023-06-16T20:00:00-05:00"
#get observations
observedProperties = requests.get(
'%s/wa/istsos/services/%s/operations/getobservation/offerings/'
'%s/procedures/%s/observedproperties/:/eventtime/%s/%s' % (
url, service, off, procedure,beginTime,endTime),
params={
"qualityIndex": "False"
}, auth=auth)
#print observed values as list
observedList = observedProperties.json()['data'][0]['result']['DataArray']['values']
print(observedList[-1])
#create dataframe
observedDf = pd.DataFrame(columns=['Date','Lon','Lat','Elev','Temp'])
observedDf['Date'] = pd.to_datetime([i[0] for i in observedList])
observedDf['Lon'] = [i[1] for i in observedList]
observedDf['Lat'] = [i[2] for i in observedList]
observedDf['Elev'] = [i[3] for i in observedList]
observedDf['Temp'] = [i[4] for i in observedList]
observedDf = observedDf.set_index('Date')
#create geodataframe
geometry = gpd.points_from_xy(observedDf.Lon, observedDf.Lat)
obsGeoDf = gpd.GeoDataFrame(
observedDf[['Lon','Lat','Elev','Temp']], geometry=geometry
)
#for online map
meanLat = obsGeoDf.Lat.mean()
meanLon = obsGeoDf.Lon.mean()
map = folium.Map(location=[meanLat, meanLon], zoom_start=17)
# Create a geometry list from the GeoDataFrame
geoDfList = [[point.xy[1][0], point.xy[0][0]] for point in obsGeoDf.geometry]
i = 0
for index,coordinates in enumerate(geoDfList):
partialTemp = obsGeoDf.iloc[index].Temp
tempDelta = 10**(partialTemp - obsGeoDf.Temp.mean())
map.add_child(folium.Circle(location=coordinates,radius=tempDelta,popup=partialTemp,icon=folium.Icon(color="%s" % "lightgray")))
map
['2023-06-15T10:20:58.387386-05:00', -76.992182, -12.114250666666667, 177.7, 23.6875]
Make this Notebook Trusted to load map: File -> Trust Notebook