My goal is to sample some coordinates that ly exactly in the center of a Landsat pixel. For this sampling, i use the clHs Unfortunately, my exported .gpx coordinates are not located in pixel-center, fortunately, they are in the right location. It is not necessary sind clHs computed indexes , with whom one my select the specified sampling site from the Original SpatialPointDataFrame(spdf)







coords = cbind(x, y)

sp = SpatialPoints(coords)

data <- data.frame(name=c("w24","W1","W2","W3"))

spdf = SpatialPointsDataFrame(coords, data)


transformed <- spTransform(spdf, CRS("+init=epsg:4326"))

td <- file.path(getwd(), "Points.gpx")

writeOGR(obj=transformed,layer ='name' , dsn=td,
     driver='GPX',dataset_options = "GPX_USE_EXTENSIONS=yes")

I Copied the Results into GoogleEarthEngine and made a Visualisation.

Link to GeeScript for Point Quality Assesment

  • 1
    This is a bit unclear. Do you want to find the nearest pixel centre to each of your points? – Spacedman Mar 22 at 10:54
  • rasterToPoints converts a Raster to Points, and thereby assigns coordinates to these Points. But unfortunately they are not in Center of the Pixels – Alexander Vocaet Mar 22 at 11:06
  • 1
    You don't show that. How is your GPX file relevant? r = raster(); rasterToPoints(r)[1:10,]` are in the pixel centres. – Spacedman Mar 22 at 12:12
  • 1
    At the moment I think this is unsolvable because I guess you are doing a load of stuff with clhs that you haven't shown us and somewhere things are getting off. Any chance you can make a reproducible example? – Spacedman Mar 22 at 12:26
  • 1
    Its not obvious to me now what your question is. You present some coordinates and then transform them and then a link to google earth engine. Where's the raster grid you expect these to be the centres of? Why do you expect that? – Spacedman Mar 22 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.