1

I have here a shapefile which contains some limits of productive areas from the company I work for.

When I open it with ArcMap it seems there are only polygons, and indeed the source tab from layer properties shows it as I said (Geometry Type: Polygon).

In the other hand, when I upload the shapefile (with all possibles complements - shp, shx, sbn, etc), I see there are a bunch of features (about 13 among thousands of areas) which is written as Linestring.

Why does it occur and is there any way of selecting only the Features written as Polygon?

PS: Maybe my script is failing in filtering bounds based on this Feature Collection because of this issue, because when I try to use filterBounds() method with other Feature Collection (with no Linestring type) it works well, but in this particular case it doesn't.

2

Why does it occur

In Earth Engine, geometries may become a type of lower dimension (polygon to line string, line string to point) when their area or length becomes zero. This is usually seen when a reprojection collapses an edge; for example, in latitude-longitude coordinates there are many different points of +90° latitude, but in a projection suitable for mapping the north pole, they would all be the same point.

In this case, I suspect that your data includes some degenerate polygons (zero area) which become line strings when transformed into Earth Engine's data format.

and is there any way of selecting only the Features written as Polygon?

It'll be a two-step process, because Earth Engine doesn't offer filters directly on geometry type. First, define a property with the geometry type, then filter the collection on it:

var polygons = features
    .map(function (f) { return f.set('geometry_type', f.geometry().type()); })
    .filter(ee.Filter.equals('geometry_type', 'Polygon'));

Caveats:

  • This is not an efficient filter that can use an index of the collection — it has to look at every feature. So it is not appropriate for efficiently selecting a few features out of a very large collection, but it is appropriate for removing some bad data.
  • Remember that 'MultiPolygon' is a different geometry type from 'Polygon'. In your particular case, this shouldn't be a problem, but in a case where some geometries have more than one polygon one might want to filter for 'Polygon' or 'MultiPolygon'.
2
  • Thanks a lot man! I'll try here and return you a feedback! – caio.valente14 Feb 24 at 17:02
  • I've just tried what you said and it worked very well for me! Although, I still couldn't filter the Landsat 8 Image Collection with the Feature Collection. Could it be due to the length of Feature Collection (over 5000)? But what you really helped me to get Linestrings out of the Collection, thanks for that! – caio.valente14 Feb 24 at 17:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.