Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

117
Vistas
Using rgee and fastDistanceTransform with a featureCollection

I have successfully extracted distance to nearest human settlement with rgee function fastDistanceTransform, where the original layer is a single image (DLR/WSF/WSF2015/v1). I want to repeat this with distance to nearest road, but the road dataset is a featureCollection and not an image.

I have successfully converted to image in the gee code editor with:

var dataset = ee.FeatureCollection('TIGER/2016/Roads')
.map(function(feature){
    var num = ee.Number.parse(feature.get('linearid'));
    return feature.set('linearid', num);
});

  var roads = dataset
  .reduceToImage({
    properties: ['linearid'],
    reducer: ee.Reducer.first()
});

Map.setCenter(-99.976, 40.38, 5);
Map.addLayer(roads, {
});

But I cannot get it to repeat the same in the R package rgee. I am using code:

road = ee$FeatureCollection("TIGER/2016/Roads")$
  map(function(feature) { num = ee$Number$parse(feature$get('linearid'))
  return(feature$set('linearid', num)) })
road2 = road$reduceToImage(properties=road$select('linearid'), reducer=ee$Reducer$first())
Map$addLayer(road2, {}, "road2")

But I get the error:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
ee.ee_exception.EEException: Collection.reduceToImage, argument 'properties': Invalid type.
Expected type: List<String>.
Actual type: FeatureCollection.

Can anyone help me fix this error so I can continue using 'road2' as an image? I think it has something to do with this (https://github.com/r-spatial/rgee/issues/232) "It seems that passing an ee.Image object in Javascript immediately changes it to a List"

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't know the R language, but it looks like you made a mistake in your translation.

  var roads = dataset
  .reduceToImage({
    properties: ['linearid'],
    reducer: ee.Reducer.first()
});

Here the properties argument to reduceToImage is a list of strings.

road2 = road$reduceToImage(properties=road$select('linearid'), reducer=ee$Reducer$first())

Here you are not constructing a list, but instead calling road$select. So, the result is an image, not the list of strings that reduceToImage wants.

Maybe you want properties=list('linearid') ? Again, I don't know R or rgee, so I can't say whether this is correct.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda