-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Hi Everyone, Has anyone ever tried to mask Sentinel 2 10mt bands using SCL band 20mt. If so can someone help out with the workflow. Following is what I tried:
- Read B03_10m
- Read SLC_20m
- Correct cell type of B03_10m
- Resample SCL_20m to 10m using B03_10m tile
- Mask B03_10m with SCL _10m
Code:
-
B03_10m = spark.read.raster("T22KGB_20190125T132231_B03_10m.tif")
-
SCL_20m = spark.read.raster("T22KGB_20190125T132231_SCL_20m.tif")
-
ct = B0310m.select(rf_cell_type('proj_raster')).distinct().first()[0]
masked_ct = CellType(ct).with_no_data_value(-99.9)
converted_B03_10m = B0310m.select("proj_raster_path",rf_convert_cell_type('proj_raster',
masked_ct).alias('proj_raster')) -
sqlc.registerDataFrameAsTable(SCL_20m, "SCL_20m")
sqlc.registerDataFrameAsTable(B03_10m, "B03_10m")
SCL_10m = sqlc.sql(""" SELECT proj_raster_path, rf_resample(proj_raster, (Select proj_raster from B03_10m), 'average') as proj_raster FROM SCL_20m """) -
masked = converted_B03_10m.withColumn('_masked', rf_mask_by_values('proj_raster', SCL_10m.proj_raster, [0, 1, 8, 9, 10]))
But I get the following error :AnalysisException: Resolved attribute(s) proj_raster#16883 missing from proj_raster#17911 in operator !Project [proj_raster#17911, rf_mask_by_values(proj_raster#17911, proj_raster#16883, array(0, 1, 8, 9, 10)) AS _masked#17949]. Attribute(s) with the same name appear in the operation: proj_raster. Please check if the right attribute(s) are used.;
I am a newbie to Rasterframes and Spark. Would be great if someone could help me out?