Skip to content
Snippets Groups Projects
Commit 5d1e302c authored by Farzaneh-prime's avatar Farzaneh-prime
Browse files

lesson numbers corrected

parent 9a434404
No related branches found
No related tags found
No related merge requests found
<p style="text-align: justify;">Welcome to the Smart Data coding course, where you'll unlock vital spatial coding skills that will empower your journey and open new horizons. To be able to follow through the chapters of this course, a few technical prerequisites must be followed. In detail, we need to install Python, the coding language we will use, Jupyter Lab/Notebook, our IDE (or integrated development environment) of choice, and a few Python libraries along the way, that can be seen as add-ons to what Python can do with our commands.</p>
<p style="text-align: justify;">Welcome to part one of the Smart Data coding course "Python and Earth Observation Data", where you'll unlock vital spatial coding skills that will empower your journey and open new horizons. To be able to follow through the chapters of this course, a few technical prerequisites must be followed. In detail, we need to install Python, the coding language we will use, Jupyter Lab/Notebook, our IDE (or integrated development environment) of choice, and a few Python libraries along the way, that can be seen as add-ons to what Python can do with our commands.</p>
<p style="text-align: justify;">💡If you are taking this course directly from the NFDI4Earth educational portal, you will work with a dedicated Jupyter Lab workspace that is already set up with all necessary libraries and data. This means you can bypass installing Python or Jupyter locally on your computer. Instead, simply log into the portal, and you’ll be ready to jump right into the coding. However, if you prefer to set up your own environment for practice or future use, follow the instructions below.</p>
<h3 style="text-align: justify;">📖Choosing a path</h3>
<p style="text-align: justify;">When installing Python and Jupyter Lab (and other packages), you can either use your native system or create a<strong> virtual environment</strong>, which gives you the ability to create an isolated environment on your machine from where you can start your projects. The big advantage here is that some libraries have dependencies on what is installed and how – and a virtual environment gives you the ability to install or deinstall everything as you go, or just start over if everything goes south. <strong>It is therefore recommended that a virtual environment be created and the needed libraries installed there</strong>. You can use Anaconda Navigator to do this. It is software you can use to avoid typing commands in a command box but instead manage environments and libraries in an easy-to-use user interface. Visit <a href="https://docs.anaconda.com/navigator/" target="_blank" rel="noopener">Anaconda Navigator</a> and its <a href="https://docs.anaconda.com/navigator/tutorials/manage-environments/" target="_blank" rel="noopener">doc </a>for Managing Environments to get more information on how to set up a virtual environment.</p>
......
%% Cell type:markdown id:f42c0ae8 tags:
### 📖Feature Collection Basics
In this chapter, you will learn how to filter / select features of a feature collection in Google Earth Engine using Python in Jupyter Notebook.
%% Cell type:markdown id:6410c599 tags:
Import necessary modules and authenticate the google-access (with a token, if needed).
%% Cell type:code id:cc3faf61 tags:
``` python
!mamba env create -f smart_data.yml
```
%% Cell type:code id:ea742ffb tags:
``` python
import ee
import geemap
```
%% Output
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[3], line 1
----> 1 import ee
2 import geemap
ModuleNotFoundError: No module named 'ee'
%% Cell type:code id:692c99df tags:
``` python
import ee
ee.Authenticate()
```
%% Cell type:code id:ca054848 tags:
``` python
ee.Authenticate()
ee.Initialize()
```
%% Cell type:code id:b7ad7048 tags:
``` python
Map = geemap.Map() # sets a variable to open the GEE Map
```
%% Cell type:code id:5aaa8fa6 tags:
``` python
Map # opens the interactive map
```
%% Cell type:markdown id:f3006eb4 tags:
Get some data to display
The "ee.FeatureCollection('TIGER/2018/States')" is a dataset, which lies on the google servers. See Google datacatalog for more data: https://developers.google.com/earth-engine/datasets
%% Cell type:code id:980d31a9 tags:
``` python
states = ee.FeatureCollection('TIGER/2018/States') # defining a "states" variable
Map.addLayer(states, {}, "US States") # add the layer of the variable
```
%% Cell type:code id:4840f85c tags:
``` python
tx = states.filter(ee.Filter.eq("NAME", "Texas")) # filter the feature collection "states" for a state: Texas
Map.addLayer(tx, {}, "Texas") # add the layer of the filtered feature
```
%% Cell type:code id:d1023e53 tags:
``` python
ca = states.filter(ee.Filter.eq("NAME", "California")) # do it again for another state
Map.addLayer(ca, {}, "California") # add the layer of another feature
```
%% Cell type:markdown id:6512cac0 tags:
Before executing the next 3 cells, **use one of the drawing tools from the left side bar ("Draw a Polygon", "Draw a Rectangle" etc.) and draw a shape on the map.**
The command "Map.user_roi" will select your drawn shape
%% Cell type:code id:6f6525fa tags:
``` python
roi = Map.user_roi # setup a region of interest which you would like to filter features of
```
%% Cell type:code id:ada1c28b tags:
``` python
selected = states.filterBounds(roi) # define a new variable to add the layer of the filtered features
```
%% Cell type:code id:4806b60c tags:
``` python
Map.addLayer(selected, {}, "US South") # add the feature-layer
```
%% Cell type:code id:8ded2205 tags:
``` python
west = states.filter(ee.Filter.inList("NAME", ["Utah", "Colorado"])) # choose some features to display them at once
```
%% Cell type:code id:e03950c3 tags:
``` python
Map.addLayer(west, {}, "US West") # add the layer displaying the western states of the US
```
%% Cell type:markdown id:67395e43 tags:
If you run everything, you can adjust the opacity and the general display of every layer in the top right corner.
There also is the inspector feature for more information.
%% Cell type:code id:33046abe tags:
``` python
# Remove not selected features or layers from the map
Map.remove_drawn_features()
Map.remove_ee_layer("US States")
```
......
......@@ -135,7 +135,7 @@ dependencies:
- libgdal=3.2.2=ha6cada3_7
- libglib=2.68.3=h1e62bf3_0
- libiconv=1.16=he774522_0
- libkml=1.3.0=h9859afa_1013
- libkml=1.3.0
- liblapack=3.9.0=9_mkl
- libnetcdf=4.8.0=nompi_hf689e7d_103
- libpng=1.6.37=h1d00b33_2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment