├── CommunityExamples ├── CAcountyBiome ├── CER ├── CER_2020 ├── COVID_19 ├── Get count for number of points in multiple polygons ├── IALE2019_GEWorkshop ├── IAleWorkshop_GE2019_Part4 ├── LC_2018 ├── LC_2020_sent ├── LC_2020_sent_ndbi ├── LC_AMS_2020 ├── LC_AMS_20CL ├── LC_AMS_20CL (copy) ├── LC_maroc1 ├── Load and Clean Sentinel 2 ├── Luciana_reflorestamento_classification_PonteAlta ├── MannKendallSStat ├── OpaltonS2SharpeningLoG (copy).js ├── Palmier ├── TREE20 ├── Temperature_day ├── Tmperature ├── blobs │ └── Storage2Array2.js ├── firstecoregion ├── harmonic model_settat ├── lc_2019 ├── lc_2020 ├── mtci_olive ├── ndvi_collection ├── night light ├── nirogen_modis ├── nitrogen_2020 ├── nitrogen_L8_2020 ├── nitrogen_taza ├── palm_temp ├── palmier_chirps ├── script_cotas_srtm ├── scripts_ndvi ├── settat_LC ├── temp ├── temperature_night ├── text │ ├── Text.js │ └── examples │ │ ├── AnnotateLandsat.js │ │ ├── Font.js │ │ ├── Simple.js │ │ └── StressTest.js └── unsorted │ ├── CloudShadowsFromSunParamaters.js │ ├── CloudShadowsWithDarkPixels.js │ ├── ElevationProfile.js │ ├── GenerateRegularGrid.js │ ├── H20_QUAL │ ├── HitOrMissTransform.js │ ├── SLIC.js │ ├── Scalebar.js │ ├── SharpeningLoG.js │ ├── SurfaceTemperature.js │ ├── SurfaceTemperature_L5.js │ ├── WaterOtsu.js │ ├── WaterOtsuSentinel1.js │ └── geohash.js ├── DeltaresDataScienceWorkshop2015 ├── 01 Hello World.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Play with Image Bands.js ├── 06 Play with Reducing Image Collections.js ├── 07 Load an Image by ID.js ├── 08 HSV Pan-sharpening.js ├── 09 Compute NDVI.js ├── 10 Map a Function over an Image Collection.js ├── 11 Greenest Pixels.js ├── 12 Chart NDVI over Time.js ├── 13 Export Image.js ├── 14 Linear Fit, Lights.js └── 15 AHN.js ├── DeltaresGoogleEarthEngineTraining2016 ├── 01 Hello World 1.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Play with Image Bands.js ├── 06 Play with Reducing Image Collections.js ├── 07 Load an Image by ID.js ├── 08 HSV Pan-sharpening.js ├── 09 Compute NDVI.js ├── 10 Map a Function over an Image Collection.js ├── 11 Greenest Pixels.js ├── 12 Chart NDVI over Time.js ├── 13 Export Image.js ├── 14 AHN.js ├── 14 Linear Fit, Lights.js ├── 15 Water.js ├── 16 Water Indices.js ├── 17 Water Otsu Thresholding.js ├── 18 Cloud_Modis_Cloud_Masking_Monthly ├── 19 Text.js ├── 20 Text, annotate video.js ├── SAR_1_Collection_Filtering ├── SAR_2_Export ├── SAR_3_Reducers └── SAR_4_Time_Series ├── DeltaresGoogleEarthEngineTraining2017 ├── 01 Hello World 1.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Image Bands.js ├── 06 Reduce Image Collections.js ├── 07 Compute NDWI.js ├── 08 Compute NDVI.js ├── 09 HSV Pan-sharpening.js ├── 10 Map a Function over an Image Collection.js ├── 12 Chart NDVI over Time.js ├── 12 Percentile Composite.js ├── 13 Export Image.js ├── 14 AHN.js ├── 15 Linear Fit, Lights.js ├── 16 Linear Fit, Water.js ├── 17 Water Detection Canny and Otsu.js ├── 18 Annotate Multple Landsat.js ├── 19 Annotate Video.js ├── 20 GPM_NCEP.js ├── 21 Supervised Classification.js └── 22 Bathymetry.js ├── DeltaresGoogleEarthEngineTraining2019_TwenteU ├── 01 Hello World.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Image Bands.js ├── 06 Reduce Image Collections.js ├── 07 Compute NDWI.js ├── 08 Compute NDVI.js ├── 09 HSV Pan-sharpening.js ├── 10 Map a Function over an Image Collection.js ├── 11 Chart NDVI over Time.js ├── 12 Percentile Composite.js ├── 13 Export Image.js ├── 14 AHN.js ├── 15 Linear Fit, Lights.js ├── 16 Linear Fit, Water.js ├── 17 Aqua Monitor (results).js ├── 18 Precipitation, animate.js ├── 19 Precipitation, aggregate.js └── 20 Precipitation, correlation.js ├── DeltaresSoftwareDays2016_AquaMonitor ├── 01 Hello World 1.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Image Bands.js ├── 06 Reducing Image Collections.js ├── 07 Compute NDWI.js ├── 08 Map a Function over an Image Collection.js ├── 09 Linear Fit, Lights.js ├── 10 Percentile Composite.js ├── 11 Linear Fit, Water.js └── 12 Aqua Monitor.js ├── TUDelftWorkshop2016 ├── 01 Hello World.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Play with Image Bands.js ├── 06 Play with Reducing Image Collections.js ├── 07 Load an Image by ID.js ├── 08 HSV Pan-sharpening.js ├── 09 Compute NDVI.js ├── 10 Map a Function over an Image Collection.js ├── 11 Chart NDVI over Time.js ├── 12 Export Image.js ├── 13 Linear Fit, Lights.js ├── 14 AHN.js ├── 15 Water.js ├── 16 Water Indices.js ├── 17 Water Otsu Thresholding.js ├── 18 Cloud_Modis_Cloud_Masking_Monthly ├── 19 Text.js ├── 20 Text, annotate video.js ├── SAR_1_Collection_Filtering ├── SAR_2_Export ├── SAR_3_Reducers └── SAR_4_Time_Series ├── aqua-monitor ├── aqua-monitor-export-change.js ├── aqua-monitor-export-map.js ├── aqua-monitor-export-video.js ├── aqua-monitor-export.js ├── aqua-monitor-old-scenes.js ├── aqua-monitor-paper-main-map.js ├── aqua-monitor-results-vis.js ├── aqua-monitor-results.js ├── aqua-monitor-sources-original-fixed-2018.js ├── aqua-monitor-sources-original.js ├── aqua-monitor-stats.js ├── aqua-monitor-video-sparkline.js ├── aqua-monitor-vis.js ├── aqua-monitor.js ├── case-screenshots.js ├── coastline.js ├── heatmap.js ├── landsatnewzealand ├── reservoirs-export-video.js ├── scene-count.js ├── shorelines │ └── future_shorelines.js └── temp │ ├── aqua-monitor-small.js │ ├── aqua-monitor.js │ └── aqua-monitor2.js ├── art2017 ├── art.js ├── bg.js ├── dem.moellering.kimerling.js ├── dem_hillshade.js └── dem_hilshade_render.js ├── by-year ├── 2015 │ ├── map scale is in meters │ ├── A.Bryk NDVI, river skeleton │ ├── AHN2.js │ ├── AHN_fill.js │ ├── AU, flow accumulation │ ├── AU5mDEM_OSM_SH.js │ ├── Advection.js │ ├── Anomaly Change Detection3 │ ├── BUG, buffer geometry gives error │ ├── BUG, download image generates black lines │ ├── BUGS canny, export │ ├── BUG_Cart_sampling.js │ ├── BUG_ViewfinderpanoramaAndTerrain │ ├── BUG_connected_pixels_in_map │ ├── BUG_feature_collection.js │ ├── BUG_fusion_table_types │ ├── BUG_in_Terrain │ ├── BUG_normalize_kernel.js │ ├── BufferButtCaps.js │ ├── BufferCapStyle.js │ ├── CART_water.js │ ├── CloudScoreAndTemperature.js │ ├── CloudShadows.js │ ├── CloudShadows2.js │ ├── ClusteringTest.js │ ├── CoastTest1 │ ├── CoastalChanges.js │ ├── Compariing 32 day collections to individual image collections │ ├── CompositeNoCloudsAndShadows.js │ ├── CountLandsatModis.js │ ├── DATASET - HydroSHEDS │ ├── DEMs │ ├── DISCUSSION raster vs. vector, distance transform │ ├── DOS.js │ ├── Decorrelation Stretch │ ├── DetectReservoir.js │ ├── ERROR OSM-LANDSAT shift │ ├── ETOPO1 │ ├── EVI, NDVI │ ├── ErrorJoke.js │ ├── Export Linear Fit │ ├── ExportNdviDiff.js │ ├── ExportPansharpened │ ├── ExportVideoPan │ ├── ExportVideoWithLabels │ ├── Export_Landsat8_SRTM_text.js │ ├── Export_Video_Landsat8_text.js │ ├── FC_intersect │ ├── FEATURE_FeatureCollection_sort.js │ ├── FeatureCollectionWithoutGeom │ ├── FitHarmonicNDVI.js │ ├── Forest gain TEOW by area_km2 │ ├── Fusion Table Error │ ├── Fusion Table Example │ ├── G3WBD │ ├── GME, custom │ ├── GRIDMET Water Year Precipitation Download │ ├── GRanD_export_video.js │ ├── GRanD_export_video_export_fails.js │ ├── GRanD_test1.js │ ├── GenerateCategorialNames.js │ ├── GlobalGrid.js │ ├── Grid of bounding boxes │ ├── Grid user-defined │ ├── HDR Landsat │ ├── HSV-based Pan-Sharpening │ ├── Hausdorff transform │ ├── HydroBASINS │ ├── HydroBASIN_rivers_catchments.js │ ├── HydroSHEDS │ ├── HydroSHEDS + L8 + STREAMS │ ├── HydroSHEDS - Public │ ├── HydroSHEDS 15SEC │ ├── Ian_cloud_mask_with_my_shadow.js │ ├── Ian_water_detection.js │ ├── Image statistics with combined reducer │ ├── Image.ConnectedPixelCount example │ ├── IterativeAlgorithm.js │ ├── L7 L8 Regression │ ├── L7, LEDAPS,average │ ├── L7_HSV-based_Pan-Sharpened_NDVI_calculator │ ├── L8 NDVI, cloudscore, mosaic │ ├── L8, DN, reflectance │ ├── L8, cloudfree, MNDWI │ ├── L8, clouds │ ├── L8, means │ ├── L8_SR │ ├── LANDSAT + MODIS │ ├── LANDSAT, classify1 │ ├── LANDSAT, classify2 │ ├── Landsat8_CloudsOnly │ ├── LandsatPansharpenedAtLocation.js │ ├── LatestL8 │ ├── MODIS NDVI download │ ├── MODIS QC Tests for BitwiseAnd │ ├── MODIS clouds and shadows (QA bits) │ ├── MODIS corrected reflectance │ ├── MODIS mask clouds and shadows │ ├── MODIS, Snow Cover Count │ ├── MODIS_Clouds_And_Shadows_Ian │ ├── MODIS_and_LANDSAT_video.js │ ├── MODIS_visual.js │ ├── MeanElevationPerCountry │ ├── Minimum Noise Fraction (MNF) Transformation (MNF_V.1.0) │ ├── Mixture Tuned Match Filtering (MTMF) Classification (MTMF_V.1.0) │ ├── Modis Cloud Masking │ ├── Murray & Darling, catchments │ ├── Myanmar_floods_2015.js │ ├── NDWI_SR_TOA_Tasumi 2 │ ├── NDWI_SR_TOA_Tasumi_SR_LEDAPS │ ├── NLCD.js │ ├── NN example │ ├── Nigeria, classify (VotingSvm), download │ ├── NumberOfScenes.js │ ├── OSM │ ├── OSM, average MNDWI vs. average 753 │ ├── OSM, basins and rivers │ ├── OSM, connect broken lines │ ├── OSM, intersect vector with raster │ ├── OSM, vectors │ ├── Ostu.js │ ├── PercentileFormulae.js │ ├── Percentiles.js │ ├── PlanetLabs.js │ ├── Plot band values at points in an image │ ├── QUESTION_blobs.js │ ├── ReduceRegionOverLine.js │ ├── ReduceRegions_SumPerFeature │ ├── ReduceResolution │ ├── Regression.js │ ├── ReprojectionsAndConvolution.js │ ├── Reservoirs │ ├── Risks_Beth.js │ ├── S1_PM.js │ ├── S1_angle_correction.js │ ├── S1_change.js │ ├── S1_filters.js │ ├── S1_flood_mapping_Nick.js │ ├── S2.js │ ├── SRTM_ALOS │ ├── SRTM_exact_test │ ├── SVM │ ├── Sentinel1.js │ ├── Sentinel1_Guido.js │ ├── Sentinel1_flood_Pakistan.js │ ├── Sentinel1_last.js │ ├── Sentinel2_cloud_mask.js │ ├── Sentinel2_sharpen.js │ ├── SkyBox GCP │ ├── SkyBox.js │ ├── SteramedBandAwareReducers.js │ ├── StyleDEM.js │ ├── SupervisedClassification2.js │ ├── TEST_geometries_and_features.js │ ├── TRMM, NCEP │ ├── TRMM, export │ ├── TWI, wettness, DATASET - HydroSHEDS │ ├── TimeSeries, LANDSAT │ ├── Trends in Snow Cover Frequency (linear and MK-signifigance from tables) │ ├── TrendySnow.js │ ├── TrendyWater.js │ ├── Various masks, MODIS + histogram │ ├── Vector to raster conversion │ ├── VideoDemo.js │ ├── VideoExportCHIRPS.js │ ├── VideoWithShadow.js │ ├── VideoWithoutCloudsOverGivenPolygon.js │ ├── VideoWithoutCloudsOverWater.js │ ├── VideoWithoutCloudsOverWater_simple.js │ ├── ViewfinderpanoramaDEM.js │ ├── WaterMekong.js │ ├── array struggles │ ├── arrays.js │ ├── bathtub_cells.js │ ├── bluest │ ├── canny, Simple Edge detection in NDVI │ ├── canny, test, mndwi │ ├── chart custom3 (histogram) │ ├── chart, custom1 │ ├── chart, custom2 │ ├── checkboard │ ├── classification, cloud masking │ ├── classifier │ ├── clouds │ ├── coast_l8 │ ├── compute distance from points contained in polygons to their boundary │ ├── compute distance on masked image │ ├── compute minimum cloud cover │ ├── convert polygon to points │ ├── count scenes │ ├── default geometry length │ ├── download as stack │ ├── download image using map bounds │ ├── export to GDrive │ ├── fint_image_by_path_row │ ├── flood fill │ ├── flood risk map │ ├── footprints.js │ ├── generate_regular_grid.js │ ├── getDownloadURL_original_scale.js │ ├── getTileUrl │ ├── getValuesAtPixels │ ├── gridmet │ ├── grodmet2 Climatology Join │ ├── group_by_features │ ├── guess_cloud_shadow.js │ ├── hillshade_360 │ ├── histogram reducer │ ├── hit-or-miss │ ├── hydro-toolbox.js │ ├── image fusion │ ├── intersect vector datasets │ ├── isolines │ ├── kernels │ ├── kernels, edges, gaussian │ ├── land cover, world countries │ ├── last_array_element.js │ ├── lights, diffs, Calibrate satellite differences │ ├── mask LANDSAT using BQA │ ├── match_SR_TOA.js │ ├── max elevation within buffered features │ ├── misaligned │ ├── mountain_shadows │ ├── non-destructive average │ ├── normalize raster │ ├── overlap line with distance transform │ ├── pan-sharpening L8expansion │ ├── projections (Map, geometry) │ ├── reduce by class from image │ ├── reduce nu month Temporally Grouped Reduction EXAMPLE │ ├── reduce to vector │ ├── reduceMinMaxAndScale.js │ ├── reduceResolutionFun.js │ ├── registration_badimages │ ├── remove nulls │ ├── ridges │ ├── roads, compute intersections │ ├── scene boundaries │ ├── scene_count.js │ ├── slope, kernels │ ├── smooth_image.js │ ├── split LineString │ ├── split LineString (EE) │ ├── style DEM │ ├── style vectors │ ├── summarize stats │ ├── sun, earth distance, image properties (bias, gain) │ ├── supervised clasification │ ├── temperature.js │ ├── temporal reducers │ ├── text.js │ ├── timeAtMax Error │ ├── time_to_space_au2.js │ ├── train classifier │ ├── train_classifier │ ├── training with raster │ ├── transparent image │ ├── transparent polygons │ ├── upscaling L8expansion │ └── water_buffer_style.js ├── 2016 │ ├── ASTER.js │ ├── ASTER2.js │ ├── ASTER_coregistration.js │ ├── ASTER_for_point.js │ ├── ASTER_night_temp.js │ ├── ASTER_temperature.js │ ├── Aleppo.js │ ├── Alex_NDVI_water_kmeans.js │ ├── ApproximateNumberOfTiles.js │ ├── Async Inspector │ ├── BUGS_VFP.js │ ├── BUG_bad_TOA.js │ ├── BUG_bad_TOA2.js │ ├── BUG_bad_scenes.js │ ├── BUG_bad_toa.ja │ ├── BandwisePercentile.js │ ├── BathymetryValidation.js │ ├── CDF.js │ ├── CalHeatMap.js │ ├── CastShadows.js │ ├── CastShadows_small_large.js │ ├── Chart.js │ ├── Chart_at_points.js │ ├── Classification_Landcover.js │ ├── CloudComposites_Ian_2016.js │ ├── CloudShadowSnowWaterMasks.js │ ├── CloudsAndShadows.js │ ├── CloudsMask_bad_scene_Ian.js │ ├── Coastline.js │ ├── CollectEarth.js │ ├── Composite.js │ ├── ComputeCount.js │ ├── Compute_Fires_Per_Polygon.js │ ├── CountScenesPerYear.js │ ├── CountScenesPerYear_ASTER.js │ ├── DistanceAspectSlope_styled.js │ ├── DistanceSlopeAspect.js │ ├── EE-art.js │ ├── EVI_PCA.js │ ├── Eigen_AndVis.js │ ├── ElevationProfile.js │ ├── EqualizeHistogram.js │ ├── ExportImageAsFeature.js │ ├── ExportParameters.js │ ├── ExportRobinson.js │ ├── ExportVideoWithAnnotations.js │ ├── FEATURE_ImageScale.js │ ├── FilterEveningImages.js │ ├── Frame.js │ ├── GPM.js │ ├── GPM_NCEP.js │ ├── GenerateGridAfrika.js │ ├── GenerateThumbnailGradientScale.js │ ├── GradientLegendItems.js │ ├── HIC_2016_review.js │ ├── HillshadeMultiplyVsHsv.js │ ├── HydroBASINS_vis.js │ ├── Hypernion.js │ ├── JRC.js │ ├── JRC_water_monthly.js │ ├── L5_shift.js │ ├── L7_FillGaps.js │ ├── Lake_Tahoe.js │ ├── Landsat123Bands.js │ ├── Landsat_Classification_reproject.js │ ├── LightsView.js │ ├── MODIS_cell_coordinates.js │ ├── MaskCombination.js │ ├── NDVI_export.js │ ├── NDVI_temporal_slope.js │ ├── NDVI_temporal_slope2.js │ ├── NDVI_temporal_slope_array.js │ ├── NearestPixel.js │ ├── Otsu_Nick_SERVER.js │ ├── P15_SUN_PARAMETERS.js │ ├── PCA,js │ ├── PCA.js │ ├── PCA_and_kmeans.js │ ├── PROBA-V and MODIS.js │ ├── PROBA-V.js │ ├── PROBA_clouds_shadows_ice.js │ ├── ProfileMax.js │ ├── Projections.js │ ├── ROC.js │ ├── RandomForestExample_Belgium.js │ ├── RandomImage.js │ ├── RegularGrid.ja │ ├── RegularGrid_SRTM.js │ ├── RegularGrid_States.js │ ├── RegularGrid_and_randomly_shifted_centers.js │ ├── S1-RefinedLeeSpekleFilter.js │ ├── S1_ASC_DSC.js │ ├── S1_clip.js │ ├── S1_clip_edge.js │ ├── S1_profile.js │ ├── S2_water.js │ ├── SERVIR-Clouds.js │ ├── SR_TOA.js │ ├── SampleImagesWithinBuffer.js │ ├── ScalesPrecision.js │ ├── ScatterPlot.js │ ├── ScatterPlot_NDWI.js │ ├── ScatterPlot_reflectance.js │ ├── ScatterPlot_reflectance_MODIS.js │ ├── ScatterPlot_reflectance_PROBA.js │ ├── SeaFog.js │ ├── SeaLevelRiseScenario.js │ ├── SelectAllLandsat.js │ ├── Sentinel1-maskedges.js │ ├── Sentinel2_and_HydroSHEDS.js │ ├── SinusoidalLeastSquaresRegression.js │ ├── SlopeAspectCustom.js │ ├── SoilFeedbackDynamicPattern.js │ ├── Spectogram.js │ ├── Spectrogram_.js │ ├── Storage2Array.js │ ├── Storage2Array2.js │ ├── Storage2FeatureCollection.js │ ├── Storage2FeatureCollecton2.js │ ├── SumHistogramBinRanges.js │ ├── TU_ScriptRamsess.js │ ├── TerraBella.js │ ├── TextMargin.js │ ├── TopographicCorrection_rotate.js │ ├── UI_Canny │ ├── UntitledFile │ ├── UntitledFile2 │ ├── UpdateLayerNameAsync.js │ ├── VIIRS.js │ ├── VIIRS2.js │ ├── WI2015.js │ ├── WaterDetectionThresholdSurface.js │ ├── Water_GLCF.js │ ├── all.js │ ├── aqua-monitor-export-paper.js │ ├── aqua-monitor-export-results-filtered.js │ ├── aqua_monitor_Dai.js │ ├── area_from_monthly_occurrence.js │ ├── bad_footprint.js │ ├── bathymetry_optical.js │ ├── bits.js │ ├── ch1_snow.js │ ├── client_server_profiling.js │ ├── cloud_fmask_and_simple.js │ ├── cloud_percentiles.js │ ├── contour.js │ ├── cumulative_costs.js │ ├── draw_area.js │ ├── dynamic_water_pan.js │ ├── ee.Algorithms.Landsat.simpleComposite.js │ ├── flood_area_cumulative_costs.js │ ├── flood_before_after.js │ ├── flood_extent_dam.js │ ├── folding.js │ ├── gallery.js │ ├── gallery_simple.js │ ├── get_aster_sentinel1_scene_count_per_year.js │ ├── get_thumb_scaled.js │ ├── hillshade_custom.js │ ├── historgram_for_image_bands.js │ ├── hyperion2.js │ ├── imagecollection2multiband.js │ ├── legend_and_svm_Phillipines.js │ ├── light_video.js │ ├── lights2.js │ ├── lights_gallery │ ├── map_feature_inspector.js │ ├── merge_TOA_fmask │ ├── multitemp_despeckle.js │ ├── normcdf.js │ ├── percentile_water.js │ ├── pi.js │ ├── policy_hackathon.js │ ├── pretty_vector_export.js │ ├── profile_client.js │ ├── projections_equalarea.js │ ├── quality_mosaic.js │ ├── reduceImageByDictionary.js │ ├── registration.js │ ├── resampling.js │ ├── reservoir_SouthAfrika.js │ ├── rotateText.js │ ├── s1_temporal_despeckle_v1.js │ ├── scatterPlotTwoImages.js │ ├── select_country_combobox.js │ ├── sigmoid.js │ ├── sum-to-one-constrained-unmixing.js │ ├── terrain_correction.js │ ├── test_contains.js │ ├── topographic_correction_George.js │ ├── ts │ ├── updateMask.js │ ├── video_water_indices.js │ └── water_sentinel1_otsu_median.js └── 2019 │ ├── 2019-06-reservoirs-all-1ha-missing │ ├── AHN_fill.js │ ├── ASTER.js │ ├── ASTER_TOA.js │ ├── Beck_KoppenGeiger_ClimateZones.js │ ├── CH4.js │ ├── Color.js │ ├── Congo_stephen_matter.js │ ├── DEMs.js │ ├── DrawAreaTool.js │ ├── ET.js │ ├── FA_90m │ ├── Florida_flood_NAIP.js │ ├── Florida_flood_precip.js │ ├── Florida_floods.js │ ├── Florida_floods_indices_trend.js │ ├── Florida_floods_phenology.js │ ├── Florida_floods_s1.js │ ├── Functions │ ├── S1_RefinedLee_module │ └── S1_RefinedLee_module_test │ ├── HAND_classes.js │ ├── HydroBASINA_Pfafstetter_traversal.js │ ├── HydroBASINS_raster_export.js │ ├── HydroBASINS_traversal_dfo.js │ ├── India_flood.js │ ├── L1-3 │ ├── L4-Chernobyl.js │ ├── L5-Chernoby-temp │ ├── Landsat │ └── Sentinel2 - Phenology Model │ ├── MODIS_monthly.js │ ├── NAIP.js │ ├── NOAA_CDR_AVHRR_SR_V5-trend │ ├── NaturalEarth-urban-admin.js │ ├── OLS.js │ ├── PCA-NDVI-MODis │ ├── PCA_lava_water.js │ ├── PCA_local │ ├── Phenology.js │ ├── Plot-test.js │ ├── Plot.js │ ├── QGIS_test.js │ ├── RhineDischargeExperiment.js │ ├── S1-SG-S1-Guido.js │ ├── S1S2.js │ ├── S1S2_masked_by_water.js │ ├── S1_SM.js │ ├── S1_anaglyph.js │ ├── S1_angle.js │ ├── S1_annual │ ├── S1_annual_gamma │ ├── S1_count.js │ ├── S1_first_band_I │ ├── S1_max.js │ ├── S1_median_polarimetric │ ├── S1_mosaic_db.js │ ├── S1_timelapse │ ├── S1_water.js │ ├── S2_bad_L1_calibration │ ├── S2_band_fun.js │ ├── S2_clouds_shadows.js │ ├── S2_mosaic_TDOM_shadows.js │ ├── S2_mosaic_by_time.js │ ├── S2_ndvi.js │ ├── S2_north.js │ ├── S2_overlapping_scenes.js │ ├── S2_quality_gallery.js │ ├── S2_quality_gallery_CDF.js │ ├── S2_shadows.js │ ├── S5 │ ├── S5_percentiles │ ├── SLIC_wekaKMeans.js │ ├── SLIC_wekaKMeans_fixed.js │ ├── SNIC │ ├── SNIC_multiindex │ ├── SNIC_vegetation │ ├── Savitzky-Golay.js │ ├── URBAN_AREAS_GAIA │ ├── UntitledFile │ ├── UntitledFile2 │ ├── UntitledFile3 │ ├── UntitledFile4 │ ├── UntitledFile5 │ ├── UntitledFile6 │ ├── VIIRS_PDF.js │ ├── WRI_reservoirs_power_India.js │ ├── advection.js │ ├── aggregate_area.js │ ├── agricultural_areas.js │ ├── animate-chart │ ├── animate-profile-series │ ├── animate-thumbnail-and-map │ ├── animate_S2L8.js │ ├── animate_raw_landsat │ ├── animate_s2_log.js │ ├── animation-cloudfree │ ├── animation-ice-optical │ ├── animation-test-s1-ice-Greenland │ ├── annotate_video.js │ ├── annotation-example.js │ ├── app-last-scenes │ ├── app-movie-maker │ ├── app-permafrost-paper │ ├── app_GOES │ ├── app_HydroBASINA_Pfafstetter_traversal2.js │ ├── app_NO2.js │ ├── app_dem_ALOW_SRTM_diff.js │ ├── app_flood_idai.js │ ├── app_water_lava │ ├── app_waterbodies │ ├── assets-simple │ ├── assets_muliview.js │ ├── bathymetry_s2.js │ ├── bayes │ ├── bicubic_edge_bugs │ ├── bug_reduce_to_vector │ ├── cell_area_fraction │ ├── cell_reproject_errors │ ├── changedetection_mortcanty │ ├── chart_annotation_bug.js │ ├── cloud_shadows_landsat │ ├── collections.js │ ├── color │ ├── concaveHull │ ├── confidence-intervals │ ├── constituents.js │ ├── contour_labels.js │ ├── countries-equal-area │ ├── covid19.js │ ├── covid19_analysis.js │ ├── covid19_areas.js │ ├── covid19_assets.js │ ├── covid19_map_regional.js │ ├── covid19_nl.js │ ├── covid19_pop.js │ ├── covid19_regional.js │ ├── crash-iran-ua │ ├── cumulativeCostSlope │ ├── cumulative_precipiation.js │ ├── custom_reduce_resolution.js │ ├── dam_designer │ ├── dam_failure_Brazil │ ├── dams_by_distance_to_coast.js │ ├── delaunay │ ├── delay │ ├── demStyling-experimental │ ├── dem_bath_visualize.js │ ├── dem_bath_visualize_Fedor.js │ ├── depth-invariant-image.js │ ├── diff_London.js │ ├── diff_London_TDOM.js │ ├── displace │ ├── displacement-rotate │ ├── dots │ ├── dramatic_palettes.js │ ├── dredging_rotterdam │ ├── dublin.js │ ├── eikonal.js │ ├── electricity.js │ ├── eo-river │ ├── es6-promise │ ├── example_export │ ├── export_JRC_presentiles.js │ ├── export_data_frederiek │ ├── export_fa90 │ ├── export_image_align_pixels │ ├── export_video.js │ ├── export_video_landsat.js │ ├── fast_focal_min_max.js │ ├── featureCollectionToDataTable.js │ ├── figure.js │ ├── find-nearest-in-time.js │ ├── fire-Kincade-goes.js │ ├── fix_bad_polygon.js │ ├── fix_bad_polygon_good_bad.js │ ├── flood.js │ ├── flood_Iran_precipitation.js │ ├── flower.js │ ├── focus_square.js │ ├── fraction_T2_MSS │ ├── future_shorelines.js │ ├── gallery.js │ ├── geometry-coords.js │ ├── gl-series │ ├── global-region-export │ ├── greenland-ice │ ├── group-reduce │ ├── group_histogram_chart │ ├── hatch.js │ ├── hatch_art.js │ ├── hexagonal-grid │ ├── hycom.js │ ├── hycom_animate_uv_z.js │ ├── image_pixel_centers │ ├── interval_area_chart.js │ ├── lakes_CatherineCuhl │ ├── landtrendr.js │ ├── last-image-timer.js │ ├── legend_gradient.js │ ├── lights.js │ ├── mmeyer_review_jrc_area.js │ ├── moisture │ ├── monte-carlo.js │ ├── no2_trend.js │ ├── norm.js │ ├── norm2d │ ├── norm2d_iamge.js │ ├── oevererosie.js │ ├── optical-flow.js │ ├── osm-waterways-merge │ ├── osm_export_land │ ├── osm_water.js │ ├── overpass_time_analemma.js │ ├── palette-diverging │ ├── pixelFractionWithText.js │ ├── polar │ ├── polarimetry1 │ ├── precipitation.js │ ├── precipitation_chart_chirps_cfs │ ├── precipitation_data_harmonize │ ├── precipitation_trmm_animation.js │ ├── preview_images.js │ ├── profile_image.js │ ├── q │ ├── random_iter_noise.js │ ├── random_points.js │ ├── reduce_image_line.js │ ├── regionToImageCollection.js │ ├── requests-test.js │ ├── require-test-fn │ ├── require_water.js │ ├── reservoir-sudan.js │ ├── river_animation.js │ ├── rivers_India.js │ ├── root_finding.js │ ├── rug-plot-S2 │ ├── rug-plot-test-T1-T2.js │ ├── s2_gallery.js │ ├── s2_water.js │ ├── scatter-plot-bands.js │ ├── scatter_plot_radiance_reflectance.js │ ├── script_geom.js │ ├── sea-level-time-series │ ├── search_bad_footprint_images │ ├── selection_zorder.js │ ├── shadows.js │ ├── slippymap │ ├── snow_cover_Stef │ ├── soltice.js │ ├── sr_toa.js │ ├── ssa │ ├── starfm │ ├── stride.js │ ├── style_hycom.js │ ├── svr.js │ ├── swell_waves │ ├── symbology-charts-map-thumbs.js │ ├── tandemx-compare │ ├── temp-trend-mean.js │ ├── temp_test │ ├── temp_water.s │ ├── temperature_trend_point │ ├── temperature_vegetation_trend_point │ ├── temporal_trends_EVI_NDVI │ ├── terrain_analysis │ ├── text-vector │ ├── tiled-video │ ├── time_series_Whittakered.js │ ├── timelapse │ ├── toggle-controls.js │ ├── topological_simplify.js │ ├── trend.js │ ├── trend_FIRMS.js │ ├── trend_swir.js │ ├── vaklodingen-animate │ ├── velocity_field.js │ ├── video_composite_s2_l8.js │ ├── video_sort_by_water.js │ ├── water-features │ ├── water-occurrence-global-grid │ ├── water-trend-s1.js │ ├── water-trend.js │ ├── water.js │ ├── water_S1.js │ ├── water_SAR │ ├── water_TDOM_shadows.js │ ├── water_detection_otsu.js │ ├── water_detection_tiled.js │ ├── water_fin.js │ ├── water_fraction │ ├── water_history.js │ ├── water_is_not_water.js │ ├── water_obstructions.js │ ├── water_occurrence_jrc_300m.js │ ├── water_s2.js │ ├── water_small_reservoirs.js │ ├── water_trend_Mamaia.js │ ├── wateroccurrence-paris-multiindex │ ├── weibull.js │ ├── weight.js │ ├── weight_spatial_distance │ ├── weighted_double_sigmoid.js │ ├── wind_farms.js │ └── wrecks.js ├── eo-bathymetry-digishape ├── covadem(copy).js ├── covadem.js └── read_tiff_files ├── eo-dams ├── Planet-multiple.js ├── TODO ├── animate-water ├── app-brazil-tailing-dams.js ├── elevation-profile.js ├── hackathon-dams-daily.js ├── hackathon-dams-yearly-export-map.js ├── hackathon-dams-yearly.js ├── insar-point-prototype.js ├── mine-coal-India ├── moisture ├── precipitation.js ├── rf.js ├── temperature-landsat.js ├── temperature.js └── water-occurrence.js ├── eo-dem ├── DEM_S1.js ├── DEM_S1_multiangle.js ├── DEM_S1_multiangle_cleaner1.js ├── DEM_S1_multitemporal.js ├── NCC_DEM_photometric_stereo.js ├── NCC_results_IC_DEM ├── NCC_results_IC_DEM2 └── S1_SM_5m.js ├── eo-levees └── app-levees ├── esa-water └── test-sites.js ├── h2020-jerico-training ├── 01 Hello World 1.js ├── 02 Hello Image.js ├── 03 Add Image to Map.js ├── 04 Load and Filter Image Collections.js ├── 05 Image Bands.js ├── 06 Reducing Image Collections.js ├── 07 Compute NDWI.js ├── 08 Water Detection Otsu.js ├── 09 Map a Function over an Image Collection.js ├── 10 Linear Fit, Lights.js ├── 11 Linear Fit, Water.js ├── 12 Percentile Composite.js ├── 13 AHN.js ├── 14 Annotate Video.js └── 15 Annotate Multple Landsat.js ├── hydro-earth ├── Africa_risk_profiles │ ├── 90_meter_downscaling.js │ ├── Export_resample_flood_maps.js │ ├── SRTM_PeronaMalik_filter │ ├── pipeline_resample_flood_maps.js │ └── resample_overlap.js ├── Aqueduct │ ├── bathtub.js │ ├── bathtub_cells.js │ └── mangroves_slopes.js ├── BurnRoad.js ├── CoastalMorphology │ ├── CHW_coastline_changes.js │ ├── CHW_coastline_changes_Colombia.js │ ├── CoastlineScenes.js │ ├── CoastlineScenes_JF.js │ └── sandbox ├── CoastalMudBars │ ├── MudBarDynamics.js │ └── MudBarsLandsat.js ├── Experiments │ ├── Advection.js │ ├── GRanD.js │ ├── PeronaMalikFilter.js │ ├── Sentinel2_test_floodmap │ ├── StyleDEM.js │ ├── WaterMekong.js │ ├── automatic_NDWI (JF).js │ ├── automatic_NDWI.js │ └── export SRTM for HydroBASIN ├── FM │ └── DflowFmGridGen.js ├── Ganges Flood Extent ├── GangesECO │ ├── Ganges Flood Extent │ ├── UntitledFile │ └── ganges_basin.js ├── LandSatWater.js ├── Landsat_SurfaceWaterTool ├── MERIT │ └── MERIT_analysis ├── NewZealand.js ├── OSM │ ├── OSM_automatic_NDWI.js │ ├── OSM_compute_buffers │ ├── OSM_compute_buffers_export.js │ ├── OSM_stat_per_catchment.js │ └── water_detection_otsu_canny.js ├── SRTM_OSM │ ├── BurnRoad.js │ ├── PARTERRA_optimize │ ├── SRTM_OSM_fusion.js │ ├── pipeline │ ├── pipeline_Bangladesh │ ├── pipeline_Manzese │ ├── pipeline_for_GFDRR_demo │ ├── preprocessing_SRTM │ ├── preprocessing_SRTM_Bangladesh │ ├── preprocessing_SRTM_SriLanka │ ├── test_burn_polygons.js │ ├── test_iterate_filter.js │ ├── test_resample_smooth_SRTM.js │ ├── test_sidewalks.js │ ├── test_straighten_road.js │ ├── validate_burn_buildings │ ├── validate_filter_building.js │ └── validate_sidewalks.js ├── ServirMekong │ ├── generate_grid.js │ ├── hand.js │ └── water_detection.js ├── Temperature │ └── temperature_power_plant.js ├── hand-plus-percentile.js ├── input-data.js ├── preprocessing_DTM_SanJuan ├── validate_burn_polygons └── validate_straighten_roads ├── landslides ├── SAR-analysis ├── landslides ├── landslides-app ├── landslides_dem_mh ├── landslides_persian_cdr_mh ├── landslides_trmm3b42_mh ├── landslides_trmm3b43_mh ├── precipitation └── precipitation-animation ├── manila-bay-atlas ├── NDVI Manila ├── Population ├── UI ├── avg_waterdepth2015 ├── export-water-occurrence ├── mangroves ├── manila-bay-atlas-app ├── shapefiles └── timelapse ├── ml ├── 1-perceptron.js └── tests │ └── iterate-memory-use.js ├── packages2 ├── algorithms-aster.js ├── algorithms-asterT.js ├── algorithms-landsat.js ├── algorithms-sentinel1.js ├── algorithms-sentinel2.js ├── algorithms.js ├── collections.js ├── surface-water-bundled.js ├── surface-water-bundled2.js ├── surface-water.js └── utils.js ├── paper-global-reservoirs ├── .idea │ ├── vcs.xml │ └── watcherTasks.xml ├── NCC_export_aggregate ├── NCC_export_waterbodies_JRC ├── NCC_export_waterbody_parameters ├── NCC_results ├── NCC_results_occurrence ├── NCC_sun_parameters ├── NCC_water-detection ├── NCC_water_per_basin.js ├── NCC_water_temperature ├── surface-area-reconstruction │ ├── .babelrc │ ├── .gitignore │ ├── dist │ │ ├── chart.js │ │ ├── gallery.js │ │ ├── surface-water.js │ │ └── water-occurrence.js │ ├── dist_v1 │ │ ├── chart.js │ │ ├── surface-water-Piru.js │ │ ├── surface-water.js │ │ ├── surface-water_fill.js │ │ ├── surface-water_fill_JRC.js │ │ ├── surface-water_fill_Laos.js │ │ ├── surface-water_fill_SouthAfrika.js │ │ ├── surface-water_fill_bad_prob.js │ │ ├── surface-water_fill_large.js │ │ ├── water-occurrence.js │ │ ├── water-occurrence_large_area.js │ │ ├── water-occurrence_large_area_ua.js │ │ └── water-occurrence_with_JRC.js │ ├── gulpfile.babel.js │ ├── package.json │ ├── src │ │ ├── algorithms-aster.js │ │ ├── algorithms-asterT.js │ │ ├── algorithms-landsat.js │ │ ├── algorithms-modis.js │ │ ├── algorithms-proba.js │ │ ├── algorithms-sentinel1.js │ │ ├── algorithms-sentinel2.js │ │ ├── algorithms.js │ │ ├── collections.js │ │ ├── imports.js │ │ ├── scripts │ │ │ ├── chart.js │ │ │ ├── footer.js │ │ │ ├── gallery.js │ │ │ ├── surface-water.js │ │ │ └── water-occurrence.js │ │ ├── utils-gallery.js │ │ ├── utils-text.js │ │ └── utils.js │ └── tests │ │ └── test.js ├── temp │ ├── proba_percentiles.js │ ├── reservoirs-export-video.js │ ├── surface-area-reconstruction-s2.js │ ├── surface-area-reconstruction.js │ └── water-detection-otsu-region-growing.js └── unsorted │ ├── ASTER_temperature.js │ ├── JRC_monthly_water.js │ ├── clouds_CastShadows.js │ ├── histogram.js │ ├── multiple-sensors-export-images.js │ ├── s1_entropy.js │ ├── segmentation.js │ ├── surface-area-reconstruction-multiple-sensors.js │ ├── time_to_afrika.js │ ├── time_to_space.js │ ├── time_to_space_au.js │ ├── time_to_space_au2.js │ ├── time_to_space_prosser_creek.js │ ├── time_to_space_tibet.js │ ├── time_to_space_tibet_Hamburg.js │ ├── time_to_space_tibet_paris.js │ └── validation-locations.js ├── paper-global-shoreline ├── ARJEN_SAND ├── JOSH_SAND_2 ├── figure-decorations.js ├── notebooks │ ├── figure_water_detection.ipynb │ └── water_detection_method.pdf ├── scenes.js └── water_figure.js ├── paper-osm-2016 ├── MurrayDarlingWaterDatasets ├── OSM_automatic_NDWI.js ├── OSM_compute_buffers ├── OSM_compute_buffers_export.js ├── OSM_compute_buffers_export_small.js ├── OSM_stat_per_catchment.js └── automatic_NDWI.js ├── paper-video-tiles ├── dam-Merowe.js ├── export-maps.js ├── s1-ice └── viirs ├── surface-water-hackathon-2018 ├── animation-test-false ├── animation-test-false-indices ├── animation-test-false-water-indices ├── animation-test-false-water-indices-alaska ├── animation-test-jrc ├── animation-test-s1 ├── animation-test-s1-flood-canada ├── coastal_classification └── extreme_events.js ├── thesis ├── ProsserCreekPCA (copy).js ├── ProsserCreekPCA.js ├── ch1_atmospherically-corrected.js ├── ch1_hyperion.js ├── ch1_multires_image_examples.js ├── ch1_snow.js ├── ch1_topo.js ├── ch1_topo_example.js ├── ch1_topographic_correction.js ├── ch2-PeronaMalik.js ├── ch2_topo_and_water.js ├── ch4-aral.js ├── ch4_Percentile_ElevationErrors.js ├── ch4_Tibet.js ├── ch4_tibet_Siling_lake.js ├── hyperion.js ├── percentiles_vs_occurrence.js ├── study-area-PC.js ├── thesis1_sample_values.js ├── thesis1_sample_values2.js ├── thesis_hyperion3_CA.js └── time_to_space_au2.js ├── urban-lights ├── app ├── draw-test ├── export ├── no-urban-lights ├── splitter-app ├── time-slider └── urban_lights_splitter ├── water-angola └── image-count.js └── wri-niger-water ├── GRDC.js ├── MODIS ├── export-catchments-rivers ├── export-video ├── export.js ├── hist-image ├── multimission ├── river-width-s1.js ├── river-width.js ├── upper-niger-app ├── upper-niger-ribasim-app ├── water-dynamic-rivers-width.js ├── water-dynamics-landsat-sentinel.js ├── water-dynamics-modis-0-export ├── water-dynamics-modis-1-plot ├── water-dynamics-modis-2-export-landsat-sentinel ├── water-dynamics-rivers.js ├── water-skeleton.js └── wflow_assets.js /CommunityExamples/Load and Clean Sentinel 2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gena/ee-code-editor-archive/31346f56ef919f87d29787b227dc1c92531ea889/CommunityExamples/Load and Clean Sentinel 2 -------------------------------------------------------------------------------- /CommunityExamples/ndvi_collection: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var s2 = ee.ImageCollection("COPERNICUS/S2"), 3 | roi = /* color: #d63000 */ee.Geometry.Polygon( 4 | [[[34.9969482421875, 31.758531633937167], 5 | [35.21392822265625, 31.7234948028286], 6 | [35.27984619140625, 31.86589521179635], 7 | [35.04913330078125, 31.886886525780806]]]); 8 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 9 | var cndvi = function(image){ 10 | var ndvi = image.normalizedDifference(['B8','B4']); 11 | return ndvi; 12 | } 13 | 14 | var cloudmask = function(image){ 15 | var mask = image.gt(0.1); 16 | return mask 17 | } 18 | 19 | var s2i = s2.filterBounds(roi); 20 | var s2ndvi = s2i.map(cndvi); 21 | var s2cloud = s2ndvi.map(cloudmask); 22 | print(s2ndvi); 23 | 24 | Map.addLayer(s2ndvi) 25 | Map.addLayer(s2cloud) 26 | 27 | 28 | -------------------------------------------------------------------------------- /CommunityExamples/night light: -------------------------------------------------------------------------------- 1 | // Compute the trend of night-time lights. 2 | 3 | // Adds a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Map the time band creation helper over the night-time lights collection. 10 | // https://developers.google.com/earth-engine/datasets/catalog/NOAA_DMSP-OLS_NIGHTTIME_LIGHTS 11 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 12 | .select('stable_lights') 13 | .map(createTimeBand); 14 | 15 | // Compute a linear fit over the series of values at each pixel, visualizing 16 | // the y-intercept in green, and positive/negative slopes as red/blue. 17 | Map.addLayer( 18 | collection.reduce(ee.Reducer.linearFit()), 19 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 20 | 'stable lights trend'); -------------------------------------------------------------------------------- /CommunityExamples/script_cotas_srtm: -------------------------------------------------------------------------------- 1 | 2 | 3 | var image = ee.Image ("USGS/SRTMGL1_003") 4 | Map.addLayer( image, {min:1000, max: 0, palette_:["blue", "green", "yellow", "red"]}) 5 | Map.addLayer ( image.lt (200), {pallete :["red", "blue"]}) 6 | var zones = image.where (image.lt(200),0) 7 | .where (image.gt(200),200) 8 | .where (image.gt(400),400) 9 | .where (image.gt(600),600) 10 | 11 | 12 | Map.addLayer(zones, {palette: ["blue", "green", "yellow", " red"], min: 0, max: 600}) -------------------------------------------------------------------------------- /CommunityExamples/text/examples/Font.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var image = ee.Image("users/gena/fonts/Arial16"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | Map.setCenter(0, 0) 5 | 6 | var proj = image.projection() 7 | var scale = Map.getScale() // best seen at native resolution 8 | 9 | 10 | image = image.changeProj(proj, proj.scale(scale, -scale)) 11 | 12 | Map.addLayer(image) 13 | -------------------------------------------------------------------------------- /CommunityExamples/unsorted/SharpeningLoG.js: -------------------------------------------------------------------------------- 1 | Map.setCenter(32.84, 39.94, 13) 2 | 3 | var sentinel2 = ee.ImageCollection('COPERNICUS/S2') 4 | .filterBounds(ee.Geometry(Map.getBounds(true)).centroid(1)); 5 | 6 | var image = ee.Image(sentinel2 7 | .sort('CLOUDY_PIXEL_PERCENTAGE', true) 8 | .toList(1, 0).get(0)) 9 | .resample('bicubic') 10 | 11 | print(image) 12 | print(ee.Date(image.get('system:time_start'))) 13 | 14 | var bands = ['B4', 'B3', 'B2', 'QA60']; 15 | 16 | var vis = {bands:['B4','B3','B2'], min:600, max:[3000, 3000, 3800], gamma: 1.2} 17 | Map.addLayer(image, vis, 'image', false); 18 | 19 | // sharpen see e.g. http://www.cse.psu.edu/~rtc12/CSE486/lecture11_6pp.pdf 20 | var log = image 21 | .convolve(ee.Kernel.gaussian(10, 7, 'meters')) // G 22 | .convolve(ee.Kernel.laplacian8(0.4)) // L of G 23 | 24 | var sharpened = image.subtract(log) 25 | Map.addLayer(sharpened, vis, 'image (sharpened)', true); 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/01 Hello World.js: -------------------------------------------------------------------------------- 1 | print("Hello, world!"); 2 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/02 Hello Image.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/03 Add Image to Map.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // simple script to add map layer to IDE 5 | print(srtm); 6 | 7 | Map.addLayer(srtm, {min:0, max:1000}); 8 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/04 Load and Filter Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // load collection but refine by location/date/cloud cover 5 | var filtered = l8 6 | .filterBounds(Map.getBounds(true)) 7 | .filterDate('2013-05-01', '2016-05-01') 8 | .filterMetadata('CLOUD_COVER', 'less_than', 30) 9 | 10 | Map.addLayer(filtered); 11 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/05 Play with Image Bands.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // Select bands to visualize, Google for wavelengths used for different satellite missions 5 | // See http://landsat.gsfc.nasa.gov/?p=10643 for a list of bands. 6 | var filtered = l8.filterBounds(Map.getBounds(true)); 7 | 8 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B4','B3','B2']}, 'RGB'); 9 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B5','B4','B3']}, 'False Color'); 10 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/06 Play with Reducing Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // reduce image collection: compute a single value using a number images 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6']; 7 | l8 = l8.select(L8_NAMES, STD_NAMES); 8 | 9 | l8 = l8.filterBounds(Map.getBounds(true)); 10 | 11 | // define true color 12 | var rgb = l8.select(['red', 'green', 'blue']); 13 | 14 | 15 | // define false color 16 | var sng = l8.select(['swir2', 'nir', 'green']); 17 | 18 | var vis = {min:0, max:0.3}; 19 | 20 | Map.addLayer(rgb.median(), vis, 'RGB'); 21 | 22 | Map.addLayer(sng.median(), vis, 'SNG'); 23 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/07 Load an Image by ID.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6']; 5 | image = image.select(L8_NAMES, STD_NAMES); 6 | 7 | var rgb = image.select(['red', 'green', 'blue']); 8 | 9 | var vis = {min:0, max:0.3}; 10 | 11 | Map.addLayer(rgb, vis, 'RGB'); 12 | 13 | Map.centerObject(rgb) -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/08 HSV Pan-sharpening.js: -------------------------------------------------------------------------------- 1 | // load image -> convert to 15m (pan-sharpening) using the panchromatic band 2 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 3 | 4 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 5 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 6 | image = image.select(L8_NAMES, STD_NAMES); 7 | 8 | var rgb = image.select(['red', 'green', 'blue']); 9 | 10 | var vis = {min:0.05, max:0.25, gamma: 1.3}; 11 | 12 | Map.addLayer(rgb, vis, 'RGB'); 13 | 14 | // pan-sharpen image using 15m band 15 | var gray = image.select('pan'); 16 | var huesat = rgb.rgbToHsv().select('hue', 'saturation'); 17 | var upres = ee.Image.cat(huesat, gray).hsvToRgb(); 18 | 19 | Map.addLayer(upres, vis, 'RGB (pansharpened)'); 20 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/09 Compute NDVI.js: -------------------------------------------------------------------------------- 1 | // compute the normalized vegetation index based on nir/red 2 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 3 | 4 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 5 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 6 | image = image.select(L8_NAMES, STD_NAMES); 7 | 8 | var rgb = image.select(['red', 'green', 'blue']); 9 | 10 | var vis = {min:0.05, max:0.3, gamma: 1.3}; 11 | 12 | Map.addLayer(rgb, vis, 'RGB'); 13 | 14 | // Compute vegetation index as: NDVI = (NIR - RED) / (NIR + RED) 15 | // More reading: http://earthobservatory.nasa.gov/Features/MeasuringVegetation/ 16 | 17 | var red = image.select('red'); 18 | var nir = image.select('nir'); 19 | var ndvi = nir.subtract(red).divide(nir.add(red)); 20 | 21 | Map.addLayer(ndvi, {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI'); 22 | 23 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/10 Map a Function over an Image Collection.js: -------------------------------------------------------------------------------- 1 | // different method to add NDVI using a self-made function 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | 4 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 5 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterDate('2014-01-01', '2014-10-01') 9 | .filterBounds(Map.getBounds(true)) 10 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 11 | 12 | function addNdvi(image) { 13 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 14 | return image.addBands(ndvi); 15 | } 16 | 17 | var median = l8.map(addNdvi).median(); 18 | 19 | var rgb = median.select(['red', 'green', 'blue']); 20 | var vis = {min:0.05, max:0.25}; 21 | Map.addLayer(rgb, vis, 'RGB'); 22 | 23 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 24 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/13 Export Image.js: -------------------------------------------------------------------------------- 1 | // two methods for saving an image from EE 2 | // 1. directly to personal google drive 3 | // 2. get url -> save locally 4 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 5 | 6 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 7 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 8 | 9 | l8 = l8 10 | .select(L8_NAMES, STD_NAMES) 11 | .filterBounds(Map.getBounds(true)) 12 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 13 | .select(['red', 'green', 'blue', 'nir']) 14 | 15 | var image = ee.Image(l8.first()) 16 | 17 | var vis = {min:0.05, max:0.25}; 18 | 19 | Map.addLayer(image, vis, 'L8') 20 | 21 | print(image) 22 | 23 | image = image 24 | .visualize(vis) 25 | .clip(Map.getBounds(true)) 26 | 27 | var id = image.get('LANDSAT_SCENE_ID').getInfo() 28 | 29 | // new, async way 30 | Export.image(image, id); 31 | 32 | // old, sync way 33 | print(image.getDownloadURL({format:'png'})) 34 | -------------------------------------------------------------------------------- /DeltaresDataScienceWorkshop2015/14 Linear Fit, Lights.js: -------------------------------------------------------------------------------- 1 | // Compute the trend of nighttime lights from DMSP. 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Fit a linear trend to the nighttime lights collection. 10 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 11 | .select('stable_lights') 12 | .map(createTimeBand); 13 | var fit = collection.reduce(ee.Reducer.linearFit()); 14 | 15 | // Display a single image 16 | Map.setCenter(30, 45, 4); 17 | Map.addLayer(ee.Image(collection.select('stable_lights').first()), 18 | {min: 0, max: 63}, 19 | 'stable lights first asset'); 20 | 21 | // Display trend in red/blue, brightness in green. 22 | Map.addLayer(fit, 23 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 24 | 'stable lights trend'); 25 | 26 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/01 Hello World 1.js: -------------------------------------------------------------------------------- 1 | print('Hello world!') -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/02 Hello Image.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/03 Add Image to Map.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | 6 | Map.addLayer(srtm, {min:0, max:1000}); 7 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/04 Load and Filter Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var filtered = l8 5 | .filterBounds(Map.getBounds(true)) 6 | .filterDate('2013-05-01', '2016-05-01') 7 | .filterMetadata('CLOUD_COVER', 'less_than', 30) 8 | 9 | Map.addLayer(filtered); 10 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/05 Play with Image Bands.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // Select bands to visualize, Google for wavelengths used for different satellite missions 5 | // See http://landsat.gsfc.nasa.gov/?p=10643 for a list of bands. 6 | var filtered = l8.filterBounds(Map.getBounds(true)); 7 | 8 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B4','B3','B2']}, 'RGB'); 9 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B5','B4','B3']}, 'False Color'); 10 | 11 | 12 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/06 Play with Reducing Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // reduce image collection: compute a single value using a number images 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6']; 7 | l8 = l8.select(L8_NAMES, STD_NAMES); 8 | 9 | l8 = l8.filterBounds(Map.getBounds(true)); 10 | 11 | var rgb = l8.select(['red', 'green', 'blue']); 12 | 13 | var sng = l8.select(['swir2', 'nir', 'green']); 14 | 15 | var vis = {min:0, max:0.3}; 16 | 17 | Map.addLayer(rgb.median(), vis, 'RGB'); 18 | 19 | Map.addLayer(sng.median(), vis, 'SNG'); 20 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/07 Load an Image by ID.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6']; 5 | image = image.select(L8_NAMES, STD_NAMES); 6 | 7 | var rgb = image.select(['red', 'green', 'blue']); 8 | 9 | var vis = {min:0, max:0.3}; 10 | 11 | Map.addLayer(rgb, vis, 'RGB'); 12 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/08 HSV Pan-sharpening.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | image = image.select(L8_NAMES, STD_NAMES); 6 | 7 | var rgb = image.select(['red', 'green', 'blue']); 8 | 9 | var vis = {min:0.05, max:0.25, gamma: 1.3}; 10 | 11 | Map.addLayer(rgb, vis, 'RGB'); 12 | 13 | // pan-sharpen image using 15m band 14 | var gray = image.select('pan'); 15 | var huesat = rgb.rgbToHsv().select('hue', 'saturation'); 16 | var upres = ee.Image.cat(huesat, gray).hsvToRgb(); 17 | 18 | Map.addLayer(upres, vis, 'RGB (pansharpened)'); 19 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/09 Compute NDVI.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | image = image.select(L8_NAMES, STD_NAMES); 6 | 7 | var rgb = image.select(['red', 'green', 'blue']); 8 | 9 | var vis = {min:0.05, max:0.3, gamma: 1.3}; 10 | 11 | Map.addLayer(rgb, vis, 'RGB'); 12 | 13 | // Compute vegetation index as: NDVI = (NIR - RED) / (NIR + RED) 14 | // More reading: http://earthobservatory.nasa.gov/Features/MeasuringVegetation/ 15 | 16 | var red = image.select('red'); 17 | var nir = image.select('nir'); 18 | var ndvi = nir.subtract(red).divide(nir.add(red)); 19 | 20 | Map.addLayer(ndvi, {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI'); 21 | 22 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/10 Map a Function over an Image Collection.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | l8 = l8 6 | .select(L8_NAMES, STD_NAMES) 7 | .filterDate('2014-01-01', '2014-10-01') 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | 11 | function addNdvi(image) { 12 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 13 | return image.addBands(ndvi); 14 | } 15 | 16 | var median = l8.map(addNdvi).median(); 17 | 18 | var rgb = median.select(['red', 'green', 'blue']); 19 | var vis = {min:0.05, max:0.25}; 20 | Map.addLayer(rgb, vis, 'RGB'); 21 | 22 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 23 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/11 Greenest Pixels.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | .select(['red', 'green', 'blue', 'nir']) 11 | 12 | Map.addLayer(l8, {}, 'L8', false) 13 | 14 | var vis = {min:0.05, max:0.25}; 15 | 16 | function addNdvi(image) { 17 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 18 | return image.addBands(ndvi); 19 | } 20 | 21 | l8 = l8.map(addNdvi) 22 | 23 | var median = l8.median(); 24 | 25 | Map.addLayer(median, vis, 'RGB'); 26 | 27 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 28 | 29 | var greenest = l8.qualityMosaic('ndvi'); 30 | Map.addLayer(greenest, vis, 'RGB greenest'); 31 | 32 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/12 Chart NDVI over Time.js: -------------------------------------------------------------------------------- 1 | var point = /* color: bf04c2 */ee.Geometry.Point([1.8370342254638672, 43.31887097689866]); 2 | 3 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 4 | 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 7 | 8 | l8 = l8 9 | .select(L8_NAMES, STD_NAMES) 10 | .filterBounds(Map.getBounds(true)) 11 | //.filterMetadata('CLOUD_COVER', 'less_than', 20) 12 | .select(['red', 'green', 'blue', 'nir']) 13 | 14 | var vis = {min:0.05, max:0.25}; 15 | 16 | function addNdvi(image) { 17 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 18 | return image.addBands(ndvi); 19 | } 20 | 21 | l8 = l8.map(addNdvi) 22 | 23 | var median = l8.median(); 24 | Map.addLayer(median, vis, 'RGB'); 25 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 26 | 27 | print(Chart.image.series(l8.select('ndvi'), point)); 28 | 29 | 30 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/13 Export Image.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | .select(['red', 'green', 'blue', 'nir']) 11 | 12 | var image = ee.Image(l8.first()) 13 | 14 | var vis = {min:0.05, max:0.25}; 15 | 16 | Map.addLayer(image, vis, 'L8') 17 | 18 | print(image) 19 | 20 | image = image 21 | .visualize(vis) 22 | .clip(Map.getBounds(true)) 23 | 24 | var id = image.get('LANDSAT_SCENE_ID').getInfo() 25 | 26 | // new, async way 27 | Export.image.toDrive({ 28 | image: image, 29 | description: id, 30 | scale: 30, 31 | region: Map.getBounds(true) 32 | }); 33 | 34 | // old, sync way 35 | print(image.getDownloadURL({format:'png'})) 36 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/14 Linear Fit, Lights.js: -------------------------------------------------------------------------------- 1 | // Compute the trend of nighttime lights from DMSP. 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Fit a linear trend to the nighttime lights collection. 10 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 11 | .select('stable_lights') 12 | .map(createTimeBand); 13 | var fit = collection.reduce(ee.Reducer.linearFit()); 14 | 15 | // Display a single image 16 | Map.setCenter(30, 45, 4); 17 | Map.addLayer(ee.Image(collection.select('stable_lights').first()), 18 | {min: 0, max: 63}, 19 | 'stable lights first asset'); 20 | 21 | // Display trend in red/blue, brightness in green. 22 | Map.addLayer(fit, 23 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 24 | 'stable lights trend'); 25 | 26 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2016/15 Water.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 3 | dam = /* color: d63000 */ee.Geometry.Point([65.50529479980469, 38.33761692801908]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.centerObject(dam, 12) 6 | 7 | var image = ee.Image(l8 8 | .filterBounds(Map.getCenter()) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 15) 10 | .select(['B6','B5','B3']) 11 | .toList(1, 10).get(0)) 12 | 13 | Map.addLayer(image, {min: 0.05, max: 0.5}, 'landsat 8') 14 | 15 | var ndwi = image.normalizedDifference(['B3', 'B5']) 16 | 17 | // ndwi = ndwi.unitScale(0, 0.5) 18 | 19 | Map.addLayer(ndwi, {min:0, max:1}, 'NDWI', false) 20 | 21 | Map.addLayer(ndwi.mask(ndwi), {palette:['000055', '0000ff']}, 'water mask') 22 | 23 | var edge = ee.Algorithms.CannyEdgeDetector(ndwi, 0.99) 24 | Map.addLayer(edge.mask(edge), {palette:['ffffff']}, 'reservoir edge') 25 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/01 Hello World 1.js: -------------------------------------------------------------------------------- 1 | print('Hello world!') -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/02 Hello Image.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/03 Add Image to Map.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"), 3 | point = /* color: #d63000 */ee.Geometry.Point([4.381442070007324, 51.98525016185232]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.centerObject(point, 14) 6 | 7 | print(srtm); 8 | 9 | Map.addLayer(srtm, {min:0, max:10}); 10 | 11 | // TODO: add AHN to map -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/04 Load and Filter Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var filtered = l8 5 | .filterBounds(Map.getBounds(true)) 6 | .filterDate('2013-05-01', '2016-05-01') 7 | .filterMetadata('CLOUD_COVER', 'less_than', 30); 8 | 9 | Map.addLayer(filtered); 10 | 11 | // TODO: visualize resulting image (mosaic) as RGB, use 0.3 as a max reflectance and Google required Landsat 8 bands 12 | 13 | // TODO: add a filter to select only images with SUN_ELEVATION > 50 -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/05 Image Bands.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 3 | point = /* color: #d63000 */ee.Geometry.Point([4.381442070007324, 51.98525016185232]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.centerObject(point, 14) 6 | 7 | // Select bands to visualize, Google for wavelengths used for different satellite missions 8 | 9 | // See http://landsat.gsfc.nasa.gov/?p=10643 for a list of bands. 10 | var filtered = l8.filterBounds(Map.getBounds(true)); 11 | 12 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B4','B3','B2']}, 'RGB'); 13 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B5','B4','B3']}, 'False Color'); 14 | 15 | 16 | // TODO: add Landsat 7 image collection instead of Landsat 8. 17 | 18 | // TODO: Which bands do we need to use to create the same composites as for Landsat 8? 19 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/07 Compute NDWI.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 2 | dam = /* color: d63000 */ee.Geometry.Point([65.50529479980469, 38.33761692801908]); 3 | 4 | Map.centerObject(dam, 12) 5 | 6 | var image = ee.Image(l8 7 | .filterBounds(Map.getCenter()) 8 | .filterMetadata('CLOUD_COVER', 'less_than', 15) 9 | .select(['B6','B5','B3']) 10 | .toList(1, 10).get(0)) 11 | 12 | Map.addLayer(image, {min: 0.05, max: 0.5}, 'landsat 8') 13 | 14 | // add NDWI masked values 15 | var ndwi = image.normalizedDifference(['B3', 'B6']) 16 | Map.addLayer(ndwi.mask(ndwi), {palette:['000055', '0000ff'], opacity: 0.5}, 'water mask') 17 | 18 | // show water edge 19 | var edge = ee.Algorithms.CannyEdgeDetector(ndwi, 0.99) 20 | Map.addLayer(edge.mask(edge), {palette:['ffffff']}, 'reservoir edge') 21 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/08 Compute NDVI.js: -------------------------------------------------------------------------------- 1 | Map.setCenter(4.381442070007324, 51.98525016185232, 12); // Delft 2 | 3 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 4 | 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 7 | image = image.select(L8_NAMES, STD_NAMES); 8 | 9 | var rgb = image.select(['red', 'green', 'blue']); 10 | 11 | var vis = {min:0.05, max:0.3, gamma: 1.3}; 12 | 13 | Map.addLayer(rgb, vis, 'RGB'); 14 | 15 | // Compute vegetation index as: NDVI = (NIR - RED) / (NIR + RED) 16 | // More reading: http://earthobservatory.nasa.gov/Features/MeasuringVegetation/ 17 | 18 | var red = image.select('red'); 19 | var nir = image.select('nir'); 20 | var ndvi = nir.subtract(red).divide(nir.add(red)); 21 | 22 | var Palettes = { 23 | ndvi: [ '306466', '9cab68', 'cccc66', '9c8448', '6e462c' ] 24 | } 25 | 26 | Map.addLayer(ndvi, {palette: Palettes.ndvi, min:-0.35, max:0.8}, 'NDVI'); 27 | 28 | // TODO: threshold NDVI to mark vegetated areas, for example, NDVI > 0.5 29 | 30 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/10 Map a Function over an Image Collection.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | l8 = l8 6 | .select(L8_NAMES, STD_NAMES) 7 | .filterDate('2014-01-01', '2014-10-01') 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | 11 | function addNdvi(image) { 12 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 13 | return image.addBands(ndvi); 14 | } 15 | 16 | var median = l8.map(addNdvi).median(); 17 | 18 | var rgb = median.select(['red', 'green', 'blue']); 19 | var vis = {min:0.05, max:0.25}; 20 | Map.addLayer(rgb, vis, 'RGB'); 21 | 22 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 23 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/13 Export Image.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | .select(['red', 'green', 'blue', 'nir']) 11 | 12 | var image = ee.Image(l8.first()) 13 | 14 | var vis = {min:0.05, max:0.25}; 15 | 16 | Map.addLayer(image, vis, 'L8') 17 | 18 | print(image) 19 | 20 | image = image 21 | .visualize(vis) 22 | .clip(Map.getBounds(true)) 23 | 24 | var id = image.get('LANDSAT_SCENE_ID').getInfo() 25 | 26 | // new, async way 27 | Export.image.toDrive({ 28 | image: image, 29 | description: id, 30 | scale: 30, 31 | region: Map.getBounds(true) 32 | }); 33 | 34 | // old, sync way 35 | print(image.getDownloadURL({format:'png'})) 36 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2017/15 Linear Fit, Lights.js: -------------------------------------------------------------------------------- 1 | // Compute the trend of nighttime lights from DMSP. 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Fit a linear trend to the nighttime lights collection. 10 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 11 | .select('stable_lights') 12 | .map(createTimeBand); 13 | var fit = collection.reduce(ee.Reducer.linearFit()); 14 | 15 | // Display a single image 16 | Map.setCenter(30, 45, 4); 17 | Map.addLayer(ee.Image(collection.select('stable_lights').first()), 18 | {min: 0, max: 63}, 19 | 'stable lights first asset'); 20 | 21 | // Display trend in red/blue, brightness in green. 22 | Map.addLayer(fit, 23 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 24 | 'stable lights trend'); 25 | 26 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/01 Hello World.js: -------------------------------------------------------------------------------- 1 | print('Hello world!') -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/02 Hello Image.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/03 Add Image to Map.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"), 3 | point = /* color: #d63000 */ee.Geometry.Point([4.381442070007324, 51.98525016185232]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.centerObject(point, 14) 6 | 7 | print(srtm); 8 | 9 | Map.addLayer(srtm, {min:0, max:10}); 10 | 11 | // TODO: add AHN to map -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/04 Load and Filter Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var filtered = l8 5 | .filterBounds(Map.getBounds(true)) 6 | .filterDate('2013-05-01', '2016-05-01') 7 | .filterMetadata('CLOUD_COVER', 'less_than', 30); 8 | 9 | Map.addLayer(filtered); 10 | 11 | 12 | // TODO: visualize resulting image (mosaic) as RGB, use 0.3 as a max reflectance and Google required Landsat 8 bands 13 | 14 | // TODO: add a filter to select only images with SUN_ELEVATION > 50 -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/08 Compute NDVI.js: -------------------------------------------------------------------------------- 1 | Map.setCenter(4.381442070007324, 51.98525016185232, 12); // Delft 2 | 3 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 4 | 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 7 | image = image.select(L8_NAMES, STD_NAMES); 8 | 9 | var rgb = image.select(['red', 'green', 'blue']); 10 | 11 | var vis = {min:0.05, max:0.3, gamma: 1.3}; 12 | 13 | Map.addLayer(rgb, vis, 'RGB'); 14 | 15 | // Compute vegetation index as: NDVI = (NIR - RED) / (NIR + RED) 16 | // More reading: http://earthobservatory.nasa.gov/Features/MeasuringVegetation/ 17 | 18 | var red = image.select('red'); 19 | var nir = image.select('nir'); 20 | var ndvi = nir.subtract(red).divide(nir.add(red)); 21 | 22 | var Palettes = { 23 | ndvi: [ '306466', '9cab68', 'cccc66', '9c8448', '6e462c' ] 24 | } 25 | 26 | Map.addLayer(ndvi, {palette: Palettes.ndvi, min:-0.35, max:0.8}, 'NDVI'); 27 | 28 | // TODO: threshold NDVI to mark vegetated areas, for example, NDVI > 0.5 29 | 30 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/10 Map a Function over an Image Collection.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA'); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | l8 = l8 6 | .select(L8_NAMES, STD_NAMES) 7 | .filterDate('2014-01-01', '2014-10-01') 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | 11 | function addNdvi(image) { 12 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 13 | return image.addBands(ndvi); 14 | } 15 | 16 | var median = l8.map(addNdvi).median(); 17 | 18 | var rgb = median.select(['red', 'green', 'blue']); 19 | var vis = {min:0.05, max:0.25}; 20 | Map.addLayer(rgb, vis, 'RGB'); 21 | 22 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 23 | 24 | // TODO: compute mean() NDWI (water index) value by mapping a function over image collection -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/13 Export Image.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | .select(['red', 'green', 'blue', 'nir']) 11 | 12 | var image = ee.Image(l8.first()) 13 | 14 | var vis = {min:0.05, max:0.25}; 15 | 16 | Map.addLayer(image, vis, 'L8') 17 | 18 | print(image) 19 | 20 | image = image 21 | .visualize(vis) 22 | .clip(Map.getBounds(true)) 23 | 24 | var id = image.get('LANDSAT_SCENE_ID').getInfo() 25 | 26 | // new, async way 27 | Export.image.toDrive({ 28 | image: image, 29 | description: id, 30 | scale: 30, 31 | region: Map.getBounds(true) 32 | }); 33 | 34 | // old, sync way 35 | print(image.getDownloadURL({format:'png'})) 36 | -------------------------------------------------------------------------------- /DeltaresGoogleEarthEngineTraining2019_TwenteU/15 Linear Fit, Lights.js: -------------------------------------------------------------------------------- 1 | // Compute the trend of nighttime lights from DMSP. 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Fit a linear trend to the nighttime lights collection. 10 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 11 | .select('stable_lights') 12 | .map(createTimeBand); 13 | var fit = collection.reduce(ee.Reducer.linearFit()); 14 | 15 | // Display a single image 16 | Map.setCenter(30, 45, 4); 17 | Map.addLayer(ee.Image(collection.select('stable_lights').first()), 18 | {min: 0, max: 63}, 19 | 'stable lights first asset'); 20 | 21 | // Display trend in red/blue, brightness in green. 22 | Map.addLayer(fit, 23 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 24 | 'stable lights trend'); 25 | 26 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/01 Hello World 1.js: -------------------------------------------------------------------------------- 1 | print('Hello World!') -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/02 Hello Image.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/03 Add Image to Map.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | 6 | Map.addLayer(srtm, {min:0, max:1000}); 7 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/04 Load and Filter Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var filtered = l8 5 | .filterBounds(Map.getBounds(true)) 6 | .filterDate('2013-05-01', '2016-05-01') 7 | .filterMetadata('CLOUD_COVER', 'less_than', 30) 8 | 9 | Map.addLayer(filtered); 10 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/05 Image Bands.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // Select bands to visualize, Google for wavelengths used for different satellite missions 5 | // See http://landsat.gsfc.nasa.gov/?p=10643 for a list of bands. 6 | var filtered = l8.filterBounds(Map.getBounds(true)); 7 | 8 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B4','B3','B2']}, 'RGB'); 9 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B5','B4','B3']}, 'False Color'); 10 | 11 | 12 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/07 Compute NDWI.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 2 | dam = /* color: d63000 */ee.Geometry.Point([65.50529479980469, 38.33761692801908]); 3 | 4 | Map.centerObject(dam, 12) 5 | 6 | var image = ee.Image(l8 7 | .filterBounds(Map.getCenter()) 8 | .filterMetadata('CLOUD_COVER', 'less_than', 15) 9 | .select(['B6','B5','B3']) 10 | .toList(1, 10).get(0)) 11 | 12 | Map.addLayer(image, {min: 0.05, max: 0.5}, 'landsat 8') 13 | 14 | // add NDWI masked values 15 | var ndwi = image.normalizedDifference(['B3', 'B6']) 16 | Map.addLayer(ndwi.mask(ndwi), {palette:['000055', '0000ff'], opacity: 0.5}, 'water mask') 17 | 18 | // show water edge 19 | var edge = ee.Algorithms.CannyEdgeDetector(ndwi, 0.99) 20 | Map.addLayer(edge.mask(edge), {palette:['ffffff']}, 'reservoir edge') 21 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/08 Map a Function over an Image Collection.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | l8 = l8 6 | .select(L8_NAMES, STD_NAMES) 7 | .filterDate('2014-01-01', '2014-10-01') 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 10 | 11 | function addNdvi(image) { 12 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 13 | return image.addBands(ndvi); 14 | } 15 | 16 | var median = l8.map(addNdvi).median(); 17 | 18 | var rgb = median.select(['red', 'green', 'blue']); 19 | var vis = {min:0.05, max:0.25}; 20 | Map.addLayer(rgb, vis, 'RGB'); 21 | 22 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 23 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/09 Linear Fit, Lights.js: -------------------------------------------------------------------------------- 1 | // Compute the trend of nighttime lights from DMSP. 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Fit a linear trend to the nighttime lights collection. 10 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 11 | .select('stable_lights') 12 | .map(createTimeBand); 13 | var fit = collection.reduce(ee.Reducer.linearFit()); 14 | 15 | // Display a single image 16 | Map.setCenter(30, 45, 4); 17 | Map.addLayer(ee.Image(collection.select('stable_lights').first()), 18 | {min: 0, max: 63}, 19 | 'stable lights first asset'); 20 | 21 | // Display trend in red/blue, brightness in green. 22 | Map.addLayer(fit, 23 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 24 | 'stable lights trend'); 25 | 26 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/10 Percentile Composite.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 5 | 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterDate('2014-01-01', '2014-10-01') 9 | .filterBounds(Map.getBounds(true)) 10 | 11 | // add all images (for inspection) 12 | Map.addLayer(l8, {}, 'all', false); 13 | 14 | // compute percentile composites 15 | var p15 = l8.reduce(ee.Reducer.percentile([15])).rename(STD_NAMES); 16 | var p35 = l8.reduce(ee.Reducer.percentile([35])).rename(STD_NAMES); 17 | var p55 = l8.reduce(ee.Reducer.percentile([55])).rename(STD_NAMES); 18 | 19 | // add to map 20 | var vis = {min:0.05, max:0.45}; 21 | Map.addLayer(p15.select(['swir1', 'nir', 'green']), vis, '15%'); 22 | Map.addLayer(p35.select(['swir1', 'nir', 'green']), vis, '35%'); 23 | Map.addLayer(p55.select(['swir1', 'nir', 'green']), vis, '55%'); 24 | -------------------------------------------------------------------------------- /DeltaresSoftwareDays2016_AquaMonitor/11 Linear Fit, Water.js: -------------------------------------------------------------------------------- 1 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA") 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(ee.Image(year).rename('year')).byte().addBands(img); 7 | } 8 | 9 | // compute wetness 10 | function computeWetness(img) { 11 | var ndwi = img.normalizedDifference(['B3', 'B6']).rename('wetness') 12 | 13 | return ee.Image(img).addBands(ndwi); 14 | } 15 | 16 | // compute NDWI 17 | var images = l8 18 | .filterBounds(Map.getCenter()) 19 | .map(createTimeBand) 20 | .map(computeWetness) 21 | .select(['year', 'wetness']) 22 | 23 | print(images.first()) 24 | 25 | var fit = images.reduce(ee.Reducer.linearFit()); 26 | 27 | // Display trend in red/blue, brightness in green. 28 | Map.addLayer(fit, 29 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 30 | 'stable lights trend'); 31 | 32 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/01 Hello World.js: -------------------------------------------------------------------------------- 1 | print("Hello, world!"); 2 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/02 Hello Image.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(srtm); 5 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/03 Add Image to Map.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // simple script to add map layer to IDE 5 | print(srtm); 6 | 7 | Map.addLayer(srtm, {min:0, max:1000}); 8 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/04 Load and Filter Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // load collection but refine by location/date/cloud cover 5 | var filtered = l8 6 | .filterBounds(Map.getBounds(true)) 7 | .filterDate('2013-05-01', '2016-05-01') 8 | .filterMetadata('CLOUD_COVER', 'less_than', 30) 9 | 10 | Map.addLayer(filtered); 11 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/05 Play with Image Bands.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // Select bands to visualize, Google for wavelengths used for different satellite missions 5 | // See http://landsat.gsfc.nasa.gov/?p=10643 for a list of bands. 6 | var filtered = l8.filterBounds(Map.getBounds(true)); 7 | 8 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B4','B3','B2']}, 'RGB'); 9 | Map.addLayer(filtered, {min:0, max:0.3, bands:['B5','B4','B3']}, 'False Color'); 10 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/06 Play with Reducing Image Collections.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // reduce image collection: compute a single value using a number images 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6']; 7 | l8 = l8.select(L8_NAMES, STD_NAMES); 8 | 9 | l8 = l8.filterBounds(Map.getBounds(true)); 10 | 11 | // define true color 12 | var rgb = l8.select(['red', 'green', 'blue']); 13 | 14 | // define false color 15 | var sng = l8.select(['swir1', 'nir', 'green']); 16 | 17 | var vis = {min:0, max:0.5}; 18 | 19 | Map.addLayer(rgb.median(), vis, 'median RGB'); 20 | 21 | Map.addLayer(sng.median(), vis, 'median SNG'); 22 | 23 | Map.addLayer(sng.reduce(ee.Reducer.percentile([15])), vis, '15% percentile SNG'); 24 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/07 Load an Image by ID.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 2 | 3 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1']; 4 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6']; 5 | image = image.select(L8_NAMES, STD_NAMES); 6 | 7 | var rgb = image.select(['red', 'green', 'blue']); 8 | 9 | var vis = {min:0, max:0.3}; 10 | 11 | Map.addLayer(rgb, vis, 'RGB'); 12 | 13 | Map.centerObject(rgb) -------------------------------------------------------------------------------- /TUDelftWorkshop2016/08 HSV Pan-sharpening.js: -------------------------------------------------------------------------------- 1 | // load image -> convert to 15m (pan-sharpening) using the panchromatic band 2 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 3 | 4 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 5 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 6 | image = image.select(L8_NAMES, STD_NAMES); 7 | 8 | var rgb = image.select(['red', 'green', 'blue']); 9 | 10 | var vis = {min:0.05, max:0.25, gamma: 1.3}; 11 | 12 | Map.addLayer(rgb, vis, 'RGB'); 13 | 14 | // pan-sharpen image using 15m band 15 | var gray = image.select('pan'); 16 | var huesat = rgb.rgbToHsv().select('hue', 'saturation'); 17 | var upres = ee.Image.cat(huesat, gray).hsvToRgb(); 18 | 19 | Map.addLayer(upres, vis, 'RGB (pansharpened)'); 20 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/09 Compute NDVI.js: -------------------------------------------------------------------------------- 1 | // compute the normalized vegetation index based on nir/red 2 | var image = ee.Image('LANDSAT/LC8_L1T_TOA/LC81980242014068LGN00'); 3 | 4 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 5 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 6 | image = image.select(L8_NAMES, STD_NAMES); 7 | 8 | var rgb = image.select(['red', 'green', 'blue']); 9 | 10 | var vis = {min:0.05, max:0.3, gamma: 1.3}; 11 | 12 | Map.addLayer(rgb, vis, 'RGB'); 13 | 14 | // Compute vegetation index as: NDVI = (NIR - RED) / (NIR + RED) 15 | // More reading: http://earthobservatory.nasa.gov/Features/MeasuringVegetation/ 16 | 17 | var red = image.select('red'); 18 | var nir = image.select('nir'); 19 | var ndvi = nir.subtract(red).divide(nir.add(red)); 20 | 21 | Map.addLayer(ndvi, {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI'); 22 | 23 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/10 Map a Function over an Image Collection.js: -------------------------------------------------------------------------------- 1 | // different method to add NDVI using a self-made function 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | 4 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 5 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 6 | l8 = l8 7 | .select(L8_NAMES, STD_NAMES) 8 | .filterDate('2014-01-01', '2014-10-01') 9 | .filterBounds(Map.getBounds(true)) 10 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 11 | 12 | function addNdvi(image) { 13 | var ndvi = image.normalizedDifference(['nir', 'red']).rename('ndvi') 14 | return image.addBands(ndvi); 15 | } 16 | 17 | var median = l8.map(addNdvi).median(); 18 | 19 | var rgb = median.select(['red', 'green', 'blue']); 20 | var vis = {min:0.05, max:0.25}; 21 | Map.addLayer(rgb, vis, 'RGB'); 22 | 23 | Map.addLayer(median.select('ndvi'), {palette: '5050FF, 000000, 00FF00', min:-0.5, max:0.5}, 'NDVI', false); 24 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/12 Export Image.js: -------------------------------------------------------------------------------- 1 | // https://developers.google.com/earth-engine/exporting#to-drive 2 | 3 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 4 | 5 | var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'pan']; 6 | var L8_NAMES = ['B2', 'B3', 'B4', 'B5', 'B6', 'B8']; 7 | 8 | var bounds = Map.getBounds(true) 9 | 10 | l8 = l8 11 | .select(L8_NAMES, STD_NAMES) 12 | .filterBounds(bounds) 13 | .filterMetadata('CLOUD_COVER', 'less_than', 20) 14 | .select(['red', 'green', 'blue', 'nir']) 15 | 16 | var image = ee.Image(l8.first()) 17 | 18 | var vis = {min:0.05, max:[0.15, 0.15, 0.2]}; 19 | 20 | Map.addLayer(image, vis, 'L8') 21 | 22 | print(image) 23 | 24 | 25 | var fileName = image.get('LANDSAT_SCENE_ID').getInfo() 26 | 27 | print(fileName) 28 | 29 | var imageRendered = image.visualize(vis) 30 | 31 | Export.image.toDrive({ 32 | image: imageRendered, 33 | description: fileName, 34 | fileNamePrefix: fileName, 35 | scale: 30, 36 | region: bounds 37 | }); -------------------------------------------------------------------------------- /TUDelftWorkshop2016/13 Linear Fit, Lights.js: -------------------------------------------------------------------------------- 1 | // Compute the trend of nighttime lights from DMSP. 2 | 3 | // Add a band containing image date as years since 1991. 4 | function createTimeBand(img) { 5 | var year = ee.Date(img.get('system:time_start')).get('year').subtract(1991); 6 | return ee.Image(year).byte().addBands(img); 7 | } 8 | 9 | // Fit a linear trend to the nighttime lights collection. 10 | var collection = ee.ImageCollection('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS') 11 | .select('stable_lights') 12 | .map(createTimeBand); 13 | var fit = collection.reduce(ee.Reducer.linearFit()); 14 | 15 | // Display a single image 16 | Map.setCenter(30, 45, 4); 17 | Map.addLayer(ee.Image(collection.select('stable_lights').first()), 18 | {min: 0, max: 63}, 19 | 'stable lights first asset'); 20 | 21 | // Display trend in red/blue, brightness in green. 22 | Map.addLayer(fit, 23 | {min: 0, max: [0.18, 20, -0.18], bands: ['scale', 'offset', 'scale']}, 24 | 'stable lights trend'); 25 | 26 | -------------------------------------------------------------------------------- /TUDelftWorkshop2016/15 Water.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 3 | dam = /* color: d63000 */ee.Geometry.Point([65.50529479980469, 38.33761692801908]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.centerObject(dam, 12) 6 | 7 | var image = ee.Image(l8 8 | .filterBounds(Map.getCenter()) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 15) 10 | .select(['B6','B5','B3']) 11 | .toList(1, 10).get(0)) 12 | 13 | Map.addLayer(image, {min: 0.05, max: 0.5}, 'landsat 8') 14 | 15 | var ndwi = image.normalizedDifference(['B3', 'B5']) 16 | 17 | // ndwi = ndwi.unitScale(0, 0.5) 18 | 19 | Map.addLayer(ndwi, {min:0, max:1}, 'NDWI', false) 20 | 21 | Map.addLayer(ndwi.mask(ndwi), {palette:['000055', '0000ff']}, 'water mask') 22 | 23 | var edge = ee.Algorithms.CannyEdgeDetector(ndwi, 0.99) 24 | Map.addLayer(edge.mask(edge), {palette:['ffffff']}, 'reservoir edge') 25 | -------------------------------------------------------------------------------- /aqua-monitor/scene-count.js: -------------------------------------------------------------------------------- 1 | var l8 = new ee.ImageCollection('LANDSAT/LC8_L1T_TOA').select(0); 2 | var l7 = new ee.ImageCollection('LANDSAT/LE7_L1T_TOA').select(0); 3 | var l5 = new ee.ImageCollection('LANDSAT/LT5_L1T_TOA').select(0); 4 | var l4 = new ee.ImageCollection('LANDSAT/LT4_L1T_TOA').select(0); 5 | 6 | var images = ee.ImageCollection(l8.merge(l7).merge(l5).merge(l4)) 7 | 8 | //var grid = ee.FeatureCollection('ft:1CH6u9UdsYgU6qsEtbsHxvYBf8ucnflmtbRVeTrU_'); // 4 degrees 9 | var grid = ee.FeatureCollection('ft:1cmASWugzqQBLH93vRf9t7Zvfpx_RvtmVhy8IGd6H') // 3 degrees 10 | 11 | grid = grid.map(function(f) { 12 | var count = images.filterBounds(f.geometry()).aggregate_count('system:time_start') 13 | return f.set('landsat_scene_count', count) 14 | }) 15 | 16 | Export.table(grid, 'grid_3degree_landsat_count') -------------------------------------------------------------------------------- /art2017/dem_hilshade_render.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image("LE7_TOA_1YEAR/2014"); 2 | Map.addLayer(image, {min:0, max: 100, bands: ["B3", "B2", "B1"]}) 3 | 4 | var hillshade = ee.Terrain.hillshade(ee.Image("srtm90_v4")) 5 | image = image.add(hillshade.int().subtract(180)) 6 | 7 | Map.addLayer(image, {min:0, max: 100, bands: ["B3", "B2", "B1"]}) -------------------------------------------------------------------------------- /by-year/2015/ map scale is in meters: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var geometry = /* color: d63000 */ee.Geometry.LineString( 3 | [[-125.947265625, 40.64730356252251], 4 | [-119.619140625, 45.521743896993634], 5 | [-109.248046875, 44.84029065139799]]); 6 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 7 | print(Map.getScale()) // map scale is in meters 8 | print(ee.Projection('EPSG:3857')) // map projection (Pseudo-Mercator) 9 | 10 | print(geometry.projection().crs()) // projection of geometry is geographic 11 | 12 | print(geometry.coordinates().get(0)) // 1st coordinate is in degrees 13 | print(geometry.length()) // but lengths is in meters 14 | print(geometry.length(1e-5, geometry.projection())) // geometry length in degrees 15 | 16 | -------------------------------------------------------------------------------- /by-year/2015/AU, flow accumulation: -------------------------------------------------------------------------------- 1 | // AU, flow accumulation 2 | 3 | var flowaccu = new ee.Image('GME/images/05889347502198831302-14427924602502221744'); 4 | Map.centerObject(flowaccu); 5 | Map.addLayer(flowaccu.mask(flowaccu.gt(10)), {min:10, max:10000000, palette:'0000FF'}, 'flow accumulation') -------------------------------------------------------------------------------- /by-year/2015/BUG, buffer geometry gives error: -------------------------------------------------------------------------------- 1 | // BUG: buffer geometry gives error 2 | 3 | /* 4 | var basins = ee.FeatureCollection('ft:1-aMEhsi4usdxVUSSjKkJGC8pir3duCi_5oItnxtT'); 5 | var id = 5060087630; 6 | var basin = ee.Feature(basins.filter(ee.Filter.eq('HYBAS_ID', id)).first()); 7 | */ 8 | 9 | var basins = ee.FeatureCollection('ft:1jVWsPL91fcIoLyNXE0DNEGrJPclOwbD2MTrwP2ve') 10 | var id = 6020006540; 11 | var basin = ee.Feature(basins.filter(ee.Filter.eq('HYBAS_ID', id)).first()); 12 | 13 | Map.centerObject(basin, 5) 14 | 15 | Map.addLayer(basin, {}, 'basin') 16 | 17 | // error 18 | // Map.addLayer(basin, {}, 'basin (buffered)') 19 | 20 | print(basin) 21 | 22 | var proj = ee.Projection('EPSG:3395') 23 | 24 | print('Area: ', basin.area(1, proj)) 25 | print('Pixels: ', basin.area(1, proj).getInfo() / (90.0 * 90.0)) 26 | 27 | // no error 28 | var basin = basin.simplify(2000).buffer(3000, 500); 29 | print(basin) 30 | 31 | Map.addLayer(basin, {}, 'basin (buffered)') 32 | 33 | // get bounds 34 | print(basin.bounds()); 35 | 36 | 37 | -------------------------------------------------------------------------------- /by-year/2015/BUGS canny, export: -------------------------------------------------------------------------------- 1 | // BUGS: canny, export 2 | 3 | var img = ee.Image('L7_L1T/LE71130602002104EDC00').select('80'); 4 | Map.centerObject(img, 15); 5 | img = img.clip(Map.getBounds(true)); 6 | 7 | Map.addLayer(img); 8 | 9 | var canny = ee.Algorithms.CannyEdgeDetector(img, 0.99, 4); 10 | Map.addLayer(canny.mask(canny), {min: 0, max: 1, palette: 'FF0000'}, 'cannny'); 11 | //Map.addLayer(canny, {}, 'canny (no mask'); 12 | 13 | // export 14 | var crs = JSON.stringify(canny.getInfo().bands[0].crs); 15 | var crs_t = JSON.stringify(canny.getInfo().bands[0].crs_transform); 16 | 17 | var region = JSON.stringify(Map.getBounds(true).coordinates); 18 | //Export.image(canny, "canny", { scale: 1, region: region }); 19 | 20 | // download 21 | //print(canny.getDownloadURL({crs: crs, crs_transform: crs_t, dimensions:'500x100' })); 22 | 23 | // convert to vector 24 | var canny_v = canny.mask(canny).reduceToVectors(); 25 | print(canny_v) 26 | 27 | -------------------------------------------------------------------------------- /by-year/2015/BUG_ViewfinderpanoramaAndTerrain: -------------------------------------------------------------------------------- 1 | var images = ee.ImageCollection('users/gena/VFP_DEM').mosaic() 2 | Map.addLayer(ee.Terrain.slope(images), {min:0, max:0.3}) 3 | 4 | var image1 = ee.Image('users/gena/ViewfinderpanoramaDEM/VFP_DEM1') 5 | Map.addLayer(ee.Terrain.slope(image1), {min:0, max:0.3}) 6 | 7 | Map.centerObject(image1) 8 | 9 | -------------------------------------------------------------------------------- /by-year/2015/BUG_feature_collection.js: -------------------------------------------------------------------------------- 1 | var fc = ee.FeatureCollection('ft:1YQ1qpXis4Z9z0NvKLdz-FjxFP5q2_fABi6aNSFn0'); 2 | 3 | var mapBasins = fc.filterBounds(Map.getBounds(true)) 4 | 5 | Map.addLayer(mapBasins) 6 | 7 | print(mapBasins) -------------------------------------------------------------------------------- /by-year/2015/BUG_normalize_kernel.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l5 = ee.ImageCollection("LANDSAT/LT5_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var image = ee.Image(l5.filterBounds(Map.getCenter()) 5 | .filterMetadata('CLOUD_COVER', 'less_than', 10).select(['B5','B4','B2']).first()); 6 | 7 | Map.addLayer(image, {min:0.05, max:0.5}, 'original') 8 | 9 | var weights = [[-1, -1, -1], [-1, 9.0, -1], [-1, -1, -1]] 10 | var kernel = ee.Kernel.fixed(3, 3, weights) 11 | print(kernel) 12 | Map.addLayer(image.convolve(kernel), {min:0.05, max:0.5}, 'sharpened 1') 13 | 14 | // should result in the same kernel since it is already sum(K) == 1 15 | var kernel = ee.Kernel.fixed(3, 3, weights, -1, -1, true) 16 | print(kernel) 17 | Map.addLayer(image.convolve(kernel), {min:0.05, max:0.5}, 'sharpened 2') 18 | 19 | -------------------------------------------------------------------------------- /by-year/2015/ClusteringTest.js: -------------------------------------------------------------------------------- 1 | // Clustering example 1 2 | 3 | var imageOriginal = ee.ImageCollection("NAIP/WI_2010").mosaic().normalizedDifference(["R", "N"]) 4 | 5 | var maxObjectSize = 256; 6 | 7 | // The RegionGrow algorithm has these arguments: 8 | // threshold - The maximum distance for inclusion in the current cluster. 9 | // useCosine - Whether to use cosine distance instead of euclidean distance 10 | // when computing the spectral distance. 11 | // secondPass - Apply a refinement pass to the clustering results. 12 | var imageClustered = ee.apply("Test.Clustering.RegionGrow", { 13 | "image": imageOriginal, 14 | "useCosine": false, 15 | "threshold": 0.1, 16 | "maxObjectSize": maxObjectSize, 17 | }); 18 | 19 | var imageConsistent = ee.apply("Test.Clustering.SpatialConsistency", { 20 | "image": imageClustered, 21 | "maxObjectSize": maxObjectSize 22 | }); 23 | 24 | addToMap(imageOriginal, {}, "Original"); 25 | // Uncomment this line to see the per-tile clustering output 26 | addToMap(imageConsistent.select('clusters').randomVisualizer(), {}, "Consistent"); -------------------------------------------------------------------------------- /by-year/2015/CoastTest1: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | l8 = l8 5 | .select(['B6', 'B5', 'B3']) 6 | //.filterDate('2013-06-06', '2014-06-06') 7 | 8 | function getPercentile(ic, percentile) { 9 | return ic.reduce(ee.Reducer.percentile([percentile])) 10 | } 11 | 12 | Map.addLayer(l8.count(), {min:0, max:50}, 'count', false) 13 | 14 | for(var i = 5; i < 30; i+= 2) { 15 | var im = getPercentile(l8, i); 16 | Map.addLayer(im, {min:0.05, max:0.2}, i + '%', false) 17 | Map.addLayer(im.normalizedDifference(['B3', 'B5']), {min:-0.5, max:0.5}, i + '% NDWI', false) 18 | } -------------------------------------------------------------------------------- /by-year/2015/DetectReservoir.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 3 | dam = /* color: d63000 */ee.Geometry.Point([65.50529479980469, 38.33761692801908]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.centerObject(dam, 12) 6 | 7 | var image = ee.Image(l8 8 | .filterBounds(Map.getCenter()) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 15) 10 | .select(['B6','B5','B3']) 11 | .toList(1, 10).get(0)) 12 | 13 | Map.addLayer(image, {min: 0.05, max: 0.5}, 'landsat 8') 14 | 15 | var mndwi = image.normalizedDifference(['B3', 'B6']) 16 | 17 | Map.addLayer(mndwi.mask(mndwi), {palette:['000055', '0000ff'], opacity: 0.5}, 'water mask') 18 | 19 | var edge = ee.Algorithms.CannyEdgeDetector(mndwi, 0.99) 20 | Map.addLayer(edge.mask(edge), {palette:['ffffff']}, 'reservoir edge') -------------------------------------------------------------------------------- /by-year/2015/ETOPO1: -------------------------------------------------------------------------------- 1 | // ETOPO1 2 | 3 | var dem = ee.Image('NOAA/NGDC/ETOPO1').select('bedrock'); 4 | addToMap(dem.mask(dem.lt(0)), {min:0, max:-10000}); 5 | -------------------------------------------------------------------------------- /by-year/2015/ExportPansharpened: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(Map.getCenter()) 5 | Map.setCenter(-78.18, 37.19) 6 | 7 | l8 = l8 8 | .filterMetadata('CLOUD_COVER', 'less_than', 10) 9 | .filterBounds(ee.Geometry(Map.getBounds(true)).centroid(1)) 10 | 11 | var image = ee.Image(l8.first()) 12 | 13 | var rgb = image.select(['B4','B3','B2']) 14 | var pan = image.select('B8') 15 | 16 | var hsv = rgb.rgbtohsv(); 17 | var huesat = hsv.select('hue', 'saturation'); 18 | var pansharpened = ee.Image.cat(huesat, pan).hsvtorgb(); 19 | 20 | Map.addLayer(rgb, {min:0.03, max:0.25}, 'rgb') 21 | Map.addLayer(pansharpened, {min:0.03, max:[0.25,0.25,0.35]}, 'pansharpened') 22 | 23 | Export.image(pansharpened) 24 | -------------------------------------------------------------------------------- /by-year/2015/FEATURE_FeatureCollection_sort.js: -------------------------------------------------------------------------------- 1 | var dams = ee.FeatureCollection('ft:1gtV2qZY2sVBpz-_1_1jndm0eJmuvJ7hN6s5ooV9I') 2 | .filter(ee.Filter.and(ee.Filter.neq('YEAR', -99), ee.Filter.neq('CATCH_SKM', -99))) 3 | 4 | Map.addLayer(dams, {}, 'dams') 5 | 6 | // sort features using two columns 7 | function dumpDam(d) { 8 | print(d.get('YEAR')) 9 | print(d.get('CATCH_SKM')) 10 | } 11 | 12 | // 1. sort two times 13 | dams = dams 14 | .sort('YEAR') 15 | .sort('CATCH_SKM') 16 | 17 | dumpDam(ee.Feature(dams.first())) 18 | 19 | // 2. compute sort column and then sort 20 | dams = dams 21 | .map(function(f) { return f.set('sort', ee.Number(f.get('YEAR')).multiply(1000000000).add(f.get('CATCH_SKM'))) }) 22 | .sort('sort') 23 | 24 | dumpDam(ee.Feature(dams.first())) 25 | -------------------------------------------------------------------------------- /by-year/2015/FeatureCollectionWithoutGeom: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var features = /* color: d63000 */ee.FeatureCollection( 3 | [ee.Feature( 4 | ee.Geometry.Polygon( 5 | [[[-136.318359375, 48.554796169223565], 6 | [-128.232421875, 41.61749568924246], 7 | [-129.462890625, 48.204540845239244]]]), 8 | { 9 | "p1": 1, 10 | "system:index": "0" 11 | })]); 12 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 13 | features = features.select([".*"], null, false) 14 | 15 | Export.table(features) 16 | 17 | print(features.getInfo()) -------------------------------------------------------------------------------- /by-year/2015/Forest gain TEOW by area_km2: -------------------------------------------------------------------------------- 1 | // Forest gain TEOW by area_km2 2 | 3 | // Get forest gain pixels just in the TEOW features using Fusion Table 4 | // and filter by area_km2 range 5 | var teow = ee.FeatureCollection('ft:1WFUz9jmLqZswBmo2hQte0AYxaTt6NFtQMOCfUXoF'); 6 | var teowArea = teow.filterMetadata ('area_km2', 'less_than', 1910039); 7 | 8 | Map.addLayer(teowArea); 9 | 10 | // Get the gain image 11 | var gfcImage = ee.Image('UMD/hansen/global_forest_change_2013'); 12 | var gainImage = gfcImage.select(['gain']); 13 | var areaImage = gainImage.multiply(ee.Image.pixelArea()); 14 | 15 | // Map the reducing function over the image collection. 16 | var newTEOW = areaImage.reduceRegions(teowArea, 'sum', 30) 17 | 18 | var filenamePrefix = 'TEOWGain'; 19 | var selectors = "ECO_NAME,ECO_ID,area_km2,AZE_ID,MapID,SiteNameFi,gain"; 20 | 21 | var taskParams = { 22 | 'driveFolder' : '', 23 | 'driveFileNamePrefix': filenamePrefix, 24 | 'fileFormat' : 'CSV', 25 | 'selectors' : selectors 26 | }; 27 | 28 | Export.table(newTEOW, filenamePrefix, taskParams); -------------------------------------------------------------------------------- /by-year/2015/Fusion Table Error: -------------------------------------------------------------------------------- 1 | // Create a feature collection from a Fusion Table. 2 | // 3 | // Select "desert" features from the TNC Ecoregions fusion table. 4 | var fc = ee.FeatureCollection('ft:1R9ciOoVAsr0obvNKae2AM0OFjIyWrKMuBvx79KHe'); 5 | 6 | Map.addLayer(fc); 7 | 8 | print(fc.toList(1,0)) 9 | // Map.addLayer(fc); 10 | -------------------------------------------------------------------------------- /by-year/2015/Fusion Table Example: -------------------------------------------------------------------------------- 1 | centerMap(-74.504235, -10.111272, 8); 2 | // Select the sira reserve outline from fusion table on my G-Drive. 3 | var sira = ee.FeatureCollection('ft:1nHfTKkYH106L5ddnW_Eq8F7NfI71ZGQEcUilCThX'); 4 | 5 | 6 | //create a blank image to paint reserve onto 7 | var siraImg = ee.Image().toByte(); 8 | 9 | // paint the feature image with colour 1 from the palette 10 | var siraFill = siraImg.paint(sira, 1); 11 | 12 | // outline the feature with colour 0 and width 3 13 | var siraComp = siraFill.paint(sira,2, 4); 14 | 15 | // Display the reserve. 16 | addToMap(siraComp,{ 17 | palette: '000000,FF0000,00FF00,0000FF', 18 | max: 3, //max on value mapped in FF. See ee.dataGetMapId to get help on these parameters 19 | opacity: 0.4 20 | }, 21 | 'El Sira Reserve'); -------------------------------------------------------------------------------- /by-year/2015/Grid of bounding boxes: -------------------------------------------------------------------------------- 1 | // Grid of bounding boxes. 2 | var polys = []; 3 | var edge = 0.5 4 | for (var lon = -120; lon < -90; lon += edge) { 5 | var x1 = lon - edge/2; 6 | var x2 = lon + edge/2; 7 | for (var lat = 35; lat < 45; lat += edge) { 8 | var y1 = lat - edge/2; 9 | var y2 = lat + edge/2; 10 | polys.push(ee.Feature.Rectangle(x1, y1, x2, y2)); 11 | } 12 | } 13 | var fc=ee.FeatureCollection(polys); 14 | addToMap(fc, {}, 'gridded boxes'); 15 | centerMap(-106, 40, 5); -------------------------------------------------------------------------------- /by-year/2015/HDR Landsat: -------------------------------------------------------------------------------- 1 | // HDR Landsat. 2 | // 3 | // Display portions of an image with different dynamic ranges. 4 | // The land areas are displayed normally, but the water areas 5 | // are streched to show more details. 6 | 7 | // Filter the L7 collection to a single date. 8 | var collection = ee.ImageCollection('LE7_L1T') 9 | .filterDate(new Date('11/8/2002'), new Date('11/9/2002')); 10 | var image = collection.mosaic().select('B3', 'B2', 'B1'); 11 | 12 | // Display the image normally. 13 | Map.addLayer(image, {gain: '1.6, 1.4, 1.1'}, 'Land'); 14 | 15 | // Add and stretch the water. Once where the elevation is masked, 16 | // and again where the elevation is zero. 17 | var elev = ee.Image('srtm90_v4'); 18 | var mask1 = elev.mask().eq(0).and(image.mask()); 19 | var mask2 = elev.eq(0).and(image.mask()); 20 | Map.addLayer(image.mask(mask1), {gain: '6.0', bias: -200}, 'Water: Masked'); 21 | Map.addLayer(image.mask(mask2), {gain: '6.0', bias: -200}, 'Water: Elev 0'); 22 | 23 | Map.setCenter(-95.738, 18.453, 9); 24 | -------------------------------------------------------------------------------- /by-year/2015/HydroSHEDS: -------------------------------------------------------------------------------- 1 | // create drainage network using flow accumulation grid 2 | var flow_accumulation = ee.Image('WWF/HydroSHEDS/15ACC'); 3 | 4 | var drainage_network_threshold = 500; 5 | var drainage_network = flow_accumulation.subtract(drainage_network_threshold).zeroCrossing(); 6 | 7 | Map.addLayer(drainage_network, {min: 0, max: 1, opacity: 0.5}, 'drainage network (th=500)'); 8 | 9 | exportImage(drainage_network, "drainage network"); 10 | 11 | // WWF/HydroSHEDS/15DIR 12 | 13 | 14 | 15 | //var exact = elev.eq(500); 16 | //Map.addLayer(exact.mask(exact), {min: 0, max: 1, palette: 'FF0000'}, 'Exactly 1000m'); 17 | -------------------------------------------------------------------------------- /by-year/2015/Image.ConnectedPixelCount example: -------------------------------------------------------------------------------- 1 | // Image.ConnectedPixelCount example. 2 | // 3 | // Split pixels of band 01 into "bright" (arbitrarily defined as 4 | // reflectance > 0.3) and "dim". Highlight small (<30 pixels) 5 | // standalone islands of "bright" or "dim" type. 6 | var img = ee.Image('MOD09GA/MOD09GA_005_2012_03_09') 7 | .select('sur_refl_b01') 8 | .multiply(0.0001); 9 | 10 | var bright = img.gt(.3); 11 | // Compute connected pixel counts; stop searching for connected pixels 12 | // once the size of the connected neightborhood reaches 30 pixels, and 13 | // use 8-connected rules. 14 | var conn = bright.connectedPixelCount(100 /* maxSize */, 15 | true /* eightConnected */); 16 | var smallClusters = conn.lt(100); 17 | 18 | centerMap(-107.24304, 35.78663, 8); 19 | addToMap(img, {min: 0, max: 1}, 'original'); 20 | addToMap(smallClusters.mask(smallClusters), 21 | {min: 0, max: 1, palette: 'FF0000'}, 'cc'); 22 | -------------------------------------------------------------------------------- /by-year/2015/IterativeAlgorithm.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Algorithm to run iteratively. 3 | */ 4 | var algorithm = function(iteration, image) { 5 | return ee.Image(image).convolve(ee.Kernel.gaussian(30, 15, 'meters')) 6 | } 7 | 8 | /*** 9 | * Runs an algorithm function iteratively using a given image as a start. 10 | */ 11 | var iterate = function(algorithm, count, image) { 12 | return ee.List.sequence(0, count - 1).iterate(algorithm, image) 13 | } 14 | 15 | Map.setCenter(-95.55, 35.79, 13) // US, Arkansas River 16 | 17 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 18 | 19 | var image = ee.Image(l8.filterBounds(Map.getCenter()).first()) 20 | .select(['B6', 'B5', 'B3']) 21 | 22 | // Add retults of iterative run to map 23 | var count = 10; // number of iterations 24 | Map.addLayer(ee.Image(iterate(algorithm, count, image)), {min: 0.03, max:0.5}, 'image') 25 | -------------------------------------------------------------------------------- /by-year/2015/L7, LEDAPS,average: -------------------------------------------------------------------------------- 1 | var c1 = ee.ImageCollection("LEDAPS/LE7_L1T_SR") 2 | .filterDate("2008-01-01", "2008-02-01") 3 | .filterBounds(Map.getBounds(true)); 4 | 5 | var c2 = c1.select(['B7', 'B4', 'B2']); 6 | Map.addLayer(c2.median(), {'gain':[0.05]}, 'median'); 7 | //Map.addLayer(c2.reduce(ee.Reducer.intervalMean(10, 30)), {'gain':[0.05]}, '10_30'); 8 | //Map.addLayer(c2.reduce(ee.Reducer.intervalMean(70, 80)), {'gain':[0.05]}, '70_80'); 9 | 10 | var c3 = c1.select(['QA']); 11 | Map.addLayer(c3.median(), {'gain':[0.05]}, 'QA'); 12 | 13 | -------------------------------------------------------------------------------- /by-year/2015/L8, DN, reflectance: -------------------------------------------------------------------------------- 1 | // L8, DN, reflectance 2 | 3 | // print(ee.Geometry(Map.getBounds(true)).centroid(1e-3)) 4 | Map.setCenter(147.01, -36.10) 5 | 6 | var c1 = ee.ImageCollection('LANDSAT/LC8').filterBounds(Map.getBounds(true)).select(['B7', 'B5', 'B3']).sort('system:index'); 7 | var c2 = ee.ImageCollection('LANDSAT/LC8_L1T_TOA').filterBounds(Map.getBounds(true)).select(['B7', 'B5', 'B3']).sort('system:index'); 8 | 9 | var offset = 2 10 | 11 | var i1 = ee.Image(c1.toList(1,offset).get(0)); 12 | var i2 = ee.Image(c2.toList(1,offset).get(0)); 13 | 14 | print(i1.getInfo()) 15 | print(i2.getInfo()) 16 | 17 | print(c1.getInfo().features.length) 18 | print(c2.getInfo().features.length) 19 | 20 | Map.addLayer(i1, {min: 0.0 * 65535, max: 0.6 * 65535 }, 'DN') 21 | Map.addLayer(i2, {min: 0.0, max: 0.6 }, 'TOA') 22 | -------------------------------------------------------------------------------- /by-year/2015/L8, cloudfree, MNDWI: -------------------------------------------------------------------------------- 1 | // L8, cloudfree, MNDWI 2 | 3 | Map.setCenter(106.6, 12.75, 8) 4 | 5 | var bands = ['B7', 'B5', 'B3', 'B6']; 6 | 7 | var images = ee.ImageCollection('LC8_L1T_TOA') 8 | //.filterDate('2013-01-01', '2015-01-01') 9 | .filterBounds(Map.getBounds(true)) 10 | .select(bands); 11 | 12 | Map.addLayer(images.select('B3', 'B6'), {gamma : 1.3}, 'images', false); 13 | 14 | var mean = images.reduce(ee.Reducer.intervalMean(10, 20)).select(['B7_mean', 'B5_mean', 'B3_mean', 'B6_mean'], bands); 15 | Map.addLayer(mean, {gamma : 1.3}, 'mean(25%, 35%)'); 16 | 17 | var mndwi = mean.normalizedDifference(['B6','B3']); 18 | Map.addLayer(mndwi, {gamma : 1.3}, 'MNDWI', false); 19 | 20 | var water = mndwi.gte(0.0); 21 | Map.addLayer(mndwi.mask(water.not()), {palette:'4FD5EE', opacity:0.6}, 'MNDWI <= 0.0'); 22 | -------------------------------------------------------------------------------- /by-year/2015/LatestL8: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T"), 3 | l8toa = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 4 | l7 = ee.ImageCollection("LANDSAT/LE7_L1T"); 5 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 6 | l8 = l8 7 | .filterBounds(Map.getBounds(true)) 8 | .filterDate('2015-09-1', '2016-01-01') 9 | .select(['B6', 'B5', 'B3']) 10 | 11 | l7 = l7 12 | .filterBounds(Map.getBounds(true)) 13 | .filterDate('2015-09-1', '2016-01-01') 14 | .select(['B5', 'B4', 'B2']) 15 | 16 | var images = ee.ImageCollection(l8.merge(l7)) 17 | .sort('DATE_ACQUIRED') 18 | 19 | var count = images.aggregate_count('system:index').getInfo() 20 | 21 | images = ee.List(images.toList(count, 0)) 22 | 23 | for(var i = 0; i < count; i++) { 24 | var image = ee.Image(images.get(i)); 25 | Map.addLayer(image, {min:1000, max:30000}, image.get('system:id').getInfo() + image.get('DATE_ACQUIRED').getInfo()) 26 | } 27 | 28 | -------------------------------------------------------------------------------- /by-year/2015/MODIS NDVI download: -------------------------------------------------------------------------------- 1 | // MODIS NDVI download 2 | // 3 | var MODIS = ee.Image('MOD09GQ/MOD09GQ_005_2001_05_24').select(['sur_refl_b01','sur_refl_b02','QC_250m']); 4 | var MODIS_NDVI = MODIS.normalizedDifference(['sur_refl_b02', 'sur_refl_b01']); 5 | var palette = ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', 6 | '74A901', '66A000', '529400', '3E8601', '207401', '056201', 7 | '004C00', '023B01', '012E01', '011D01', '011301']; 8 | 9 | Map.addLayer(MODIS,{'bands': ['sur_refl_b02', 'sur_refl_b02', 'sur_refl_b01'],'min': 0, 'max': 10000},'MODIS_250m'); 10 | //Map.addLayer(MODIS_NDVI,{'bands': ['sur_refl_b02', 'sur_refl_b02', 'sur_refl_b01'],'min': 0, 'max': 10000},'MODIS_250m'); 11 | addToMap(MODIS_NDVI, {min: 0, max: 1, palette: palette}, 'NDVI'); 12 | 13 | 14 | var path = MODIS_NDVI.getDownloadURL({ 15 | 'name': 'MOD09GQ_005_2001_05_24_NDVI', 16 | 'scale': 250, 17 | 'crs': 'EPSG:32649', 18 | 'region': '[[110.1955, 35.8738], [112.0275, 35.8738],[112.0275, 34.5129], [110.1955, 34.5129]]', 19 | }); 20 | 21 | print(path) 22 | 23 | -------------------------------------------------------------------------------- /by-year/2015/MODIS QC Tests for BitwiseAnd: -------------------------------------------------------------------------------- 1 | // MODIS QC Tests for BitwiseAnd. 2 | // 3 | // Extracts quality bits from MOD09GQ QC band, and masks pixels 4 | // where the quality value is not "ideal". 5 | // Lowest two bits contain quality value: 6 | // 00: "produced at ideal quality all bands" 7 | // 01: "produced at less than ideal quality some or all bands" 8 | // 10: "not produced due to cloud effects all bands" 9 | // 11: "not produced due to other reasons" 10 | 11 | var modis = ee.Image('MOD09GQ/MOD09GQ_005_2012_02_08'); 12 | 13 | var qual = modis.select('QC_250m').bitwiseAnd(0x03).neq(0); 14 | 15 | centerMap(-90.79994, 44.21912, 11); 16 | 17 | addToMap(modis.select('QC_250m'),{},'QC_250m'); 18 | addToMap(modis.select('sur_refl_b01'), 19 | {min: 100, max: 16000}, 'refl_b01'); 20 | addToMap(ee.Image([1, 0, 0]).mask(qual), {min: 0, max: 1}, 21 | 'quality_not_ideal'); 22 | 23 | -------------------------------------------------------------------------------- /by-year/2015/MODIS mask clouds and shadows: -------------------------------------------------------------------------------- 1 | // MODIS mask clouds and shadows 2 | 3 | var getQABits = function(image, start, end, newName){var pattern = 0; 4 | for (var i = start; i <= end; i++){ 5 | pattern += Math.pow(2, i)} 6 | return image.select([0], [newName]).bitwiseAnd(pattern).rightShift(start)}; 7 | 8 | var quality_mask = function(image) { 9 | var BQA = image.select('StateQA'); 10 | var internal_cloud = getQABits(BQA, 10, 10, 'internal_cloud'); 11 | var cloud_shadow = getQABits(BQA, 2, 2, 'cloud_shadow'); 12 | 13 | return internal_cloud.addBands(ee.Image(1).select([0], ['count'])); 14 | /* 15 | return collection.mask(internal_cloud.neq(1)) 16 | .mask(cloud_shadow.neq(1)) 17 | */}; 18 | 19 | var my_collection = ee.ImageCollection('MODIS/MOD09A1') 20 | .filterDate('2012-01-01', '2016-01-01') 21 | .map(quality_mask); 22 | 23 | print (my_collection); 24 | 25 | Map.addLayer(my_collection.sum().select(0), {min:0, max:154}) -------------------------------------------------------------------------------- /by-year/2015/MODIS_visual.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var etopo = ee.Image("NOAA/NGDC/ETOPO1"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // Start with an image collection for a 1 month period. 5 | var collection = ee.ImageCollection(ee.ImageCollection('MOD09GA').merge(ee.ImageCollection('MYD09GA'))) 6 | .filterDate('2010-06-01', '2010-09-01') 7 | .select(['sur_refl_b06', 'sur_refl_b05', 'sur_refl_b03']); 8 | 9 | Map.addLayer( 10 | collection.reduce(ee.Reducer.percentile([15])).mask(etopo.select('bedrock').gt(-100)) 11 | , 12 | { 13 | gain: 0.05, 14 | gamma: 0.9 15 | }, 16 | 'median of masked collection' 17 | ); 18 | -------------------------------------------------------------------------------- /by-year/2015/MeanElevationPerCountry: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var dem = ee.Image("NOAA/NGDC/ETOPO1"), 3 | countries = ee.FeatureCollection("ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw"); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | dem = dem.select('ice_surface') 6 | 7 | var meanElevationPerCountry = dem.reduceRegions({ 8 | collection: countries, 9 | reducer: ee.Reducer.mean(), 10 | scale: 100000, // 100km 11 | }); 12 | 13 | var palette = ['006837', '1a9850', '66bd63', 'a6d96a', 'd9ef8b', 'ffffbf', 'fee08b', 'fdae61', 'f46d43', 'd73027', 'a50026', 'ffffff'] 14 | 15 | Map.addLayer(dem.mask(dem.gt(-20)), {min:0, max:1000, palette: palette}, 'dem') 16 | 17 | print(meanElevationPerCountry.first()) 18 | 19 | var img = ee.Image(0).float().paint(meanElevationPerCountry, 'mean'); 20 | Map.addLayer(img.mask(dem.gt(-20)), {min:0, max:1000, palette: palette}, 'dem per country') -------------------------------------------------------------------------------- /by-year/2015/NLCD.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var nlcd = ee.ImageCollection("USGS/NLCD"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var colorsRainbow = [ 5 | 'F26C4F', // Light Red 6 | 'F68E55', // Light Red Orange 7 | 'FBAF5C', // Light Yellow Orange 8 | 'FFF467', // Light Yellow 9 | 'ACD372', // Light Pea Green 10 | '7CC576', // Light Yellow Green 11 | '3BB878', // Light Green 12 | '1ABBB4', // Light Green Cyan 13 | '00BFF3', // Light Cyan 14 | '438CCA', // Light Cyan Blue 15 | '5574B9', // Light Blue 16 | '605CA8', // Light Blue Violet 17 | '855FA8', // Light Violet 18 | 'A763A8', // Light Violet Magenta 19 | 'F06EA9', // Light Magenta 20 | 'F26D7D' // Light Magenta Red 21 | ]; 22 | Map.addLayer(nlcd.select('landcover'), {palette:colorsRainbow}, 'NLCD') -------------------------------------------------------------------------------- /by-year/2015/PercentileFormulae.js: -------------------------------------------------------------------------------- 1 | var values = ee.List([3,5.5,7,8,9,11,13,15]) 2 | 3 | var images = values.map(function (v) { 4 | return ee.Image(ee.Number(v)).toFloat().rename(['value']); 5 | }) 6 | var ic = ee.ImageCollection.fromImages(images); 7 | 8 | print(Chart.array.values(values, 0, [1,2,3,4,5,6,7,8])) 9 | 10 | /** 11 | * http://onlinestatbook.com/2/introduction/percentiles.html 12 | * 13 | * 25% is expected to be 5.5 14 | * 15 | * R(P) = P/100 x (N + 1) 16 | * 17 | * values: [ 3, 5, 7, 8, 9,11,13,15] 18 | * ranks: [ 1, 2, 3, 4, 5, 6, 7, 8] 19 | * 20 | * R(25) = 25/100 x (8 + 1) = 9/4 = 2.25 21 | * 22 | * P = (0.25)(7 - 5) + 5 = 5.5 23 | */ 24 | 25 | var p25 = ic.reduce(ee.Reducer.percentile({percentiles:[25], maxRaw:5})); 26 | Map.addLayer(p25) 27 | 28 | var sample = ee.Feature(p25.sample(ee.Geometry.Point(0,0), 30).first()) 29 | print(sample.get('value_p25')) 30 | -------------------------------------------------------------------------------- /by-year/2015/Percentiles.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // Percentiles.js 5 | 6 | var percentiles = [10, 20, 30, 40, 50] 7 | 8 | Map.setCenter(-123.94, 39.91, 14) 9 | var bounds = Map.getBounds(true); 10 | print(ee.Geometry(bounds).centroid(100)) 11 | 12 | var p = l8.filterDate('2014-01-01', '2015-01-01').filterBounds(bounds).reduce(ee.Reducer.percentile(percentiles)).clip(bounds) 13 | 14 | for(var i = 0; i < percentiles.length; i++) { 15 | var v = percentiles[i]; 16 | Map.addLayer(p.select('B6_p' + v, 'B5_p' + v, 'B3_p' + v), {min: 0.05, max: 0.5}, v.toString()) 17 | } 18 | -------------------------------------------------------------------------------- /by-year/2015/ReprojectionsAndConvolution.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var g = /* color: d63000 */ee.Geometry.Polygon( 3 | [[[-105.1171875, 40.38002840251183], 4 | [-109.072265625, 45.27488643704894], 5 | [-113.90625, 43.70759350405294], 6 | [-111.09375, 40.979898069620155]]]); 7 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 8 | var step = 50000 9 | var distance = 500000 10 | var crs = ee.Projection('EPSG:3857'); // Web Mercator 11 | var crs_transform = [step,0,0,0,step,0] 12 | 13 | var image = ee.Image(1).byte().paint(g, 0) 14 | 15 | var d = image.distance(ee.Kernel.euclidean(500000, "meters")).reproject(crs, crs_transform).clip(g); 16 | 17 | Map.centerObject(g, 6) 18 | Map.addLayer(d, {min:0, max:distance}) 19 | 20 | var s = d.convolve(ee.Kernel.sobel()).reproject(crs, crs_transform).clip(g) 21 | Map.addLayer(s, {}, 'sobel') 22 | -------------------------------------------------------------------------------- /by-year/2015/S2.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var s2 = ee.ImageCollection("COPERNICUS/S2"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | Map.addLayer(s2.select(10).count(), {min:0, max:20, palette:['ff0000', '00ff00']}, 'count'); 5 | 6 | var image = s2 7 | .select(['B4', 'B3', 'B2']) 8 | .reduce(ee.Reducer.percentile([15])); 9 | 10 | Map.addLayer(image, {min:500, max:[2500, 2500, 3500]}, 's2') -------------------------------------------------------------------------------- /by-year/2015/SRTM_exact_test: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | Map.addLayer(srtm, {min:0, max:50}) 5 | 6 | var info = srtm.getInfo() 7 | var crs = info.bands[0].crs 8 | var crs_transform = info.bands[0].crs_transform 9 | //crs_transform = [crs_transform[0], crs_transform[1], 0.0, crs_transform[3], crs_transform[4], 0.0]; 10 | 11 | var bounds = ee.Geometry(Map.getBounds(true)).bounds(1e-2).coordinates().getInfo()[0]; 12 | print(bounds) 13 | 14 | var url = srtm.getDownloadURL({ 15 | name: 'srtm_test', 16 | crs: crs, 17 | crs_transform: JSON.stringify(crs_transform), 18 | region: JSON.stringify(bounds), 19 | }); 20 | 21 | print(url) -------------------------------------------------------------------------------- /by-year/2015/Sentinel1.js: -------------------------------------------------------------------------------- 1 | var csent = ee.ImageCollection("COPERNICUS/S1").filterDate('2015-01-01', '2015-07-02'); 2 | 3 | var EWHH = csent.filter(ee.Filter.eq('instrumentMode','EW')) 4 | .filter(ee.Filter.eq('transmitterReceiverPolarisation','HH')); 5 | 6 | var IWHH = csent.filter(ee.Filter.eq('instrumentMode','IW')) 7 | .filter(ee.Filter.eq('transmitterReceiverPolarisation','HH')); 8 | 9 | 10 | //print(csent); 11 | //print(filtered) 12 | 13 | Map.addLayer(EWHH,{bands: ['HH']}, 'EWHH' ); 14 | Map.addLayer(IWHH, {bands: ['HH']},'IWHH' ); 15 | 16 | Map.centerObject(csent) -------------------------------------------------------------------------------- /by-year/2015/SkyBox GCP: -------------------------------------------------------------------------------- 1 | var skybox = ee.Image('GME/images/00979750194450688595-04594044960761723980'); 2 | Map.addLayer(skybox, {'opacity':0.5}); 3 | 4 | Map.centerObject(skybox, 17); 5 | 6 | Map.setStyle('SATELLITE'); // <--- THIS DOES NOT WORK -------------------------------------------------------------------------------- /by-year/2015/SkyBox.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('GME/images/00979750194450688595-15376670774087721723') 2 | Map.addLayer(image) 3 | Map.addLayer(image.select('b4'), {opacity: 0.5}) 4 | Map.centerObject(image) -------------------------------------------------------------------------------- /by-year/2015/TEST_geometries_and_features.js: -------------------------------------------------------------------------------- 1 | var coords = [[0,0], [1,1]] 2 | 3 | var geoms = ee.List(coords).map(function(o) { 4 | return ee.Geometry.Point(o) // OK, Geometry is constructed and returned? 5 | }) 6 | 7 | var features1 = ee.List(geoms).map(function(g) { 8 | return ee.Feature(g) // ERROR, returns ee.Geometry instead of ee.Feature 9 | }); 10 | print('step1', features1.get(0)) 11 | 12 | var features2 = ee.List(geoms).map(function(g) { 13 | return ee.Algorithms.Feature(g) // OK, ee.Feature is returned 14 | }); 15 | print('step2', features2.get(0)) 16 | 17 | var features3 = geoms.map(function(f) { 18 | return ee.Feature(f).geometry(); // OK, Feature is constructed and its geometry is returned 19 | }) 20 | print('step3', features3.get(0)) 21 | 22 | var features4 = ee.FeatureCollection(geoms).map(function(f) { 23 | return ee.Feature(f).geometry(); // FAILS, geometry is supposed to just get a read-only geometry? 24 | }) 25 | print('step4', features4.get(0)) 26 | 27 | -------------------------------------------------------------------------------- /by-year/2015/TRMM, NCEP: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var ncep = ee.ImageCollection("NOAA/CFSV2/FOR6H"), 3 | trmm = ee.ImageCollection("TRMM/3B42"); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | // TRMM, NCEP 6 | 7 | var palette = ['f7fbff', 'deebf7', 'c6dbef', '9ecae1', '6baed6', '4292c6', '2171b5', '08519c', '08306b']; 8 | 9 | // NCEP 10 | var c = ncep 11 | .filterDate("2014-01-01", "2014-10-01") 12 | .select(['Precipitation_rate_surface_6_Hour_Average']); 13 | Map.addLayer(c.sum(), {min:0, max:0.03, palette: palette}, 'P, NCEP, sum()'); 14 | Map.addLayer(c, {}, 'P, NCEP', false) 15 | 16 | // TRMM 17 | var c = trmm 18 | .filterDate("2014-01-01", "2014-10-01") 19 | .select(['precipitation']); 20 | Map.addLayer(c.sum(), {min:0, max:250, palette: palette}, 'P, TRMM, sum()'); 21 | Map.addLayer(c, {}, 'P, TRMM', false) 22 | 23 | -------------------------------------------------------------------------------- /by-year/2015/TRMM, export: -------------------------------------------------------------------------------- 1 | // TRMM, export 2 | 3 | var precip = ee.ImageCollection('TRMM/3B42').select('precipitation'); 4 | var test = ee.Image(precip.first()); 5 | var border = ee.FeatureCollection('ft:1rWmQrWDf2EIwkNWjlu_9LcdegqIH65fnT_lrYhJN'); 6 | //test = test.clip(border); 7 | 8 | print(test.getInfo()); 9 | /* 10 | var path = test.getDownloadURL({'name' : 'TestImage2', 11 | //'region' : '[[-66.809703, -19.480177000000026], [-45.694159, -19.480177000000026], [-45.694159, -5.167584999999974], [-66.809703, -5.167584999999974], [-66.809703, -19.480177000000026]]', 12 | //'scale' : 27000 13 | 'crs' : 'EPSG:4326', 14 | 'crs_transform' : JSON.stringify([0.25,0,-180,0,-0.25,50]), 15 | 'dimensions' : JSON.stringify([1440,400]) 16 | }); 17 | print(path); 18 | */ 19 | 20 | addToMap(test); 21 | centerMap(-51.35010, -14.65724, 4); 22 | 23 | exportImage( 24 | test, 25 | "My_Task", 26 | { 27 | 'crs' : 'EPSG:4326', 28 | 'crs_transform' : JSON.stringify([0.25,0,-180,0,-0.25,50]), 29 | 'dimensions' : JSON.stringify([1440,400]) 30 | } 31 | ); 32 | -------------------------------------------------------------------------------- /by-year/2015/TimeSeries, LANDSAT: -------------------------------------------------------------------------------- 1 | // TimeSeries, LANDSAT 2 | // Plot Landsat 8 band value means in a section of San Francisco. 3 | 4 | var bounds = Map.getBounds(); 5 | print(bounds) 6 | var center = ee.Geometry.Rectangle( 7 | bounds[0] + 0.48 * (bounds[2] - bounds[0]), 8 | bounds[1] + 0.48 * (bounds[3] - bounds[1]), 9 | bounds[0] + 0.52 * (bounds[2] - bounds[0]), 10 | bounds[1] + 0.52 * (bounds[3] - bounds[1])); 11 | addToMap(center); 12 | 13 | var landsat8Toa = ee.ImageCollection('LC8_L1T_TOA') 14 | //.filterDate('2012-12-25', '2013-12-25') 15 | .select('B[1-7]'); 16 | 17 | var sfTimeSeries = Chart.image.series(landsat8Toa, center, ee.Reducer.median(), 200); 18 | 19 | print(sfTimeSeries); 20 | 21 | -------------------------------------------------------------------------------- /by-year/2015/Vector to raster conversion: -------------------------------------------------------------------------------- 1 | // Vector to raster conversion 2 | 3 | Map.setCenter(31.8878, -26.3965, 11); 4 | 5 | var test = ee.FeatureCollection('ft:1wWOHbvBTCAPJsVpe0eyVtzQnVy6auy4Xkh5V_-8I'); 6 | Map.addLayer(test, null, 'Feature Collection',false); 7 | print(test); 8 | 9 | var buffer = test.map(function(f) { return f.buffer(200); }); 10 | 11 | var testRaster = buffer.reduceToImage(['ID'], ee.Reducer.mean()); 12 | Map.addLayer(testRaster, {min:1, max:10, palette:['000000','cc3300']}, 'Points as Raster'); 13 | -------------------------------------------------------------------------------- /by-year/2015/array struggles: -------------------------------------------------------------------------------- 1 | // array struggles 2 | 3 | var image = new ee.Image(new ee.ImageCollection("LANDSAT/LC8_L1T") 4 | .select(['B7', 'B6', 'B3']) 5 | .first()); 6 | 7 | Map.centerObject(image, 14); 8 | Map.addLayer(image); 9 | 10 | var g = image.geometry(); 11 | 12 | var max = image.reduceRegion('max', g, 120).values(); 13 | var min = image.reduceRegion('min', g, 120).values(); 14 | 15 | min = min.get(0); print(min); 16 | max = max.get(0); print(max); 17 | 18 | Map.addLayer(image, {'min':min, 'max':max}); 19 | 20 | 21 | -------------------------------------------------------------------------------- /by-year/2015/arrays.js: -------------------------------------------------------------------------------- 1 | var a = ee.Array([1,3,4]) 2 | 3 | var last = a.get([-1]) 4 | 5 | print(last) 6 | 7 | var a3 = Array(3) 8 | for(var i=0; i<3; i++) { 9 | a3[i] = i 10 | } 11 | print(ee.Array(a3)) 12 | 13 | var a1 = ee.Array([1,2,3]) 14 | var a2 = ee.Array([2,2,2]) 15 | 16 | print(a1.multiply(a2)) -------------------------------------------------------------------------------- /by-year/2015/chart custom3 (histogram): -------------------------------------------------------------------------------- 1 | // chart custom3 (histogram) 2 | 3 | // A simple example demonstrating manual construction of a chart. 4 | 5 | // DataTables can be Google Visualization API DataTable literals or simple 2-D 6 | // arrays: 7 | // https://developers.google.com/chart/interactive/docs/reference#DataTable 8 | var dataTable = { 9 | cols: [{id: 'name', label: 'Airport Code', type: 'string'}, 10 | {id: 'year', label: 'Elevation (m)', type: 'number'}], 11 | rows: [{c: [{v: 'SFO'}, {v: 4}]}, 12 | {c: [{v: 'JFK'}, {v: 4}]}, 13 | {c: [{v: 'DEN'}, {v: 1655}]}, 14 | {c: [{v: 'LHR'}, {v: 25}]}, 15 | {c: [{v: 'ZRH'}, {v: 432}]}] 16 | }; 17 | 18 | var options = { 19 | title: 'Airport elevation histogram', 20 | vAxis: {title: 'Number of airports'}, 21 | legend: {position: 'none'}, 22 | hAxis: { 23 | title: 'Elevation (m)', 24 | logScale: true 25 | } 26 | }; 27 | 28 | print(Chart(dataTable, 'Histogram', options)); -------------------------------------------------------------------------------- /by-year/2015/compute minimum cloud cover: -------------------------------------------------------------------------------- 1 | // compute minimum cloud cover 2 | 3 | var images = ee.ImageCollection('LANDSAT/LE7_L1T') 4 | .filterDate('2000-01-01','2001-01-02') 5 | .map(function(img) { 6 | var cloudCover = ee.Image(img.getInfo().properties['CLOUD_COVER']) 7 | .select([0], ['cloud_cover']) 8 | 9 | return img.addBands(cloudCover); 10 | }); 11 | 12 | addToMap(collection.reduce('min')); 13 | -------------------------------------------------------------------------------- /by-year/2015/convert polygon to points: -------------------------------------------------------------------------------- 1 | // convert polygon to points 2 | 3 | var fc = ee.FeatureCollection([ 4 | ee.Geometry.Polygon(-72.93411, 41.30902, -72.93411, 41.31902, -72.94411, 41.31902) 5 | ]); 6 | 7 | var coords = ee.Feature(fc.first()).geometry().coordinates().get(0); 8 | 9 | print(ee.Geometry.MultiPoint(coords.getInfo())) // works 10 | 11 | print(ee.Geometry.MultiPoint(coords)) // fails, but needed for the function below (to be used in map() 12 | 13 | var toPoints = function(f) { 14 | var coords = ee.Feature(f).geometry().coordinates().get(0); 15 | return ee.MultiPoint(coords); 16 | } 17 | 18 | Map.setCenter(-72.94, 41.32, 13); 19 | Map.addLayer(fc); 20 | Map.addLayer(fc.map(toPoints)); 21 | -------------------------------------------------------------------------------- /by-year/2015/count scenes: -------------------------------------------------------------------------------- 1 | // count scenes 2 | 3 | // var poly = ee.Geometry.Rectangle(120.49, 30.62,122.40, 31.92); 4 | var collection = ee.ImageCollection('LANDSAT/LT5_L1T') 5 | .filterDate('2000-01-01','2001-01-02') 6 | .select(0); 7 | 8 | addToMap(collection.reduce('count').log(), {min:0, max:5}); -------------------------------------------------------------------------------- /by-year/2015/default geometry length: -------------------------------------------------------------------------------- 1 | // default geometry length 2 | 3 | var g = [ 4 | ee.Geometry.LineString([[-180, 30], [-50, 30]]), 5 | ee.Geometry.LineString([[-180, 0], [-50, 0]]) 6 | ]; 7 | 8 | var fc = ee.FeatureCollection(g); 9 | 10 | // print default length 11 | print('default: ' + g[0].length(1e-3).getInfo()) 12 | print('default: ' + g[1].length(1e-3).getInfo()) 13 | 14 | // print length in WGS84 15 | var wgs84 = ee.Projection('EPSG:4326') 16 | print('WGS84: ' + g[0].length(1e-3, wgs84).getInfo()) 17 | print('WGS84: ' + g[1].length(1e-3, wgs84).getInfo()) 18 | 19 | // print length in Pseudo-Mercator 20 | var pseudoMercator = ee.Projection('EPSG:3857') 21 | print('Pseudo-Mercator: ' + g[0].length(1e-3, pseudoMercator).getInfo()) 22 | print('Pseudo-Mercator: ' + g[1].length(1e-3, pseudoMercator).getInfo()) 23 | 24 | 25 | Map.addLayer(fc) 26 | 27 | Map.centerObject(fc) 28 | -------------------------------------------------------------------------------- /by-year/2015/download image using map bounds: -------------------------------------------------------------------------------- 1 | // download image using map bounds 2 | 3 | // grab some image 4 | Map.setCenter(10, 10, 10); 5 | 6 | // ... why do we have to wrap .first() once again? Can't it just ee.Image()? 7 | var image = ee.Image(ee.ImageCollection('LANDSAT/LC8_L1T') 8 | .filterBounds(Map.getBounds(true)) 9 | .filterMetadata('CLOUD_COVER', 'less_than', 20).first()); 10 | 11 | // get bounds as a geometry 12 | var bounds = JSON.stringify(Map.getBounds(true)); 13 | 14 | print(bounds) 15 | 16 | print(image.visualize().getDownloadURL( 17 | { 18 | name: 'L8', 19 | format: 'png', 20 | scale: 30, 21 | region: bounds 22 | } 23 | )); 24 | 25 | 26 | // export to Google Drive 27 | -------------------------------------------------------------------------------- /by-year/2015/fint_image_by_path_row: -------------------------------------------------------------------------------- 1 | // find image by path/row/date 2 | 3 | print(ee.ImageCollection("LE7_L1T") 4 | .filter(ee.Filter.eq("WRS_PATH", 42)) 5 | .filter(ee.Filter.eq("WRS_ROW", 34)) 6 | .filterDate('2006-01-01', '2006-12-31')) -------------------------------------------------------------------------------- /by-year/2015/flood risk map: -------------------------------------------------------------------------------- 1 | // flood risk map 2 | 3 | // bringing in polygon of Flood risk zone from Google Crisis Maps (which is from NOAA) for 4 | // we downloaded the kml, uploading to a fusion table, and using the fusion table idea to make a feature 5 | var fc = ee.FeatureCollection('ft:1QJ-gk626RaMYPIDbk_l974oevNcfspNDmu7uq9g'); 6 | 7 | //elevation- this one is National Elevation Data Set, with a 10 meter resolution 8 | var ned = ee.Image("ned_13"); 9 | //elevation cliped to flood risk polygon 10 | var clipped= ned.clip(fc.geometry(1)); 11 | // elevation recolored to highlight low elevation 12 | var reclass = clipped.where( 13 | ned.gt(0).and(ned.lt(100)), 14 | 1); 15 | var paletteDEM= ["ff0000","FF3300", "ffff00", "00ff00", "66ffff" ]; 16 | addToMap(clipped, {min:20, max:400, palette:paletteDEM}, "elevation"); 17 | //var max = clipped.reduceRegion(ee.call("Reducer.max"),fc, null, null, null, true); 18 | 19 | var max = clipped.reduceRegion({ 20 | reducer: ee.Reducer.max(), 21 | //crs: 'EPSG:4326', 22 | bestEffort: true}); 23 | var value = max.getInfo(); 24 | print(value.elevation); -------------------------------------------------------------------------------- /by-year/2015/getDownloadURL_original_scale.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm30 = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // getDownloadURL_original_scale.js 5 | 6 | var bounds = ee.Geometry(Map.getBounds(true)) 7 | // print(bounds.centroid(1)) 8 | Map.setCenter(-78.22, 33.92, 14) 9 | 10 | Map.addLayer(srtm30, {min:0, max:20}, 'srtm 30m') 11 | 12 | var info = srtm30.getInfo().bands[0] 13 | var crs = info.crs; 14 | var crs_transform = info.crs_transform 15 | crs_transform = [crs_transform[0], crs_transform[1], 0.0, crs_transform[3], crs_transform[4], 0.0]; 16 | 17 | print(crs_transform) 18 | 19 | var url = srtm30.clip(bounds).getDownloadURL({ 20 | name: 'srtm30', 21 | crs: crs, 22 | crs_transform: JSON.stringify(crs_transform), 23 | region: JSON.stringify(bounds.coordinates().getInfo()[0]) 24 | }) 25 | 26 | print(url) -------------------------------------------------------------------------------- /by-year/2015/getTileUrl: -------------------------------------------------------------------------------- 1 | // getTileUrl 2 | 3 | var srtm = ee.Image('USGS/SRTMGL1_003') 4 | .visualize({min:0, max:1000}); 5 | 6 | 7 | Map.addLayer(srtm); 8 | 9 | // I guess getMap().mapId is just an id of a given image to be used for map (tiledImageId?) 10 | var id = srtm.getMap(); 11 | 12 | // how to get these parameters? tile schema for images 13 | var x = 165; 14 | var y = 400; 15 | var z = 10; 16 | 17 | print(ee.data.getTileUrl(id, x, y, z)) 18 | -------------------------------------------------------------------------------- /by-year/2015/histogram reducer: -------------------------------------------------------------------------------- 1 | // histogram reducer 2 | 3 | var image = new ee.Image(new ee.ImageCollection("LANDSAT/LC8_L1T") 4 | .select(['B7', 'B6', 'B3']) 5 | .first()); 6 | 7 | //Map.centerObject(image, 14); 8 | Map.addLayer(image); 9 | 10 | var g = Map.getBounds(true); 11 | 12 | var max = image.reduceRegion('max', g, 120).values(); 13 | var min = image.reduceRegion('min', g, 120).values(); 14 | 15 | min = min.get(0); print(min); 16 | max = max.get(0); print(max); 17 | 18 | Map.addLayer(image, {'min':min.getInfo(), 'max':max.getInfo()}); // error 19 | 20 | 21 | -------------------------------------------------------------------------------- /by-year/2015/kernels: -------------------------------------------------------------------------------- 1 | // kernels 2 | 3 | // Euclidean 4 | var d = ee.Kernel.euclidean(9); 5 | print(d.getInfo()) // no weights can be inspected 6 | 7 | // Custom 8 | var w = [[1, 1, 1], 9 | [0, 0, 0], 10 | [0, 0, 0]]; 11 | 12 | var k2 = ee.Kernel.fixed(3, 3, w); 13 | print(k2.getInfo().weights) 14 | 15 | print(k2.rotate(1)) // no weights can be inspected 16 | -------------------------------------------------------------------------------- /by-year/2015/last_array_element.js: -------------------------------------------------------------------------------- 1 | var a = ee.Array([1,3,4]) 2 | 3 | var index = a.length().get([0]).subtract(1) 4 | 5 | var last = a.get([index]) 6 | 7 | print(last) 8 | -------------------------------------------------------------------------------- /by-year/2015/mask LANDSAT using BQA: -------------------------------------------------------------------------------- 1 | // mask LANDSAT using BQA 2 | 3 | var collection = ee.ImageCollection('LANDSAT/LC8_L1T_TOA') 4 | .filterDate('2015-01-01', '2015-01-02') 5 | .filterBounds(Map.getBounds(true)) 6 | .select(['B4','B3','B2','BQA']); 7 | 8 | var maskBadPixels = function(img) { 9 | var bad = img.select('BQA').eq([61440,59424,57344,56320,53248,52256,52224,49184,49152]).reduce('max'); 10 | return img.mask(bad.not()); 11 | }; 12 | var collection = collection.map(maskBadPixels); 13 | 14 | Map.addLayer(collection.select(['B4','B3','B2']), 'rgb'); -------------------------------------------------------------------------------- /by-year/2015/misaligned: -------------------------------------------------------------------------------- 1 | var i1 = ee.Image("LT51970241984299XXX02"); 2 | var i2 = ee.Image("LT51980241984306XXX09"); 3 | var i3 = ee.Image("LT51970241984315XXX02"); 4 | 5 | //addToMap(i1.select(["70", "40", "20"]), {}, 't1'); 6 | addToMap(i2.select(["70", "40", "20"]), {opacity:0.8}, 't2 (misaligned)'); 7 | //addToMap(i3.select(["70", "40", "20"]), {}, 't3'); 8 | 9 | Map.centerObject(i2, 10); 10 | 11 | -------------------------------------------------------------------------------- /by-year/2015/projections (Map, geometry): -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var geometry = /* color: d63000 */ee.Geometry.LineString( 3 | [[-125.947265625, 40.64730356252251], 4 | [-119.619140625, 45.521743896993634], 5 | [-109.248046875, 44.84029065139799]]); 6 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 7 | // projections (Map, geometry) 8 | 9 | print(Map.getScale()) // map scale is in meters 10 | print(ee.Projection('EPSG:3857')) // map projection (Pseudo-Mercator) 11 | 12 | print(geometry.projection().crs()) // coordinate reference system of geometry is geographic 13 | 14 | print(geometry.coordinates().get(0)) // 1st coordinate is in degrees 15 | print(geometry.length()) // but lengths is in meters 16 | print(geometry.length(1e-5, geometry.projection())) // geometry length in degrees 17 | 18 | -------------------------------------------------------------------------------- /by-year/2015/reduce by class from image: -------------------------------------------------------------------------------- 1 | // reduce by class from image 2 | 3 | var spectrumImage = ee.Image('LANDSAT/LC8_L1T_32DAY_TOA/20130407'); 4 | var classImage = ee.Image('MCD12Q1/MCD12Q1_005_2001_01_01').select('Land_Cover_Type_1'); 5 | var image = spectrumImage.addBands(classImage); 6 | 7 | var rect = ee.Geometry.Rectangle(-100, 19, -99, 20); 8 | var reducer = ee.Reducer.mean().unweighted().forEachBand(spectrumImage); 9 | print(image.reduceRegion(reducer.group(12), rect, 1000)); 10 | -------------------------------------------------------------------------------- /by-year/2015/reduce nu month Temporally Grouped Reduction EXAMPLE: -------------------------------------------------------------------------------- 1 | // Temporally Grouped Reduction EXAMPLE 2 | 3 | var modis = ee.ImageCollection('MODIS/MOD13A1'); 4 | 5 | var months = ee.List.sequence(1, 12); 6 | 7 | // Group by month, and then reduce within groups by mean(); 8 | // the result is an ImageCollection with one image for each 9 | // month. 10 | var byMonth = ee.ImageCollection.fromImages( 11 | months.map(function (m) { 12 | return modis.filter(ee.Filter.calendarRange(m, m, 'month')) 13 | .select(1).mean() 14 | .set('month', m); 15 | })); 16 | print(byMonth); 17 | 18 | Map.addLayer(ee.Image(byMonth.first())); -------------------------------------------------------------------------------- /by-year/2015/reduceMinMaxAndScale.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var images = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(Map.getCenter()) 5 | Map.setCenter(-76.74, 38.59, 13) 6 | 7 | var bounds = Map.getBounds(true); 8 | 9 | var image = ee.Image(images.filterBounds(bounds).filterMetadata('CLOUD_COVER', 'less_than', 10).first()) 10 | 11 | Map.addLayer(image.select(['B4', 'B3', 'B2']), {min:[0.05, 0.05, 0.05], max:[0.3, 0.3, 0.4]}) 12 | 13 | // is it possible to make them return approximately the same values? 14 | print(image.reduceRegion(ee.Reducer.min(), bounds, 30).get('B4')) 15 | print(image.reduceRegion(ee.Reducer.min(), bounds, 300).get('B4')) 16 | print(image.resample('bicubic').reduceRegion(ee.Reducer.min(), bounds, 300).get('B4')) 17 | 18 | -------------------------------------------------------------------------------- /by-year/2015/remove nulls: -------------------------------------------------------------------------------- 1 | // remove nulls 2 | 3 | zipped = zipped.removeAll([[null, null]]); -------------------------------------------------------------------------------- /by-year/2015/ridges: -------------------------------------------------------------------------------- 1 | var dem = ee.Image('USGS/SRTMGL1_003'); 2 | 3 | var gaussianKernel = ee.Kernel.gaussian(1.0, 1.0, "pixels"); 4 | var gaussianDem = dem.convolve(gaussianKernel); 5 | 6 | 7 | var terrain = ee.Algorithms.Terrain(gaussianDem); 8 | var slope = terrain.select("slope"); 9 | var hillshade = terrain.select("hillshade"); 10 | 11 | Map.addLayer(hillshade); 12 | Map.addLayer(dem, {min:0, max:4000}); 13 | Map.addLayer(gaussianDem, {min:0, max:4000}); 14 | Map.addLayer(slope); 15 | 16 | var terrain1 = terrain.addBands(terrain) 17 | var slope1 = terrain1.select('slope_1') 18 | 19 | var terrain2 = ee.Algorithms.Terrain(slope1); 20 | 21 | var slope2 = terrain2.select('slope') 22 | var hillshade2 = terrain2.select('hillshade') 23 | 24 | Map.addLayer(slope2); 25 | Map.addLayer(hillshade2); 26 | 27 | print(slope2) -------------------------------------------------------------------------------- /by-year/2015/roads, compute intersections: -------------------------------------------------------------------------------- 1 | // roads, compute intersections 2 | 3 | Map.setCenter(-121.9031, 36.9775, 15); 4 | 5 | // Roads in Santa Cruz County, CA 6 | var roads = ee.FeatureCollection('ft:121CRiCES306Yx8wv01rAQml1No8THjNLN0sS1NoH'); 7 | 8 | addToMap(roads, {}, "roads"); 9 | 10 | // Set up an intersection filter. 11 | var filter = ee.Filter.intersects({ 12 | leftField: '.geo', 13 | rightField: '.geo'}); 14 | 15 | // Get the intersection points between roads. 16 | // At the end, filter out self-intersections by 17 | // dropping features with length 0. 18 | var joined = ee.Join.inner('road1', 'road2') 19 | .apply(roads, roads, filter); 20 | var intersections = joined.map(function(tuple) { 21 | var dict = ee.Feature(tuple); 22 | var road1 = ee.Feature(dict.get('road1')); 23 | var road2 = ee.Feature(dict.get('road2')); 24 | var intersection = road1.intersection(road2); 25 | var length = intersection.length(); 26 | return intersection.set('length', length); 27 | }).filter(ee.Filter.eq('length', 0)); 28 | 29 | addToMap(intersections, {}, 'intersections'); 30 | -------------------------------------------------------------------------------- /by-year/2015/scene boundaries: -------------------------------------------------------------------------------- 1 | var pa = ee.FeatureCollection('ft:1u9f2vs39TSQVFR6YXVo9SWXweSDJ2m8DtcRoHyw'); 2 | var outlines = ee.Image(0).mask(0).byte().paint(pa, 255, 2); 3 | outlines = outlines.mask(outlines.neq(0)); 4 | addToMap(outlines, {min:0, max:255}); 5 | centerMap(108.9,4.5,7); -------------------------------------------------------------------------------- /by-year/2015/scene_count.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l5 = ee.ImageCollection("LANDSAT/LT5_L1T_TOA"), 3 | l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 4 | l7 = ee.ImageCollection("LANDSAT/LE7_L1T_TOA"); 5 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 6 | print(Map.getCenter()) 7 | Map.setCenter(103.82, 12.84, 7) 8 | var add = function(ic, name) { Map.addLayer(ic.select(0).count(), {min:0, max:500, palette:['ff0000', '00ff00']}, name); } 9 | add(l5, 'l5') 10 | add(l7, 'l7') 11 | add(l8, 'l8') -------------------------------------------------------------------------------- /by-year/2015/train classifier: -------------------------------------------------------------------------------- 1 | // train classifier 2 | // see also Workspace: https://earthengine.google.org/#workspace/EIUBUuSjgwE 3 | 4 | var input = ee.Image("LE7_TOA_1YEAR/2001") 5 | var region = ee.Geometry.Rectangle([2.34802, 10.30052, 12.56531, 1.22672]) 6 | var features = ee.FeatureCollection("ft:1wp3BTRf4VvN5RlG92E3doir7UzkvebRDStQc2kmY") 7 | var classifier = input.trainClassifier({ 8 | training_features: features, 9 | training_property: "class", 10 | classifier_name: "VotingSvm" 11 | }); 12 | var result = input.classify(classifier) 13 | 14 | var palette = ["22e5ef","ff4217","4de41c","2b783b","fbff13"]; 15 | Map.addLayer(result, {palette: palette, min:1, max:5, format:"png"}); 16 | Map.addLayer(ee.Image().paint(region, 1, 1)); 17 | Export.image(result, "Classification", { 18 | region: JSON.stringify(region.toGeoJSON().coordinates),'maxPixels': 10e9, 19 | scale: 10}) 20 | -------------------------------------------------------------------------------- /by-year/2015/transparent image: -------------------------------------------------------------------------------- 1 | // transparent image 2 | 3 | var lat = ee.Image.pixelLonLat().select('latitude'); 4 | var mask = lat.subtract(0).multiply(1); 5 | Map.addLayer(lat.mask(mask), {'palette':"FF0000"}); -------------------------------------------------------------------------------- /by-year/2015/transparent polygons: -------------------------------------------------------------------------------- 1 | // transparent polygons 2 | 3 | var pa = ee.FeatureCollection('ft:1u9f2vs39TSQVFR6YXVo9SWXweSDJ2m8DtcRoHyw'); 4 | var outlines = ee.Image(0).mask(0).byte().paint(pa, 255, 2); 5 | outlines = outlines.mask(outlines.neq(0)); 6 | addToMap(outlines, {min:0, max:255}); 7 | centerMap(108.9,4.5,7); -------------------------------------------------------------------------------- /by-year/2016/ASTER.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var aster = ee.ImageCollection("ASTER/AST_L1T_003"), 3 | geometry = /* color: d63000 */ee.Geometry.Point([-120.15498161315918, 39.38141608560946]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | // add ASTER images 6 | var images = aster 7 | .filterBounds(geometry) 8 | .select(['B09', 'B3N', 'B02']) 9 | .filter(ee.Filter.listContains('ORIGINAL_BANDS_PRESENT', 'B09')) 10 | .filter(ee.Filter.listContains('ORIGINAL_BANDS_PRESENT', 'B3N')) 11 | .filter(ee.Filter.listContains('ORIGINAL_BANDS_PRESENT', 'B02')) 12 | 13 | Map.addLayer(images, {}, 'all', false) 14 | 15 | print(images.first()) 16 | 17 | var count = images.select(0).aggregate_count('system:id') 18 | print('ASTER', count) 19 | 20 | var count = 50 21 | var list = images.toList(count, 0) 22 | for(var i=0; i 1) { 11 | throw 'Bad reflectance value: ' + reflectance 12 | } 13 | -------------------------------------------------------------------------------- /by-year/2016/Chart.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gena/ee-code-editor-archive/31346f56ef919f87d29787b227dc1c92531ea889/by-year/2016/Chart.js -------------------------------------------------------------------------------- /by-year/2016/ComputeCount.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var geometry = /* color: d63000 */ee.Geometry.LineString( 3 | [[-137.28515625, 34.88593094075317], 4 | [-128.84765625, 43.19716728250127], 5 | [-119.267578125, 39.707186656826565], 6 | [-105.99609375, 44.5278427984555]]); 7 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 8 | var scale = 50000; 9 | 10 | // convert line to coarse scale raster 11 | var image = ee.Image().toByte() 12 | .paint(geometry, 1, 5) 13 | .reproject('EPSG:3587', null, scale) 14 | 15 | // generate geometry 16 | var rect = geometry.bounds().buffer(scale * 5) 17 | 18 | // count pixels 19 | var total = image.reduceRegion(ee.Reducer.sum(), rect, scale, null, null, false, 1e12, 15) 20 | print(total) 21 | 22 | 23 | // add layers 24 | Map.addLayer(image, {}, 'raster') 25 | Map.addLayer(rect, {}, 'rect') 26 | -------------------------------------------------------------------------------- /by-year/2016/EqualizeHistogram.js: -------------------------------------------------------------------------------- 1 | // histogram reducer 2 | 3 | var image = new ee.Image(new ee.ImageCollection("LANDSAT/LC8_L1T_TOA") 4 | .select(['B4', 'B3', 'B2']) 5 | .filterBounds(ee.Geometry(Map.getBounds(true)).centroid(100)) 6 | .filter(ee.Filter.lt('CLOUD_COVER', 15)) 7 | .first()); 8 | 9 | //Map.centerObject(image, 14); 10 | Map.addLayer(image); 11 | 12 | var g = Map.getBounds(true); 13 | var scale = 300 14 | 15 | var i = image.reduce(ee.Reducer.max()) // reduce to a single band 16 | var minMax = i.reduceRegion(ee.Reducer.percentile([1, 98]), g, scale).values().getInfo(); 17 | var min = minMax[0] 18 | var max = minMax[1] 19 | 20 | Map.addLayer(image, {'min': min, 'max': max}); 21 | 22 | 23 | -------------------------------------------------------------------------------- /by-year/2016/ExportImageAsFeature.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var image = ee.Image(l8.first()) 5 | 6 | function toFeature(image) { 7 | return ee.Feature(image.select(0).geometry(), image.toDictionary()) 8 | } 9 | 10 | var feature = toFeature(image) 11 | 12 | Map.addLayer(feature) 13 | Map.centerObject(feature) 14 | 15 | Export.table.toDrive(ee.FeatureCollection([feature])) 16 | -------------------------------------------------------------------------------- /by-year/2016/ExportRobinson.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var image = ee.Image("NOAA/NGDC/ETOPO1"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var dem = image.select('bedrock') 5 | 6 | // export in Robinson - FAILS 7 | var rect = ee.Geometry.Rectangle([-180, -90, 180, 90]) 8 | Export.image.toDrive({image: i, description: 'dem_Robinson', fileNamePrefix: 'dem_Robinson', dimensions: '1024x768', region: rect, crs: 'EPSG:53030'}) 9 | 10 | // show as Web Mercator 11 | var i = dem.visualize({min:-1000, max:5000, forceRgbOutput:true}) 12 | Map.addLayer(i, {}, 'dem (Web Mercator)') 13 | 14 | // show as WGS84 15 | var j = i.changeProj(ee.Projection('EPSG:4326'), ee.Projection('EPSG:3857').scale(111315, 111315)) 16 | Map.addLayer(ee.ImageCollection([ee.Image(0).visualize({palette:['ffffff']}), j]).mosaic(), {}, 'dem (WGS84)') 17 | 18 | Map.setCenter(0,0,1) 19 | 20 | -------------------------------------------------------------------------------- /by-year/2016/FEATURE_ImageScale.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('CGIAR/SRTM90_V4') 2 | 3 | // 1. hangs, client-side 4 | var info = image.getInfo() 5 | var transform = info.bands[0].crs_transform 6 | print(transform) 7 | var scale = transform[0] 8 | 9 | print('Scale: ', scale) 10 | 11 | // 2. looks to complex 12 | var proj = image.projection() 13 | var transform = proj.transform() // return type is string 14 | print(transform) 15 | var scale = ee.Number.parse(ee.String(transform.split('elt_0_0", ').get(1)).split('\\]').get(0)) // :( 16 | 17 | print('Scale: ', scale) -------------------------------------------------------------------------------- /by-year/2016/FilterEveningImages.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | l8 = l8 5 | .filterBounds(Map.getBounds(true)) 6 | .filter( 7 | ee.Filter.or( 8 | ee.Filter.lessThan('SUN_ELEVATION', 5), 9 | ee.Filter.greaterThan('WRS_ROW', 120) 10 | ) 11 | ) 12 | 13 | print(l8.size()) 14 | 15 | Map.addLayer(l8.select([5,4,2]).reduce(ee.Reducer.percentile([20]))) 16 | 17 | -------------------------------------------------------------------------------- /by-year/2016/HIC_2016_review.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var fa = ee.Image("WWF/HydroSHEDS/15ACC"), 3 | geometry = /* color: d63000 */ee.Geometry.Point([119.56480979919434, 31.243519408729505]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.addLayer(fa.mask(fa.gt(100))) 6 | 7 | Map.setCenter(119.55, 31.22, 13) 8 | 9 | var reservoirFA = fa.reduceRegion(ee.Reducer.first(), geometry, 100).get('b1') 10 | var area = ee.Number(reservoirFA).multiply(450*450 / 1000000) 11 | print('Reservoir drainage area (km2): ', area) -------------------------------------------------------------------------------- /by-year/2016/HillshadeMultiplyVsHsv.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image("LE7_TOA_1YEAR/2014").select(["B3", "B2", "B1"]); 2 | Map.addLayer(image, {min:0, max: 100, bands: ["B3", "B2", "B1"]}) 3 | 4 | var hillshade = ee.Terrain.hillshade(ee.Image("srtm90_v4")) 5 | var image1 = image.add(hillshade.int().subtract(180)) 6 | Map.addLayer(image1, {min:0, max: 100}) 7 | 8 | var weight = 0.5 9 | var hsv = image.unitScale(0, 100).rgbToHsv() 10 | var intensity = hsv.select('value').multiply(ee.Image(1).toFloat().subtract(weight)) 11 | .add(hillshade.unitScale(50,255).multiply(weight)) 12 | var image2 = ee.Image.cat(hsv.select('hue', 'saturation'), intensity).hsvtorgb() 13 | Map.addLayer(image2, {min:0.3, max: [0.9,0.9,1]}) 14 | -------------------------------------------------------------------------------- /by-year/2016/JRC_water_monthly.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var monthlyWater = ee.ImageCollection("JRC/GSW1_0/MonthlyHistory"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | print(monthlyWater.first()) 5 | 6 | var water2010 = monthlyWater.filterDate('2010-01-01', '2011-01-01').mean() 7 | Map.addLayer(water2010.mask(water2010), {palette:['ffffff', '0000ff']}, '2010-2011') 8 | 9 | var water2013 = monthlyWater.filterDate('2013-01-01', '2014-01-01').mean() 10 | Map.addLayer(water2013.mask(water2013), {palette:['ffffff', '0000ff']}, '2013-2014') 11 | 12 | var water2014 = monthlyWater.filterDate('2014-01-01', '2015-01-01').mean() 13 | Map.addLayer(water2014.mask(water2014), {palette:['ffffff', '0000ff']}, '2014-2015') 14 | -------------------------------------------------------------------------------- /by-year/2016/L5_shift.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8toa = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 3 | l5toa = ee.ImageCollection("LANDSAT/LT5_L1T_TOA"); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | l5toa = l5toa.select([4,3,1]) 6 | l8toa = l8toa.select([5,4,2]) 7 | 8 | print(l5toa.first()) 9 | print(l8toa.first()) 10 | 11 | Map.addLayer(l8toa.filterDate('2015-01-01', '2016-01-01').reduce(ee.Reducer.percentile([15])), {min:0.05, max:0.3}, '2016 l8toa') 12 | Map.addLayer(l5toa.filterDate('1999-01-01', '2005-01-01').reduce(ee.Reducer.percentile([15])), {min:0.05, max:0.3, opacity: 0.7}, '1999 l5toa') 13 | -------------------------------------------------------------------------------- /by-year/2016/Lake_Tahoe.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // http://tahoe.usgs.gov/bath.html 5 | 6 | Map.addLayer(l8.select([6,5,2]).reduce(ee.Reducer.percentile([15])), {min:0.05, max:0.3}, '15%') 7 | Map.addLayer(l8.select([6,5,2]).reduce(ee.Reducer.percentile([60])), {min:0.05, max:0.3}, '60%') -------------------------------------------------------------------------------- /by-year/2016/MaskCombination.js: -------------------------------------------------------------------------------- 1 | var l7 = new ee.ImageCollection('LANDSAT/LE7_L1T_TOA').filterDate('2005-01-01', '2006-01-01').select(['B5', 'B4', 'B2']); 2 | 3 | 4 | var images = l7 5 | 6 | Map.addLayer(images.reduce(ee.Reducer.percentile([15])), {min:0.03, max:0.3}, 'l7') 7 | 8 | images = images.map(function(i) { 9 | var mask = i.mask(); 10 | // var maskNew = mask.select(0).multiply(mask.select(1).multiply(mask.select(2))) 11 | var maskNew = maskNew.focal_min(1000, 'square', 'meters') 12 | return i.mask(maskNew) 13 | }) 14 | 15 | Map.addLayer(images.reduce(ee.Reducer.percentile([15])), {min:0.03, max:0.3}, 'l7 (masked)') 16 | -------------------------------------------------------------------------------- /by-year/2016/ScalesPrecision.js: -------------------------------------------------------------------------------- 1 | var scale = 0.0333333333333333333333333333333333333333; // truncates to 17 digits precision (double) 2 | print(scale) 3 | print(ee.Number(scale).getInfo()) 4 | 5 | print(scale === ee.Number(scale).getInfo()) 6 | 7 | scale = ee.Number(scale) 8 | 9 | var prj = ee.Projection('EPSG:4326').scale(scale, scale) 10 | 11 | var scaleComputed = prj.nominalScale().divide(ee.Projection('EPSG:4326').nominalScale()) 12 | 13 | print('Original scale:', scale.format('%.25f')) 14 | print('Computed scale:', scaleComputed.format('%.25f')) 15 | 16 | print('Computed and original scales area equal: ', scaleComputed.eq(scale)) 17 | 18 | // SRTM 19 | var dem = ee.Image('USGS/SRTMGL1_003') 20 | var prj = dem.projection() 21 | print(prj.transform()) 22 | 23 | print(prj.nominalScale().divide(ee.Projection('EPSG:4326').nominalScale())) 24 | 25 | // HAND 26 | var hand = ee.Image(ee.ImageCollection('users/gena/global-hand/hand-100').first()) 27 | var prj = hand.projection() 28 | print(prj.transform()) 29 | 30 | print(prj.nominalScale().divide(ee.Projection('EPSG:4326').nominalScale())) 31 | -------------------------------------------------------------------------------- /by-year/2016/SeaLevelRiseScenario.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | Map.addLayer(srtm.gt(0), {}, 'SRTM > 0', false) 5 | Map.addLayer(srtm.gt(1), {}, 'SRTM > 1m (3.28 feet)', false) 6 | 7 | var diff = srtm.gt(0).subtract(srtm.gt(1)) 8 | Map.addLayer(diff.mask(diff), {palette:['ff0000']}, 'diff (80 year scenario)') -------------------------------------------------------------------------------- /by-year/2016/SelectAllLandsat.js: -------------------------------------------------------------------------------- 1 | // define image collections for LANDSAT 5, 7, and 8 2 | var l5 = ee.ImageCollection('LANDSAT/LT5_L1T_TOA').select(['B3', 'B2', 'B1'], ['red', 'green', 'blue']) 3 | var l7 = ee.ImageCollection('LANDSAT/LE7_L1T_TOA').select(['B3', 'B2', 'B1'], ['red', 'green', 'blue']) 4 | var l8 = ee.ImageCollection('LANDSAT/LC8_L1T_TOA').select(['B4', 'B3', 'B2'], ['red', 'green', 'blue']) 5 | 6 | // merge 7 | var images = ee.ImageCollection(l5.merge(l7).merge(l8)) 8 | 9 | // filter images by path/row 10 | images = images.filter(ee.Filter.and(ee.Filter.eq('WRS_PATH', 96), ee.Filter.eq('WRS_ROW', 71))) 11 | 12 | // print 13 | print(images.size()) 14 | 15 | // show count and first 16 | Map.addLayer(images.select(0).count(), {min: 0, max: 800, palette:['d7191c', '1a9641']}, 'count', false) 17 | Map.addLayer(ee.Image(images.first()), {min: 0.05, max:0.3}, 'first') 18 | -------------------------------------------------------------------------------- /by-year/2016/Sentinel1-maskedges.js: -------------------------------------------------------------------------------- 1 | var collection = ee.ImageCollection('COPERNICUS/S1_GRD').filterMetadata('instrumentMode', 'equals', 'IW'). 2 | filter(ee.Filter.eq('transmitterReceiverPolarisation', 'VV')); 3 | 4 | var c = ee.Geometry.Point(2.46, 48.57) 5 | 6 | function maskEdge(img) { 7 | var mask = img.select(0).unitScale(-25, 5).multiply(255).toByte().connectedComponents(ee.Kernel.rectangle(1,1), 100); 8 | return img.updateMask(mask.select(0)); 9 | } 10 | 11 | var im = ee.Image(collection.filterDate('2015-03-01', '2015-03-31').filterBounds(c).first()) 12 | Map.addLayer(im, {bands: ['VV'], min:-25, max: 0}, 'VV non-masked'); 13 | 14 | collection = collection.map(maskEdge); 15 | 16 | var im = ee.Image(collection.filterDate('2015-03-01', '2015-03-31').filterBounds(c).first()) 17 | Map.addLayer(im, {bands: ['VV'], min:-25, max: 0}, 'VV masked'); 18 | 19 | var im = ee.Image(collection.filterDate('2015-03-01', '2015-03-31').filterBounds(c).first()) 20 | Map.addLayer(im, {bands: ['VH'], min:-25, max: 0}, 'VH masked'); 21 | -------------------------------------------------------------------------------- /by-year/2016/Sentinel2_and_HydroSHEDS.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var s2 = ee.ImageCollection("COPERNICUS/S2"), 3 | fa = ee.Image("WWF/HydroSHEDS/15ACC"), 4 | fa90 = ee.Image("users/gena/GlobalHAND/90m-global/fa"); 5 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 6 | 7 | var percentile = 15 8 | 9 | var p = s2.select(['B3', 'B8']).reduce(ee.Reducer.percentile([percentile])).rename(['B3', 'B8']) 10 | 11 | Map.addLayer(p, {bands: ['B3', 'B8', 'B3'], min: 100, max:3000}, percentile + '%') 12 | 13 | var ndwi = p.normalizedDifference(['B3', 'B8']) 14 | Map.addLayer(ndwi, {min: -0.5, max: 0.5}, 'NDWI') 15 | 16 | Map.addLayer(fa.mask(fa.gt(10)), {}, 'flow accumulation') 17 | 18 | Map.addLayer(fa90.mask(fa90.gt(100)), {}, 'fa 90 > 100') 19 | -------------------------------------------------------------------------------- /by-year/2016/Storage2Array.js: -------------------------------------------------------------------------------- 1 | var path = 'gs://gee-storage.appspot.com/test_binary.dat' 2 | 3 | function readBinaryArray(path, precision) { 4 | // read a binary array from a Blob stored in Google Cloud Storage 5 | // assume little-endian encoding and given precision (default uint8) 6 | // TODO handle signed precision 7 | var numBytes = 1; 8 | if (precision == 'uint8') {numBytes = 1;} 9 | if (precision == 'uint16') {numBytes = 2;} 10 | if (precision == 'uint32') {numBytes = 4;} 11 | var str = ee.Blob(path).string().getInfo(); 12 | var strLen=str.length; 13 | var buf = ee.List.repeat(0,strLen/numBytes); 14 | var val = 0, cnt = 0; 15 | for (var i=0; i 8 | * 3. create Features from Storage 9 | * 10 | * @param {string} path 11 | * Path to the Google Storage file containing GeoJSON FeatureCollection. 12 | * 13 | * @return {ee.FeatureCollection} A new feature collection. 14 | */ 15 | community.Algorithms.fromStorage = function(path) { 16 | var str = ee.Blob(path).string().getInfo() 17 | var o = JSON.parse(str) 18 | var features = o.features.map(function(f) { return ee.Feature(f) }) 19 | 20 | return ee.FeatureCollection(features) 21 | }; 22 | 23 | // ========================================================================================= 24 | 25 | var fc = community.Algorithms.fromStorage('gs://hydro-earth-v2/hello.geojson') 26 | 27 | print('First feature: ', fc.first()) 28 | 29 | Map.addLayer(fc, {}, 'feature collection') 30 | -------------------------------------------------------------------------------- /by-year/2016/SumHistogramBinRanges.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var region = /* color: d63000 */ee.Geometry.Polygon( 3 | [[[-122.1514892578125, 38.35673412466715], 4 | [-122.14599609375, 37.76854362092148], 5 | [-121.46484375, 37.71207219310847], 6 | [-121.5087890625, 38.37396220263095]]]); 7 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 8 | var image = ee.Image('srtm90_v4'); 9 | 10 | var bins = ee.Array([0, 5, 20, 80, 320, 1250, 5000]); 11 | 12 | // Map each pixel value to an array with a '1' in the appropriate bin. 13 | var binned = image.gte(bins.slice(0, 0, -1)) 14 | .and(image.lt(bins.slice(0, 1))); 15 | 16 | // Sum over the pixels we're interested in. 17 | print(binned.toInt32().reduceRegion(ee.Reducer.sum().forEachElement(), region)); 18 | -------------------------------------------------------------------------------- /by-year/2016/Water_GLCF.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var glcf = ee.ImageCollection("GLCF/GLS_WATER"), 3 | water = ee.Image("users/gena/AU_Murray_Darling/MNDWI_15_water_WGS"), 4 | l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 5 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 6 | Map.addLayer(l8.select(['B6','B5','B3']).reduce(ee.Reducer.percentile([20])),{min:0.03, max:0.4}, 'l8', false) 7 | 8 | var water1 = glcf.map(function(i){return i.eq(2)}).mosaic() 9 | var water2 = water.select(0).add(water.select(1)).add(water.select(2)).neq(0) 10 | Map.addLayer(water2.mask(water2), {gamma:3}, 'AU') 11 | Map.addLayer(water1.mask(water1), {palette:['ff6060']}, 'GLCF') 12 | 13 | -------------------------------------------------------------------------------- /by-year/2016/bits.js: -------------------------------------------------------------------------------- 1 | /*** 2 | * Pad a number with leading zeros 3 | */ 4 | function pad(n, width, z) { 5 | z = z || '0'; 6 | n = n + ''; 7 | return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; 8 | } 9 | 10 | /*** 11 | * Test if specific bit is set 12 | */ 13 | function testBit(value, bit) { 14 | // generate a binary pattern 15 | var pattern = Math.pow(2, bit) 16 | 17 | // test bit 18 | var result = ee.Number(value).bitwiseAnd(pattern).gt(0); 19 | 20 | // debug 21 | print(pad(value.toString(2), 4) + ' AND ' + pad(pattern.toString(2), 4) + ' = ' + result.getInfo()) 22 | 23 | return result; 24 | } 25 | 26 | // tests 27 | var value = 0 28 | print(testBit(value, 0)) 29 | print(testBit(value, 1)) 30 | 31 | var value = 1 32 | print(testBit(value, 0)) 33 | print(testBit(value, 1)) 34 | 35 | var value = 2 36 | print(testBit(value, 0)) 37 | print(testBit(value, 1)) 38 | -------------------------------------------------------------------------------- /by-year/2016/contour.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var srtm = ee.Image("USGS/SRTMGL1_003"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var min = -10 5 | var max = 10 6 | var step = 2 7 | var levels = ee.List.sequence(min, max, step) 8 | 9 | var contours = levels.map(function(level) { 10 | var contour = srtm 11 | .resample('bicubic') 12 | .convolve(ee.Kernel.gaussian(5, 3)) 13 | .subtract(ee.Image.constant(level)).zeroCrossing() // line contours 14 | // .gt(ee.Image.constatn(level)) // area 15 | .multiply(ee.Image.constant(level)).toFloat(); 16 | 17 | return contour.mask(contour); 18 | }) 19 | 20 | contours = ee.ImageCollection(contours).mosaic() 21 | 22 | Map.addLayer(ee.Image(1).toByte(), {palette:['000000'], opacity: 0.8}, 'background') 23 | Map.addLayer(contours, {min: min, max: max, palette:['00ff00', 'ff0000']}, 'contours') 24 | 25 | Map.setOptions('SATELLITE') -------------------------------------------------------------------------------- /by-year/2016/folding.js: -------------------------------------------------------------------------------- 1 | /*** [section title] ***/ 2 | print('Hello') 3 | 4 | /*** [next section title] ***/ 5 | 6 | //#region [optional description] 7 | 8 | print('test') 9 | 10 | //#endregion -------------------------------------------------------------------------------- /by-year/2016/get_aster_sentinel1_scene_count_per_year.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var s1 = ee.ImageCollection("COPERNICUS/S1_GRD"), 3 | aster = ee.ImageCollection("ASTER/AST_L1T_003"); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | ee.List.sequence(2000, 2017).getInfo().map(function(y) { 6 | aster.filterDate(ee.Date.fromYMD(y, 1, 1), ee.Date.fromYMD(y+1, 1, 1)).size().getInfo(function(l) { 7 | print('ASTER, ' + y + ', ' + l) 8 | }) 9 | }) 10 | 11 | ee.List.sequence(2012, 2017).getInfo().map(function(y) { 12 | s1.filterDate(ee.Date.fromYMD(y, 1, 1), ee.Date.fromYMD(y+1, 1, 1)).size().getInfo(function(l) { 13 | print('C-SAR, ' + y + ', ' + l) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /by-year/2016/historgram_for_image_bands.js: -------------------------------------------------------------------------------- 1 | var image = ee.Image('LANDSAT/LC8_L1T/LC82220762015015LGN00'); 2 | 3 | var vis = { 4 | bands: ['B5', 'B6', 'B4'], 5 | min: [0, 1977, 3640], 6 | max: [37401, 16151, 10260] 7 | }; 8 | 9 | Map.addLayer(image, vis) 10 | 11 | // show histogram 12 | var scale = 300 13 | var maxBuckets = 100 14 | print(ui.Chart.image.histogram(image.select('B5'), image.geometry(), scale, maxBuckets)) 15 | print(ui.Chart.image.histogram(image.select('B6'), image.geometry(), scale, maxBuckets)) 16 | print(ui.Chart.image.histogram(image.select('B4'), image.geometry(), scale, maxBuckets)) 17 | 18 | var hist = image.reduceRegion(ee.Reducer.histogram(maxBuckets), image.geometry(), scale) 19 | print(hist) -------------------------------------------------------------------------------- /by-year/2016/imagecollection2multiband.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var ic = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | ic = ic 5 | .filterBounds(Map.getBounds(true)) 6 | .filterDate('2015-01-01', '2015-06-01') 7 | .select(0) 8 | .map(function(i) { 9 | return i.unmask(0, false) 10 | }) 11 | 12 | var a = ic.toArray() 13 | 14 | Map.addLayer(a) 15 | 16 | var bandNames = ee.List.sequence(1, ic.size()).map(function(i) { 17 | return ee.String('T').cat(ee.Number(i).format('%d')) 18 | }) 19 | 20 | print(bandNames) 21 | 22 | var multiband = a.matrixTranspose(0, 1).arrayProject([1]).arrayFlatten([bandNames]) 23 | 24 | Map.addLayer(multiband) 25 | 26 | -------------------------------------------------------------------------------- /by-year/2016/profile_client.js: -------------------------------------------------------------------------------- 1 | var n = 10 2 | var loop = ee.List.sequence(0, n).getInfo() 3 | var times = [] 4 | 5 | // client-side profiling 6 | function profile(f, i) { 7 | var t0 = new Date() 8 | 9 | f.getInfo(function(f) { 10 | var t1 = new Date() 11 | 12 | var elapsed = t1.getTime() - t0.getTime() 13 | 14 | times.push(elapsed) 15 | 16 | if(i === n) { 17 | print(ui.Chart.array.values(times, 0)) 18 | } 19 | }) 20 | 21 | return f 22 | } 23 | 24 | // client-side delay 25 | function delay(millis) { 26 | var before = Date.now(); 27 | while (Date.now() < before + millis) {}; 28 | } 29 | 30 | // server-side function 31 | function f(i) { 32 | var image = ee.Image(ee.ImageCollection('LANDSAT/LC8_L1T_TOA').first()) 33 | var value = image.reduceRegion(image.geometry().centroid()) 34 | 35 | profile(value, i) 36 | } 37 | 38 | // 1. call function n times 39 | loop.map(function(i) { 40 | f(i) 41 | }) 42 | 43 | return 44 | 45 | delay(5000) 46 | 47 | // 2. call function n times with delay 48 | loop.map(function(i) { 49 | f(i) 50 | }) 51 | -------------------------------------------------------------------------------- /by-year/2016/resampling.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var image = ee.Image(l8.select(['B6', 'B5', 'B3']) 5 | .filterBounds(ee.Geometry(Map.getBounds(true)).centroid(10)).toList(1, 2).get(0)) 6 | 7 | Map.addLayer(image, {min: 0.03, max: 0.3}, 'image') 8 | 9 | Map.addLayer(image, {min: 0.03, max: 0.3}, 'image (bicubic)') -------------------------------------------------------------------------------- /by-year/2016/select_country_combobox.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var countries = ee.FeatureCollection("ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | // get country names 5 | var names = countries.aggregate_array('Country') 6 | 7 | // initialize combobox 8 | var select = ui.Select({ 9 | items: names.getInfo(), 10 | 11 | onChange: function(key) { 12 | var selectedCountry = ee.Feature(countries.filter(ee.Filter.eq('Country', key)).first()) 13 | Map.centerObject(selectedCountry); 14 | 15 | // show country 16 | var layer = ui.Map.Layer(selectedCountry, {color:'green'}, 'selected country') 17 | Map.layers().set(0, layer) 18 | } 19 | }); 20 | 21 | // show 22 | select.setPlaceholder('Choose a country ...'); 23 | print(select) -------------------------------------------------------------------------------- /by-year/2016/sigmoid.js: -------------------------------------------------------------------------------- 1 | function sigmoid(x) { 2 | return x.multiply(-1).exp().add(1).pow(-1) 3 | } 4 | 5 | 6 | Map.setCenter(0,0,7) 7 | 8 | var image = ee.Image([0,0]).mask(sigmoid(ee.Image.pixelLonLat().select(0))) 9 | Map.addLayer(image) 10 | -------------------------------------------------------------------------------- /by-year/2016/ts: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var images = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"), 3 | geometry = /* color: #d63000 */ee.Geometry.Point([-113.37890625, 41.96765920367816]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | var timeSeries = images 6 | .filterBounds(geometry) 7 | .sort('system:time_start') 8 | .getRegion(geometry, 30) 9 | 10 | print(timeSeries) 11 | 12 | // export 13 | var f = ee.Feature(null).set('timeSeries', timeSeries) 14 | Export.table.toDrive({collection: ee.FeatureCollection([f]), fileFormat: 'GeoJSON'}) 15 | 16 | // plot values 17 | print('Headers: ', timeSeries.get(0)) 18 | var times = timeSeries.slice(1).map(function(o) { return ee.List(o).slice(3, 4) }) 19 | var values = timeSeries.map(function(o) { return ee.List(o).slice(7, 9) }) 20 | 21 | print(ui.Chart.array.values(values, 0, times).setOptions({title: 'RED, NIR', type: 'line'})) 22 | -------------------------------------------------------------------------------- /by-year/2016/updateMask.js: -------------------------------------------------------------------------------- 1 | Map.setCenter(0, 0, 8) 2 | 3 | // generate a new image, a few squares 4 | var xy = ee.Image.pixelLonLat() 5 | var original = xy.mask(xy.abs().lt(1)).gt(0) 6 | 7 | Map.addLayer(original, {}, 'original', false) 8 | 9 | var mask1 = xy.abs() 10 | var mask2 = ee.Image(1).subtract(xy.abs()) 11 | 12 | // apply mask1 13 | var image1 = original.updateMask(mask1) 14 | Map.addLayer(image1, {}, 'masked (mask1)', false) 15 | 16 | // now apply mask2 on top of mask1, expected masks to be combined 17 | var image2 = image1.updateMask(mask2) 18 | Map.addLayer(image2, {}, 'masked (mask1, mask2)', false) 19 | 20 | // generate expected image 21 | var expected = original.updateMask(mask1.multiply(mask2)) 22 | Map.addLayer(expected, {}, 'expected') 23 | 24 | -------------------------------------------------------------------------------- /by-year/2019/AHN_fill.js: -------------------------------------------------------------------------------- 1 | var utils = require('users/gena/packages:utils') 2 | 3 | var colors_dem = ['006837', '1a9850', '66bd63', 'a6d96a', 'd9ef8b', 'ffffbf', 'fee08b', 'fdae61', 'f46d43', 'd73027', 'a50026', 'ffffff'] 4 | 5 | var addDem = function(dem, name, min, max, visible) { 6 | var im = dem.visualize({palette:colors_dem, min:min, max:max, opacity: 1.0}); 7 | Map.addLayer(utils.hillshadeRGB(im, dem, 1.4, 6.0, 35), {}, name, visible); 8 | } 9 | 10 | var dem = ee.Image('AHN/AHN2_05M_INT') // interpolated 11 | 12 | var min = -5 13 | var max = 10 14 | 15 | // original 16 | addDem(dem, 'AHN (land)', min, max, true) 17 | 18 | // filled 19 | var radius = 15 20 | var iterations = 2 21 | var demFilled = utils.fillGaps(dem, radius, iterations) 22 | addDem(demFilled, 'AHN fill', min, max, true) 23 | 24 | 25 | -------------------------------------------------------------------------------- /by-year/2019/ET.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var naip = ee.ImageCollection("USDA/NAIP/DOQQ"), 3 | s2 = ee.ImageCollection("COPERNICUS/S2"); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | Map.addLayer(s2.filterDate('2017-05-01', '2017-10-01').select(['B4', 'B3','B2']).reduce(ee.Reducer.percentile([20])), {min: 300, max: 3000}, 'S2') 6 | Map.addLayer(ee.Image(naip.filterBounds(Map.getBounds(true)).select(['R','G','B']).mosaic()), {min:0, max: 255, gamma: 0.9}, 'NAIP') 7 | 8 | print(ee.Image(naip.filterBounds(Map.getBounds(true)).first()).projection()) 9 | print(Map.getCenter()) -------------------------------------------------------------------------------- /by-year/2019/FA_90m: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var table = ee.FeatureCollection("users/gena/eo-reservoirs/waterbodies-reservoirs"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var palettes = require('users/gena/packages:palettes') 5 | 6 | var hydro = require('users/gena/packages:hydro') 7 | hydro.Map.addDem({ palette: palettes.cb.Greys[9].slice(2) }) 8 | 9 | Map.addLayer(ee.Image(1), { palette: ['000000']}, 'black', true, 0.7) 10 | 11 | var fa = ee.ImageCollection('users/imerg/flow_acc_3s').mosaic() 12 | 13 | Map.addLayer(fa.mask(fa.unitScale(1000, 10000)), {min: 1000, max: 100000, palette: palettes.cb.OrRd[9].slice(0).reverse().slice(2) }, 'FA, 90m', true) 14 | 15 | Map.addLayer(fa.mask(fa.unitScale(100, 5000)).updateMask(ee.Image(1).subtract(fa.unitScale(100, 5000))), {min: 100, max: 5000, palette: palettes.cb.OrRd[9].slice(2) }, 'FA, 90m', true) 16 | 17 | Map.addLayer(table.style( {fillColor: '00ffff44', color: '00ffff'} ), {}, 'reservoirs') -------------------------------------------------------------------------------- /by-year/2019/Florida_flood_NAIP.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var naip = ee.ImageCollection("USDA/NAIP/DOQQ"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var animation = require('users/gena/packages:animation') 5 | 6 | naip = naip.filterBounds(Map.getBounds(true)) 7 | 8 | naip = naip.map(function(i) { 9 | return i.set({ hasN: i.bandNames().contains('N') }) 10 | }) 11 | .filter(ee.Filter.eq('hasN', true)) 12 | .select(['N', 'R', 'G']) 13 | 14 | var years = ee.List([2010, 2013, 2015, 2017]) 15 | var images = years.map(function(y) { 16 | var t0 = ee.Date.fromYMD(y, 1, 1) 17 | var t1 = t0.advance(1, 'year') 18 | 19 | return naip.filterDate(t0, t1).mosaic().set('system:time_start', t0.millis()) 20 | }) 21 | 22 | 23 | images = ee.ImageCollection(images).map(function(i) { 24 | return i.set({ label: i.date().format() }) 25 | }).sort('system:time_start') 26 | 27 | animation.animate(images, { vis: {min: 0, max: 255}, label: 'label' }) 28 | -------------------------------------------------------------------------------- /by-year/2019/Florida_flood_precip.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var gsmap = ee.ImageCollection("JAXA/GPM_L3/GSMaP/v6/operational"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var animation = require('users/gena/packages:animation') 5 | var palettes = require('users/gena/packages:palettes') 6 | var palette = palettes.cb.PuRd[7] 7 | 8 | Map.setOptions('HYBRID') 9 | 10 | var p = gsmap.select('hourlyPrecipRate').filterDate('2017-06-06', '2017-06-08') 11 | .map(function(i) { return i.resample('bicubic')}) 12 | 13 | var frames = p 14 | .map(function(i) { 15 | return i.updateMask(i.unitScale(0, 15)).visualize({palette: palette, min: 0, max: 15}) 16 | .set({label: i.date().format()}) 17 | }) 18 | 19 | var total = p.sum() 20 | Map.addLayer(total.updateMask(total.unitScale(0, 15)), {min: 0, max: 450, palette: palette}, 'total') 21 | 22 | animation.animate(frames, {maxFrames: 100, label: 'label'}) -------------------------------------------------------------------------------- /by-year/2019/Florida_floods.js: -------------------------------------------------------------------------------- 1 | var animation = require('users/gena/packages:animation') 2 | var assets = require('users/gena/packages:assets') 3 | 4 | var images = assets.getImages(Map.getCenter(), { 5 | //missions: ['S2'], 6 | missions: ['S2', 'L8', 'L7'], 7 | includeTier2: true, 8 | resample: true, 9 | //filter: ee.Filter.date('2016-01-01', '2019-01-01') 10 | //filter: ee.Filter.date('2017-01-01', '2018-01-01') 11 | filter: ee.Filter.date('2017-05-01', '2017-09-01') 12 | }).map(function(i) { return i.set({label: i.date().format().cat(', ').cat(i.get('MISSION')) })}) 13 | 14 | // images = assets.getMostlyCleanImages(images, Map.getBounds(true), { 15 | // //cloudFrequencyThresholdDelta: 0.15, 16 | // }) 17 | 18 | images = images.sort('system:time_start') 19 | print(images.size()) 20 | 21 | animation.animate(images, { 22 | vis: {min: 0.05, max: 0.4}, 23 | label: 'label', 24 | maxFrames: 150 25 | }) 26 | -------------------------------------------------------------------------------- /by-year/2019/NAIP.js: -------------------------------------------------------------------------------- 1 | var images = ee.ImageCollection('USDA/NAIP/DOQQ') 2 | //.filterDate('2013-01-01', '2014-12-01') 3 | .filterBounds(Map.getBounds(true)) 4 | print(images) 5 | 6 | var size = images.size().getInfo() 7 | 8 | images = images.toList(size) 9 | 10 | for(var i=0; i 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /paper-global-reservoirs/.idea/watcherTasks.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /paper-global-reservoirs/NCC_sun_parameters: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var mines = ee.FeatureCollection("users/gena/mines-mrds"); 3 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 4 | var mines = ee.FeatureCollection("users/gena/mines-mrds"); 5 | var minesImage = ee.Image().paint(mines, 1, 1).focal_max(4) 6 | Map.addLayer(minesImage, {palette: ['ff0000']}, 'mines') 7 | 8 | var assets = require('users/gena/packages:assets') 9 | 10 | var clear = true 11 | var images = assets.getImages(ee.Geometry(Map.getBounds(true)), clear) 12 | 13 | images = images 14 | .sort('system:time_start') 15 | .sort('MEAN_SOLAR_ZENITH_ANGLE') 16 | .sort('MEAN_SOLAR_AZIMUTH_ANGLE') 17 | 18 | 19 | print(images.first()) 20 | 21 | print('Zenith: ', ui.Chart.feature.histogram(images, 'SUN_ELEVATION', 10)) 22 | print('Azimuth: ', ui.Chart.feature.histogram(images, 'SUN_AZIMUTH', 10)) 23 | print('Zenith vs Azimuth: ', ui.Chart.feature.byFeature(images, 'SUN_AZIMUTH', 'SUN_ELEVATION')) 24 | 25 | 26 | -------------------------------------------------------------------------------- /paper-global-reservoirs/surface-area-reconstruction/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015", "stage-0"] 3 | } -------------------------------------------------------------------------------- /paper-global-reservoirs/surface-area-reconstruction/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /paper-global-reservoirs/surface-area-reconstruction/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "surface-area-reconstruction", 3 | "version": "1.0.0", 4 | "description": "Google Earth Engine Playground Code for Multi-mission Surface Area Reconstruction", 5 | "main": "index.js", 6 | "dependencies": { 7 | }, 8 | "devDependencies": { 9 | "babel-cli": "^6.18.0", 10 | "babel-core": "^6.18.2", 11 | "babel-loader": "^6.2.8", 12 | "babel-polyfill": "^6.16.0", 13 | "babel-preset-es2015": "^6.18.0", 14 | "babel-preset-latest": "^6.16.0", 15 | "babel-preset-stage-0": "^6.16.0", 16 | "gulp": "latest", 17 | "gulp-concat": "^2.6.1", 18 | "gulp-babel": "^6.1.2", 19 | "gulp-each": "^0.2.0", 20 | "gulp-git": "^1.12.0", 21 | "gulp-git-push": "^1.0.1", 22 | "merge-stream": "^1.0.1", 23 | "webpack": "^1.13.3" 24 | }, 25 | "scripts": { 26 | "test": "echo \"Error: no test specified\" && exit 1" 27 | }, 28 | "author": "Gennadii Donchyts", 29 | "license": "LGPL-3.0" 30 | } 31 | -------------------------------------------------------------------------------- /paper-global-reservoirs/surface-area-reconstruction/src/algorithms-modis.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gena/ee-code-editor-archive/31346f56ef919f87d29787b227dc1c92531ea889/paper-global-reservoirs/surface-area-reconstruction/src/algorithms-modis.js -------------------------------------------------------------------------------- /paper-global-reservoirs/surface-area-reconstruction/src/algorithms-proba.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gena/ee-code-editor-archive/31346f56ef919f87d29787b227dc1c92531ea889/paper-global-reservoirs/surface-area-reconstruction/src/algorithms-proba.js -------------------------------------------------------------------------------- /paper-global-reservoirs/surface-area-reconstruction/src/scripts/footer.js: -------------------------------------------------------------------------------- 1 | app(); -------------------------------------------------------------------------------- /paper-global-reservoirs/unsorted/s1_entropy.js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var s1 = ee.ImageCollection("COPERNICUS/S1_GRD"), 3 | geometry = /* color: d63000 */ee.Geometry.Point([-120.1523208618164, 39.38207950167204]); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | var start = '2015-03-08' 6 | var stop = '2015-03-10' 7 | 8 | Map.centerObject(geometry, 14) 9 | Map.setOptions('HYBRID') 10 | 11 | var image = ee.Image(s1.filterDate(start, stop).filterBounds(Map.getBounds(true)).filter(ee.Filter.eq('transmitterReceiverPolarisation', 'VV')).first()).select('VV') 12 | 13 | Map.addLayer(image, {min: -20, max:10}, 'before correction') 14 | 15 | // Compute the gray-level co-occurrence matrix (GLCM), get contrast. 16 | var glcm = image.multiply(10).toInt().glcmTexture({size: 4}); 17 | print(glcm) 18 | Map.addLayer(glcm, {bands: 'VV_ent', min: 0, max: 5, palette: ['0000CC', 'CC0000']}, 'entropy'); 19 | 20 | 21 | Map.addLayer(image.mask(glcm.select('VV_ent').gt(0.1)), {min: -20, max:10}, 'after correction') 22 | -------------------------------------------------------------------------------- /paper-global-shoreline/notebooks/water_detection_method.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gena/ee-code-editor-archive/31346f56ef919f87d29787b227dc1c92531ea889/paper-global-shoreline/notebooks/water_detection_method.pdf -------------------------------------------------------------------------------- /thesis/ProsserCreekPCA (copy).js: -------------------------------------------------------------------------------- 1 | /**** Start of imports. If edited, may not auto-convert in the playground. ****/ 2 | var l5 = ee.ImageCollection("LANDSAT/LT5_L1T_TOA"), 3 | l8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"); 4 | /***** End of imports. If edited, may not auto-convert in the playground. *****/ 5 | l8 = l8.filterBounds(Map.getBounds(true)).filterDate('2013-01-01', '2014-01-01') 6 | .map(function(i) { return i.resample('bicubic')}) 7 | 8 | var image = l8.reduce(ee.Reducer.percentile([15])).rename(ee.Image(l8.first()).bandNames()) 9 | 10 | 11 | Map.addLayer(image, {bands:['B6', 'B5', 'B3'], min: 0.03, max:0.5}) 12 | 13 | var ndwi = image.normalizedDifference(['B5', 'B3']) 14 | Map.addLayer(ndwi, {min: -0.5, max:0.5}, 'ndwi') 15 | 16 | var edgeNdwi0 = ndwi.zeroCrossing() 17 | 18 | Map.addLayer(edgeNdwi0.mask(edgeNdwi0), {palette:['ffffff']}, 'ndwi = 0') 19 | 20 | var edge = ee.Algorithms.CannyEdgeDetector(ndwi, 0.4, 0.7) 21 | Map.addLayer(edge.mask(edge), {palette:['ff0000']}, 'ndwi edges') -------------------------------------------------------------------------------- /thesis/ch1_topo_example.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gena/ee-code-editor-archive/31346f56ef919f87d29787b227dc1c92531ea889/thesis/ch1_topo_example.js -------------------------------------------------------------------------------- /urban-lights/draw-test: -------------------------------------------------------------------------------- 1 | 2 | 3 | Map.onClick(function(coords){ 4 | var point = ee.Geometry.Point(coords.lon, coords.lat); 5 | var bounds = Map.getBounds() 6 | var width = bounds[2] - bounds[0] 7 | var scale = Map.getScale() * 22 8 | var circle = point.buffer(scale, scale/32) 9 | Map.addLayer(circle, {}, 'circle') 10 | }) -------------------------------------------------------------------------------- /wri-niger-water/GRDC.js: -------------------------------------------------------------------------------- 1 | var stationsGRDC = ee.FeatureCollection('ft:1sLCtbxs9GWGMWq8JAJL1ivn8lQ5pVuZRdHgRdiSS') 2 | 3 | Map.addLayer(stationsGRDC, {}, 'stations (GRDC)') 4 | 5 | print(stationsGRDC) -------------------------------------------------------------------------------- /wri-niger-water/wflow_assets.js: -------------------------------------------------------------------------------- 1 | var wflow = { 2 | rivers: ee.FeatureCollection('users/gena/water-niger/wflow/rivers'), 3 | riversMask: ee.Image('users/gena/water-niger/wflow/wflow_river'), 4 | catchments: ee.FeatureCollection('users/gena/water-niger/wflow/catchments'), 5 | } 6 | 7 | Map.addLayer(wflow.catchments, {}, 'catchments') 8 | Map.addLayer(wflow.riversMask, { palette: ['yellow'] }, 'rivers (raster)') 9 | Map.addLayer(wflow.rivers.style({ color: 'cyan' }), {}, 'rivers') 10 | --------------------------------------------------------------------------------