centreborelli / s2p

Satellite Stereo Pipeline
GNU Affero General Public License v3.0
208 stars 67 forks source link

RPC rectification using Planet Scope Scenes #141

Open FergusDal opened 1 year ago

FergusDal commented 1 year ago

I am experiencing issues applying the s2p pipeline to Planet Scope Scenes. Particularly, it seems that the rectification isn't working properly. Upon visual inspection, the rectification pairs seem to be shifted, and not correctly coregistered. (See attached red and green image). Rectification_Issue

I am using two PlanetScope Basic Scenes (level 1B), (Names: 20201124_031355_67_1064_1B_AnalyticMS, 20201126_031738_79_105d_1B_AnalyticMS), with"rectification method" = "rpc". If I am reading the source code correctly, the code assumes the accompanying RPC txt files can be parsed the same as ikonos rpc files. Do you know if Planet and Ikonos rpc files are really compatible? Or do you have any other ides why it is not working?

Attached is also the config file. The images were converted to grayscale before introduction to the pipeline by simply averaging the 4 channels. I also tested with original images, they also seem to not rectify properly.

config.txt

gfacciol commented 1 year ago

Hi!
Could you try "rectification_method": "sift" instead of "rpc" ? My guess is that the RPC are not globally adjusted, so it's better to ignore them for the rectification.

jveitchmichaelis commented 1 year ago

Thanks @gfacciol I had a play around with the config. Apologies for the late reply, I've been in the field. This seems to work well:

Initial band merging (one image for example):

echo 20201124_031355_67_1064_1B_AnalyticMS.tif | xargs -I{} gdal_calc.py -R {} --R_band=1 -G {} --G_band=2 -B {} --B_band=3 --outfile=gray.tif --calc="R*0.2989+G*0.5870+B*0.1140"
{
  "clean_tmp": true,
  "clean_intermediate": false,
  "out_dir" : "./output/",
  "images" : [
    {"img" : "files/PSScene/20201124_031355_67_1064/basic_analytic_udm2/gray.tif"},
    {"img" : "files/PSScene/20201126_031738_79_105d/basic_analytic_udm2/gray.tif"}
    ],
  "roi": {
      "x": 0,
      "y": 0,
      "w": 3000,
      "h": 3000
   },
  "full_img": true,
  "horizontal_margin": 128,
  "vertical_margin": 128,
  "tile_size" : 1024,
  "disp_range_method" : "sift",
  "rectification_method": "rpc",
  "dsm_resolution": 0.5,
  "use_srtm": true
}

I'm not sure what we had set up wrong the first time, but this seems to produce a decent DEM!

gfacciol commented 1 year ago

Hi @jveitchmichaelis, the config looks good! You can also try using "rectification_method": "sift" that's because if rpcs are not too precise the epipolar rectification based on rpcs can lead to poorer DEMs. let me know if it improves. best g