Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added vector datasets catalog
- Loading branch information
Showing
18 changed files
with
385 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/global_land_ice_measurements.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('GLIMS/current') | ||
visParams = { | ||
'palette': ['gray', 'cyan', 'blue'], | ||
'min': 0.0, | ||
'max': 10.0, | ||
'opacity': 0.8, | ||
} | ||
|
||
image = ee.Image().float().paint(dataset, 'area') | ||
Map.setCenter(-35.618, 66.743, 7) | ||
Map.addLayer(image, visParams, 'GLIMS/current') | ||
# Map.addLayer(dataset, {}, 'for Inspector', False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/global_power_plant_database.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
# Visualization for WRI/GPPD/power_plants | ||
# https:#code.earthengine.google.com/9efbd726e4a8ba9b8b56ba94f1267678 | ||
|
||
table = ee.FeatureCollection("WRI/GPPD/power_plants") | ||
|
||
# Get a color from a fuel | ||
fuelColor = ee.Dictionary({ | ||
'Coal': '000000', | ||
'Oil': '593704', | ||
'Gas': 'BC80BD', | ||
'Hydro': '0565A6', | ||
'Nuclear': 'E31A1C', | ||
'Solar': 'FF7F00', | ||
'Waste': '6A3D9A', | ||
'Wind': '5CA2D1', | ||
'Geothermal': 'FDBF6F', | ||
'Biomass': '229A00' | ||
}) | ||
|
||
# List of fuels to add to the map | ||
fuels = ['Coal', 'Oil', 'Gas', 'Hydro', 'Nuclear', 'Solar', 'Waste', | ||
'Wind', 'Geothermal', 'Biomass'] | ||
|
||
# /** | ||
# * Computes size from capacity and color from fuel type. | ||
# * | ||
# * @param {!ee.Geometry.Point} pt A point | ||
# * @return {!ee.Geometry.Point} Input point with added style dictionary. | ||
# */ | ||
def addStyle(pt): | ||
size = ee.Number(pt.get('capacitymw')).sqrt().divide(10).add(2) | ||
color = fuelColor.get(pt.get('fuel1')) | ||
return pt.set('styleProperty', ee.Dictionary({'pointSize': size, 'color': color})) | ||
|
||
|
||
# Make a FeatureCollection out of the power plant data table | ||
pp = ee.FeatureCollection(table).map(addStyle) | ||
# print(pp.first()) | ||
|
||
# /** | ||
# * Adds power plants of a certain fuel type to the map. | ||
# * | ||
# * @param {string} fuel A fuel type | ||
# */ | ||
def addLayer(fuel): | ||
# print(fuel) | ||
Map.addLayer(pp.filter(ee.Filter.eq('fuel1', fuel)).style({'styleProperty': 'styleProperty', 'neighborhood': 50}), {}, fuel, True, 0.65) | ||
|
||
|
||
# Apply `addLayer` to each record in `fuels` | ||
for fuel in fuels: | ||
Map.addLayer(pp.filter(ee.Filter.eq('fuel1', fuel)).style(**{'styleProperty': 'styleProperty', 'neighborhood': 50}), {}, fuel, True, 0.65) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/landsat_wrs2_grid.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('projects/google/wrs2_descending') | ||
|
||
empty = ee.Image().byte() | ||
|
||
Map.setCenter(-78, 36, 8) | ||
Map.addLayer(empty.paint(dataset, 0, 2), {}, 'Landsat WRS-2 grid') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/resolve_ecoregions.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
|
||
def set_color(f): | ||
c = ee.String(f.get('COLOR')).slice(1) | ||
return f \ | ||
.set('R', ee.Number.parse(c.slice(0, 2), 16)) \ | ||
.set('G', ee.Number.parse(c.slice(2, 4), 16)) \ | ||
.set('B', ee.Number.parse(c.slice(4, 6), 16)) | ||
|
||
|
||
fc = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017') \ | ||
.map(lambda f: set_color(f)) | ||
|
||
base = ee.Image(0).mask(0).toInt8() | ||
Map.addLayer(base.paint(fc, 'R') | ||
.addBands(base.paint(fc, 'G') | ||
.addBands(base.paint(fc, 'B'))), {'gamma': 0.3}) | ||
|
||
|
||
|
||
# # Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions. | ||
# ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017') | ||
|
||
# # Display as default and with a custom color. | ||
# Map.addLayer(ecoregions, {}, 'default display', False) | ||
# Map.addLayer(ecoregions, {'color': 'FF0000'}, 'colored', False) | ||
|
||
|
||
# Map.addLayer(ecoregions.draw(**{'color': '006600', 'strokeWidth': 5}), {}, 'drawn', False) | ||
|
||
|
||
# # Create an empty image into which to paint the features, cast to byte. | ||
# empty = ee.Image().byte() | ||
|
||
# # Paint all the polygon edges with the same number and 'width', display. | ||
# outline = empty.paint(**{ | ||
# 'featureCollection': ecoregions, | ||
# 'color': 1, | ||
# 'width': 3 | ||
# }) | ||
# Map.addLayer(outline, {'palette': 'FF0000'}, 'edges') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/us_census_blocks.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('TIGER/2010/Blocks') | ||
visParams = { | ||
'min': 0.0, | ||
'max': 700.0, | ||
'palette': ['black', 'brown', 'yellow', 'orange', 'red'] | ||
} | ||
|
||
# Turn the strings into numbers | ||
dataset = dataset.map(lambda f: f.set('pop10', ee.Number.parse(f.get('pop10')))) | ||
|
||
image = ee.Image().float().paint(dataset, 'pop10') | ||
|
||
Map.setCenter(-73.99172, 40.74101, 13) | ||
Map.addLayer(image, visParams, 'TIGER/2010/Blocks') | ||
# Map.addLayer(dataset, {}, 'for Inspector', False) |
2 changes: 2 additions & 0 deletions
2
Datasets/us_counties.py → Datasets/Vectors/us_census_counties.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Datasets/tiger_datasets.py → Datasets/Vectors/us_census_datasets.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Datasets/census_roads.py → Datasets/Vectors/us_census_roads.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/us_census_tracts.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('TIGER/2010/Tracts_DP1') | ||
visParams = { | ||
'min': 0, | ||
'max': 4000, | ||
'opacity': 0.8, | ||
} | ||
|
||
# Turn the strings into numbers | ||
dataset = dataset.map(lambda f: f.set('shape_area', ee.Number.parse(f.get('dp0010001')))) | ||
|
||
# Map.setCenter(-103.882, 43.036, 8) | ||
image = ee.Image().float().paint(dataset, 'dp0010001') | ||
|
||
Map.addLayer(image, visParams, 'TIGER/2010/Tracts_DP1') | ||
# Map.addLayer(dataset, {}, 'for Inspector', False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/us_census_zip_code.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('TIGER/2010/ZCTA5') | ||
visParams = { | ||
'palette': ['black', 'purple', 'blue', 'green', 'yellow', 'orange', 'red'], | ||
'min': 500000, | ||
'max': 1000000000, | ||
} | ||
|
||
zctaOutlines = ee.Image().float().paint(**{ | ||
'featureCollection': dataset, | ||
'color': 'black', | ||
'width': 1 | ||
}) | ||
|
||
image = ee.Image().float().paint(dataset, 'ALAND10') | ||
# Map.setCenter(-93.8008, 40.7177, 6) | ||
Map.addLayer(image, visParams, 'TIGER/2010/ZCTA5') | ||
Map.addLayer(zctaOutlines, {}, 'borders') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/us_epa_ecoregions.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('EPA/Ecoregions/2013/L3') | ||
visParams = { | ||
'palette': ['0a3b04', '1a9924', '15d812'], | ||
'min': 23.0, | ||
'max': 3.57e+11, | ||
'opacity': 0.8, | ||
} | ||
image = ee.Image().float().paint(dataset, 'shape_area') | ||
Map.setCenter(-99.814, 40.166, 5) | ||
Map.addLayer(image, visParams, 'EPA/Ecoregions/2013/L3') | ||
# Map.addLayer(dataset, {}, 'for Inspector', False) | ||
|
||
|
||
dataset = ee.FeatureCollection('EPA/Ecoregions/2013/L4') | ||
visParams = { | ||
'palette': ['0a3b04', '1a9924', '15d812'], | ||
'min': 0.0, | ||
'max': 67800000000.0, | ||
'opacity': 0.8, | ||
} | ||
image = ee.Image().float().paint(dataset, 'shape_area') | ||
Map.setCenter(-99.814, 40.166, 5) | ||
Map.addLayer(image, visParams, 'EPA/Ecoregions/2013/L4') | ||
# Map.addLayer(dataset, {}, 'for Inspector', False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/usgs_watershed_boundary.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('USGS/WBD/2017/HUC02') | ||
styleParams = { | ||
'fillColor': '000070', | ||
'color': '0000be', | ||
'width': 3.0, | ||
} | ||
regions = dataset.style(**styleParams) | ||
Map.setCenter(-96.8, 40.43, 4) | ||
Map.addLayer(regions, {}, 'USGS/WBD/2017/HUC02') | ||
|
||
|
||
dataset = ee.FeatureCollection('USGS/WBD/2017/HUC04') | ||
styleParams = { | ||
'fillColor': '5885E3', | ||
'color': '0000be', | ||
'width': 3.0, | ||
} | ||
subregions = dataset.style(**styleParams) | ||
Map.setCenter(-110.904, 36.677, 7) | ||
Map.addLayer(subregions, {}, 'USGS/WBD/2017/HUC04') | ||
|
||
|
||
dataset = ee.FeatureCollection('USGS/WBD/2017/HUC06') | ||
styleParams = { | ||
'fillColor': '588593', | ||
'color': '587193', | ||
'width': 3.0, | ||
} | ||
basins = dataset.style(**styleParams) | ||
Map.setCenter(-96.8, 40.43, 7) | ||
Map.addLayer(basins, {}, 'USGS/WBD/2017/HUC06') | ||
|
||
|
||
dataset = ee.FeatureCollection('USGS/WBD/2017/HUC08') | ||
styleParams = { | ||
'fillColor': '2E8593', | ||
'color': '587193', | ||
'width': 2.0, | ||
} | ||
subbasins = dataset.style(**styleParams) | ||
Map.setCenter(-96.8, 40.43, 8) | ||
Map.addLayer(subbasins, {}, 'USGS/WBD/2017/HUC08') | ||
|
||
|
||
dataset = ee.FeatureCollection('USGS/WBD/2017/HUC10') | ||
styleParams = { | ||
'fillColor': '2E85BB', | ||
'color': '2E5D7E', | ||
'width': 1.0, | ||
} | ||
watersheds = dataset.style(**styleParams) | ||
Map.setCenter(-96.8, 40.43, 9) | ||
Map.addLayer(watersheds, {}, 'USGS/WBD/2017/HUC10') | ||
|
||
|
||
dataset = ee.FeatureCollection('USGS/WBD/2017/HUC12') | ||
styleParams = { | ||
'fillColor': '2E85BB', | ||
'color': '2E5D7E', | ||
'width': 0.1, | ||
} | ||
subwatersheds = dataset.style(**styleParams) | ||
Map.setCenter(-96.8, 40.43, 10) | ||
Map.addLayer(subwatersheds, {}, 'USGS/WBD/2017/HUC12') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# GitHub URL: https://github.com/giswqs/qgis-earthengine-examples/tree/master/Datasets/Vectors/world_database_on_protected_areas.py | ||
|
||
import ee | ||
from ee_plugin import Map | ||
|
||
dataset = ee.FeatureCollection('WCMC/WDPA/current/polygons') | ||
visParams = { | ||
'palette': ['2ed033', '5aff05', '67b9ff', '5844ff', '0a7618', '2c05ff'], | ||
'min': 0.0, | ||
'max': 1550000.0, | ||
'opacity': 0.8, | ||
} | ||
image = ee.Image().float().paint(dataset, 'REP_AREA') | ||
Map.setCenter(41.104, -17.724, 6) | ||
Map.addLayer(image, visParams, 'WCMC/WDPA/current/polygons') | ||
# Map.addLayer(dataset, {}, 'for Inspector', False) | ||
|
||
|
||
dataset = ee.FeatureCollection('WCMC/WDPA/current/points') | ||
styleParams = { | ||
'color': '#4285F4', | ||
'width': 1, | ||
} | ||
protectedAreaPoints = dataset.style(**styleParams) | ||
# Map.setCenter(110.57, 0.88, 4) | ||
Map.addLayer(protectedAreaPoints, {}, 'WCMC/WDPA/current/points') |
Oops, something went wrong.