This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit | |
height: 505 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define the area of interest, using the Earth Engines geometry object | |
coords = [ | |
[lon - sze/2., lat - sze/2.], | |
[lon + sze/2., lat - sze/2.], | |
[lon + sze/2., lat + sze/2.], | |
[lon - sze/2., lat + sze/2.], | |
[lon - sze/2., lat - sze/2.] | |
] | |
aoi = ee.Geometry.Polygon(coords) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# define the bands that I want to use. B4 is red, B3 is green, B2 is blue | |
# https://developers.google.com/earth-engine/datasets/catalog/COPERNICUS_S2_SR#bands | |
bands = ['B4', 'B3', 'B2'] | |
# export geotiff images, these go to Drive and then are downloaded locally | |
for selection in bands: | |
task = ee.batch.Export.image.toDrive(image=db.select(selection), | |
description=selection, | |
scale=30, | |
region=aoi, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# open the images | |
B2 = rasterio.open('B2.tif') | |
B3 = rasterio.open('B3.tif') | |
B4 = rasterio.open('B4.tif') | |
#get the scaling | |
image = np.array([B2.read(1), B3.read(1), B4.read(1)]).transpose(1,2,0) | |
p2, p98 = np.percentile(image, (2,98)) | |
# use the B2 image as a starting point so that I keep the same parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conda create --name geo_forge | |
conda activate geo_forge | |
conda config --env --add channels conda-forge | |
conda config --env --set channel_priority strict | |
conda install python=3.9 jupyter numpy matplotlib earthengine-api rasterio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ee | |
import rasterio | |
from rasterio.plot import show as showRasterio | |
# my script | |
from EarthEngineToGeoTIFF import getSentinalS2SRImage | |
import matplotlib.pyplot as plt | |
# Trigger the authentication flow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Chicago central latitude, longitude and approximate size | |
lat = 41.8781 | |
lon = -87.6298 | |
sze = 0.65 | |
_ = getSentinalS2SRImage(lon, lat, sze, 'ChicagoGeoTIFF.tif') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f,ax = plt.subplots(figsize=(15,15)) | |
chicago = rasterio.open('ChicagoGeoTIFF.tif') | |
showRasterio(chicago.read(), ax = ax, transform=chicago.transform) | |
chicago.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conda activate geo_forge | |
conda install geopandas pandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rasterio | |
import pandas as pd | |
import geopandas as gpd | |
df = pd.read_csv('311_Service_Requests_-_Pot_Holes_Reported_-_Historical.csv') | |
gdf = gpd.read_file('Boundaries_ZIP_Codes/geo_export_94cfa385-03be-4b00-b827-c9e4fdd73a8f.shp') | |
chicago = rasterio.open('ChicagoGeoTIFF.tif') |
OlderNewer