Earth-Information-System / fireatlas

https://earth-information-system.github.io/fireatlas/docs/
7 stars 3 forks source link

Bad Geometries and International Date Line Issues #118

Closed ranchodeluxe closed 2 months ago

ranchodeluxe commented 2 months ago

Problem

Russia presents a couple problems:

  1. We have quite a few geometries that when serialized to JSON are NaN and cause internal server errors during serialization:

SELECT primarykey from eis_fire_snapshot_perimeter_nrt where NOT ST_IsValid(geometry);

This statement above can help identify them (and delete them) but we need to find the core issue

  1. In the picture below we can also see a number of Russian polygons are wildly mis-projected over Greenland and need to find the source. This might be b/c our bbox crosses the international date line
Screen Shot 2024-08-06 at 4 36 42 AM
ranchodeluxe commented 2 months ago

still unsure if number 2 above is international date line issues but even when trying to render the source data in a notebook we quickly end up in this situation:

from fireatlas import FireIO, preprocess,  postprocess
import branca.colormap as cm
import folium
import pandas as pd

tst = [2024, 8, 5, "AM"]
ted = [2024, 8, 6, "AM"]
region = ("RussiaEast", [97.16172779881556, 46.1226744036175, 168.70469654881543, 77.81982396998427])

region = preprocess.read_region(region, location="s3")
# df = postprocess.read_allpixels(tst, ted, region, location="s3")
gdf = postprocess.read_allfires_gdf(tst, ted, region, location="s3").reset_index()
gdf.head(3)
gdf[gdf['t'].dt.date == pd.to_datetime('2024-08-02').date()].head(3)
gdf.crs
mymap = folium.Map(zoom_start=12)
color = 'blue'
data = gdf
# put the region on the map
folium.GeoJson(
    region[1],
    style_function=lambda x: {'fillColor': 'pink', 'color': 'red', 'weight': 2}
).add_to(mymap)
folium.GeoJson(
    data["hull"],
    name=f"perimeter",
    color=color,
    fill_opacity=0.2,
    weight=3, 
).add_to(mymap) 
mymap
Screen Shot 2024-08-06 at 7 57 05 AM
ranchodeluxe commented 2 months ago

Still on the international date line hunch and rerunning all of RussiaEast with a new bbox to test the theory. About three hours out from that being finished

ranchodeluxe commented 2 months ago

It was the international date line. I win 🎖️

Screen Shot 2024-08-07 at 5 00 41 PM