The full source code for the same can be found here.
- If you do not have the data yet, you can download it from here. I downloaded the Admin 1 boundary, but this method is generic, so applies to any shapefile that you have.
- Open up the QGIS or any other GIS software that you use. Load the shapefile and see the attributes tables to find out about the column name and the list of values that column posses. In the image below: ADM1_NAME is the name of the column and the values underneath eg. Hoa Binh, Thanh Hoa, … are the range of values. Make note of the value(s) that you are interested in.
- Now in Earth Engine, import the assets that you want to filter and display the result to ensure that this is the area that you want to filter. In this tutorial, I show you how you can upload your shapefile to the Earth Engine asset.
var vietnam = ee.FeatureCollection('users/biplov/blog/vietnam_admin1'); Map.centerObject(vietnam); Map.addLayer(vietnam, {color: 'red'}, 'vietnam');
- We will use ee.Filter objects and the associated method to do the filtering, in particular for this exercise we will use ee.Filter.inList method. From step 1, we have two areas of interests. Lets filter to those areas.
var filter = ee.Filter.inList('ADM1_NAME', ['Hoa Binh', 'Thanh Hoa']); var filteredArea = vietnam.filter(filter); Map.addLayer(filteredArea, {color: 'green'}, 'filteredArea');
Matthew
fantastic, I have finally been able to filter my featureCollection import now! thanks
席茜
but when I using the shape i upload to calculate the NDVI ,the label could not be defined as exsiting column .
biplovbhandari
sharing an link would be helpful!
席茜
https://code.earthengine.google.com/?scriptPath=users%2F737766908%2FHS%3Ahs
could you open it?
biplovbhandari
Nope. You have to open the link in your code editor and do ‘Get Link’. Make sure that your assets are shared as well.
席茜
https://code.earthengine.google.com/e2ff8de3f7046c5d1a6bdd416a8c2738
sorry ,my skill is not good.
biplovbhandari
I cannot access your table. You need to make sure anyone can read it (i.e. public) by going into your asset tab and sharing it.
席茜
I share the table with anyone ,could you try it again?
Akinchan
Hi Biplov
Could you help me about display the label/text of a shapefile. I have to display few POI’s city with over raster layer and dont want to show the detailed default base map in GEE.
Thanks