I am using Python
to work with Google Earth Engine. I would like to extract some data for Paris.
I got the shapefile of Paris and I extracted its boundary as shown below:
import ee
ee.Initialize()
import geopandas as gpd
from shapely.geometry import Polygon
import pylab as plt
gdf = gpd.read_file('drive/MyDrive/Colab Notebooks/shapefiles/France/COMMUNE-shp/') ## Paris metro area
gdf = gdf.to_crs(epsg=4326)
def returnCityBoundary(gdf):
## from shapefile it returns city boundary as a rectangle in different format
#### polygon_geom: shapely polygon
#### polygon: geopandas dataframe
#### geometry: Earth Engine polygon
bounds = gdf.total_bounds
lon_point_list = [bounds[0], bounds[0], bounds[2], bounds[2]]
lat_point_list = [bounds[1], bounds[3], bounds[3], bounds[1]]
polygon_geom = Polygon(zip(lon_point_list, lat_point_list))
crs = {'init': 'epsg:4326'}
polygon = gpd.GeoDataFrame(index=[0], crs=crs, geometry=[polygon_geom])
geometry = ee.Geometry.Polygon(
[[[bounds[0], bounds[1]],
[bounds[0], bounds[3]],
[bounds[2], bounds[3]],
[bounds[2], bounds[1]]]])
return polygon_geom, polygon, geometry
polygon, gdf_polygon, geometry = returnCityBoundary(gdf)
fig, ax = plt.subplots()
gdf_polygon.boundary.plot(ax=ax, color='red')
gdf.boundary.plot(ax=ax)
Now I would like to extract some images in this boundary. This is what I am doing but it does not work.
cover = ee.ImageCollection('MODIS/006/MOD11A2').filter(ee.Filter.date('2018-01-01', '2018-05-01'))\
.select('LST_Day_1km')\
.filterBounds(geometry)
shapefile
of Paris metropolitan area. I use it to get the bounding box around it (the red rectangle).