LaPoGeoMar / geoquimica_marinha

Atividades das aulas de geoquímica do curso de oceanografia da UFSC
3 stars 2 forks source link

Como arrumar as posições colhidas em formatos diferentes #11

Closed ocefpaf closed 2 years ago

ocefpaf commented 2 years ago
import numpy as np
import re

def fix_positions(pos):
    if pos.lower() in ["lat", "long"]:
        return np.NaN
    deg, rest = re.split("º|°", pos)
    mn, *rest = rest.split("'", maxsplit=1)
    rest = [val for val in rest if val][0]
    sec = rest.replace(",", ".").strip("''").strip('"W').strip('"S')
    deg, mn, sec = list(map(float, (deg, mn, sec)))
    return -(deg +  (mn/60) + (sec/60/60))

lons, lats = [], []
for k, row in df.iterrows():
    lon, lat = row["Long"], row["Lat"]
    try:
        lon, lat = list(map(float, (lon, lat)))
        if lat > 0:
            lat = -1*lat
    except ValueError:
        lon, lat = list(map(fix_positions, (lon, lat)))
    lons.append(lon)
    lats.append(lat)
ocefpaf commented 2 years ago
import folium
import folium.plugins
import geopandas

attr = "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community"
tiles = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"

m = folium.Map(zoom_start=15,
    location=[-27.5822, -48.5161],
    tiles=tiles,
    attr=attr,
)

# Descomente o código abaixo se você tiver a arquivo georeferenciado do mangue.
# folium.GeoJson(gdf).add_to(m)
# gdf = geopandas.read_file("./Manguezal_Itacorubi/itacorubi.geojson")
# meters = gdf.to_crs(epsg=3395)  # WGS 84 / World Mercator
# m.fit_bounds(m.get_bounds())

folium.plugins.Fullscreen(force_separate_button=True).add_to(m)

for k, row in df.iterrows():
    lat, lon = row["Lat"], row["Long"]
    folium.Marker(location=[lat, lon]).add_to(m)
ocefpaf commented 2 years ago

Note to self: fazer um app pyscript mais genérico para poder arrumar as planilhas antes do arquivamento.