Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resample SCL_20m to 10m and mask B03_10m #609

Open
arind123 opened this issue May 17, 2023 · 0 comments
Open

Resample SCL_20m to 10m and mask B03_10m #609

arind123 opened this issue May 17, 2023 · 0 comments

Comments

@arind123
Copy link

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 = B03
    10m.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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant