Untitled
unknown
r
3 years ago
3.7 kB
11
Indexable
wrongpx <- c("-9.396.641.882.422.890", "-9.304.622.681.824.810", "13.515.417.370.886.000", "-8.684.257.026.170.890", "-8.680.770.919.984.900", "101.834.611.826.965", "10.193.100.706.617.700", "10.219.990.723.712.100", "10.313.323.895.851.700", "5.198.622.854.348.800", "522.966.036.530.991", "6.672.059.968.614.300", "6.697.346.426.121.210", "670.996.448.642.307", "6.720.674.470.567.420", "60.134.382.334.850.000", "60.358.967.578.939.100", "655.790.249.036.627", "6.702.098.047.006.890", "-12.277.098.166.184.200", "-12.267.759.787.278.000", "-12.136.473.166.184.200", "-11.979.368.673.996.700", "-6.719.010.128.031.270", "-6.702.393.306.742.210", "-6.684.746.517.191.430") wrongpy <- c( "4.225.003.901.908.680", "4.206.714.810.932.560", "5.302.157.955.780.640", "11.730.648.534.943.100", "11.828.070.365.345.800", "5.894.885.808.037.180", "5.932.599.814.986.280", "5.889.994.746.157.780", "5.882.713.438.605.430", "6.284.896.677.254.320", "62.819.013.513.968.700", "6.126.754.103.873.870", "6.127.211.626.918.860", "61.003.898.331.081.600", "6.116.571.037.144.940", "3.357.720.064.449.210", "3.393.496.429.223.080", "3.358.795.385.883.850", "3.344.483.505.654.630", "7.374.168.244.137.070", "7.331.809.399.301.800", "7.312.782.500.181.960", "7.379.300.296.546.410", "5.768.235.196.120.210", "5.761.327.342.878.430", "57.663.625.566.576.200" ) images <- c("20200211T170421_20200211T170703_T15TVG", "20200211T170421_20200211T170703_T15TVG", "20200531T102031_20200531T102434_T32UQD", "20190519T155911_20190519T161919_T16PEU", "20190519T155911_20190519T161919_T16PEU", "20200302T042659_20200302T042843_T48VUL", "20200302T042659_20200302T042843_T48VUL", "20200302T042659_20200302T042843_T48VUL", "20200302T042659_20200302T042843_T48VUL", "20210716T080611_20210716T080610_T39VWK", "20210716T080611_20210716T080610_T39VWK", "20200718T070619_20200718T070622_T42VUN", "20200718T070619_20200718T070622_T42VUN", "20200718T070619_20200718T070622_T42VUN", "20200718T070619_20200718T070622_T42VUN", "20200226T101909_20200226T102438_T32SKC", "20200226T101909_20200226T102438_T32SKC", "20200226T101909_20200226T102438_T32SKC", "20200226T101909_20200226T102438_T32SKC", "20220524T202851_20220524T203032_T10XEG", "20220524T202851_20220524T203032_T10XEG", "20220524T202851_20220524T203032_T10XEG", "20220524T202851_20220524T203032_T10XEG", "20200313T153929_20200313T154432_T19VFD", "20200313T153929_20200313T154432_T19VFD", "20200313T153929_20200313T154432_T19VFD") wrong_df <- data.frame(x = wrongpx, y = wrongpy, s2id = images) # remove points with gsub but no sign wrong_df$x <- as.numeric(gsub("[^0-9-]", "", wrong_df$x)) wrong_df$y <- as.numeric(gsub("[^0-9-]", "", wrong_df$y)) xpossible <- c(10**15, 10**14, 10**16, 10**13) ypossible <- c(10**15, 10**14, 10**16, 10**13) combs <- expand.grid(x = xpossible, y = ypossible) library(rgee) library(sf) ee_Initialize() container <- list() for (index in 1:26) { print(index) # Create a image footprint img <- ee$Image(sprintf("COPERNICUS/S2/%s", wrong_df$s2id[index])) img_geo <- ee_as_sf(img$geometry()) for (index2 in 1:16) { # create a sf object with the possible combinations x_possible_coord <- wrong_df$x[index]/combs$x[index2] y_possible_coord <- wrong_df$y[index]/combs$y[index2] possible_st_point <- st_as_sf(st_sfc(st_point(c(x_possible_coord, y_possible_coord)), crs = 4326)) # intersect the two sf objects; return true or false if (st_intersects(possible_st_point, img_geo, sparse = FALSE)[[1]]) { break } } container[[index]] <- st_coordinates(possible_st_point) } write.csv(do.call(rbind, container), "wrong_coords.csv")
Editor is loading...