adugnag / gee_s1_ard

Creates an analysis ready sentinel-1 SAR image collection in Google Earth Engine by applying additional border noise correction, speckle filtering and radiometric terrain normalization.
MIT License
233 stars 83 forks source link

s1_preprocess does not show on python folium map. #22

Closed fekenzofugi closed 2 months ago

fekenzofugi commented 2 months ago

Nothing is ploted when FORMAT='DB'.

#Parameters
parameter = {  'START_DATE': '2016-06-23',
            'STOP_DATE': '2020-02-01',
            'POLARIZATION': 'VVVH',
            'ORBIT' : 'BOTH',
            'ROI': train_aoi,
            'APPLY_BORDER_NOISE_CORRECTION': True,
            'APPLY_SPECKLE_FILTERING': True,
            'SPECKLE_FILTER_FRAMEWORK':'MULTI',
            'SPECKLE_FILTER': 'BOXCAR',
            'SPECKLE_FILTER_KERNEL_SIZE': 10,
            'SPECKLE_FILTER_NR_OF_IMAGES':15,
            'APPLY_TERRAIN_FLATTENING': True,
            'DEM': ee.Image('USGS/SRTMGL1_003'),
            'TERRAIN_FLATTENING_MODEL': 'VOLUME',
            'TERRAIN_FLATTENING_ADDITIONAL_LAYOVER_SHADOW_BUFFER':0,
            'FORMAT': 'LINEAR',
            'CLIP_TO_ROI': True,
            'SAVE_ASSET': False,
            'ASSET_ID': "",
            'FOLDER_NAME': "s1_data"
            }
#processed s1 collection
s1_processed = s1_preproc(parameter)

s1 = s1_processed[0]
s1_processed = s1_processed[1]
visparam = {}
if (parameter["POLARIZATION"]=='VVVH'):
    if (parameter["FORMAT"]=='DB'):
        s1_processed_view = s1_processed.map(add_ratio_lin).map(lin_to_db2)
        s1_view = s1.map(add_ratio_lin).map(lin_to_db2)
        visparam = {"bands":['VV','VH','VVVH_ratio'],"min": [-20, -25, 1],"max": [0, -5, 15], "gamma": 1.1}

    else:
        s1_processed_view = s1_processed.map(add_ratio_lin)
        s1_view = s1.map(add_ratio_lin)
        visparam = {"bands":['VV','VH','VVVH_ratio'], "min": [0.01, 0.0032, 1.25],"max": [1, 0.31, 31.62], "gamma": 1.1}

else:
    if (parameter["FORMAT"]=='DB'):
        s1_processed_view = s1_processed.map(lin_to_db)
        s1_view = s1.map(lin_to_db)
        visparam = {"bands":[parameter["POLARIZATION"]],"min": -25,"max": 0}

    else:
        s1_processed_view = s1_processed
        s1_view = s1
        visparam = {"bands":[parameter["POLARIZATION"]],"min": 0,"max": 0.2}

print(visparam)
center = train_aoi.centroid(10).coordinates().reverse().getInfo()
m = folium.Map(location=center, zoom_start = 12)

m.add_ee_layer(
    s1_view.first(), visparam, "First image in the input S1 collection", False
)
"""
m.add_ee_layer(
    s1_processed_view.first(), visparam, "First image in the processed S1 collection", True
)

m.add_ee_layer(
    train_s2_col_list[0].mosaic().clip(train_aoi),
                    {'bands': ['B4', 'B3', 'B2'], 'min': 0, 'max': 2500, 'gamma': 1.1},
                    f'S2 image', False, 1, 9
)

m.add_child(folium.LayerControl())

display(m)
adugnag commented 2 months ago

Well, it works for me using the following code. So you may want to change the way the images are added to folium.

Visualize

import folium s1_preprocces_view = s1_processed.map(add_ratio_lin).map(lin_to_db2); visparam = {'bands':['VV', 'VH','VVVH_ratio'],'min': [-20, -25, 1],'max': [0, -5, 15]}

Use folium to visualize the imagery.

s1_processed_mapid = s1_preprocces_view.first().getMapId(visparam)

map = folium.Map(location=center)

folium.TileLayer( tiles=s1_processed_mapid['tile_fetcher'].url_format, attr='Map Data © Google Earth Engine', overlay=True, name='Preprocessed S1', ).add_to(map)

map.add_child(folium.LayerControl()) map

fekenzofugi commented 2 months ago

It didn't work for me, the image only appears when FORMAT = 'LINEAR'. But thanks for the help.