use a client-side shapefile to filter server-side object #89
Unanswered
pablovelasquezfranco
asked this question in
Q&A
Replies: 1 comment
-
One way would be to load shapefile in QGIS, query geometries from the shapefile layer using PyQGIS API, and then transform them into EE objects to use as a filter. Keep in mind that this is not the fastest way as EE geometries will have to be created as GeoJSON strings, this will involve a costly client-server round trip. So, it would make sense to simplify them of pass only bounds. The following code snippet demonstrates this: import json
import ee
from ee_plugin import Map
geometries = []
layer = QgsProject.instance().mapLayersByName("hydrobasins_africa")[0]
for f in layer.getFeatures():
geom = ee.Geometry(json.loads(f.geometry().asJson(precision=3)))
geometries.append(geom)
break
features = ee.FeatureCollection(geometries)
Map.addLayer(features, {}, 'features')
images = ee.ImageCollection('COPERNICUS/S2') \
.filterBounds(features.geometry()) \
.filterDate('2020-01-01', '2020-02-01')
Map.addLayer(images.mosaic(), { 'bands': ['B12', 'B8', 'B4'], 'min': 500, 'max': 5000 }, 'images') For larger shapefiles, you can always import shapefile into EE and then query it from QGIS, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Does anybody know how to filter an EE.Collection with a client shapefile using command line in QGis?
Beta Was this translation helpful? Give feedback.
All reactions