117 fishnet
Creating a fishnet based on an input vector dataset
Uncomment the following line to install geemap if needed.
In [ ]:
Copied!
# !pip install -U geemap
# !pip install -U geemap
In [ ]:
Copied!
import ee
import geemap
import ee
import geemap
In [ ]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
Simply draw a rectangle or polyon on the map use to used as an ROI.
In [ ]:
Copied!
data = Map.user_roi
if data is None:
data = ee.Geometry.BBox(-112.8089, 33.7306, -88.5951, 46.6244)
Map.addLayer(data, {}, 'ROI')
Map.user_roi = None
Map.centerObject(data)
data = Map.user_roi
if data is None:
data = ee.Geometry.BBox(-112.8089, 33.7306, -88.5951, 46.6244)
Map.addLayer(data, {}, 'ROI')
Map.user_roi = None
Map.centerObject(data)
The input data can also be a file path or HTTP URL to a vector dataset. There are two ways to create a fishnet: specifying horizontal and vertical intervals or the number of rows and columns.
Let's create a fishnet by specifying horizontal and vertical intervals in degrees.
In [ ]:
Copied!
fishnet = geemap.fishnet(data, h_interval=2.0, v_interval=2.0, delta=1)
fishnet = geemap.fishnet(data, h_interval=2.0, v_interval=2.0, delta=1)
In [ ]:
Copied!
Map.addLayer(fishnet, {}, 'Fishnet 1')
Map.addLayer(fishnet, {}, 'Fishnet 1')
Draw another polygon on the map.
In [ ]:
Copied!
data = Map.user_roi
if data is None:
data = ee.Geometry.Polygon(
[
[
[-64.602356, -1.127399],
[-68.821106, -12.625598],
[-60.647278, -22.498601],
[-47.815247, -21.111406],
[-43.860168, -8.913564],
[-54.582825, -0.775886],
[-60.823059, 0.454555],
[-64.602356, -1.127399],
]
]
)
Map.addLayer(data, {}, 'ROI2')
Map.centerObject(data)
Map
data = Map.user_roi
if data is None:
data = ee.Geometry.Polygon(
[
[
[-64.602356, -1.127399],
[-68.821106, -12.625598],
[-60.647278, -22.498601],
[-47.815247, -21.111406],
[-43.860168, -8.913564],
[-54.582825, -0.775886],
[-60.823059, 0.454555],
[-64.602356, -1.127399],
]
]
)
Map.addLayer(data, {}, 'ROI2')
Map.centerObject(data)
Map
Let's create another fishnet by specifying the number of rows and columns.
In [ ]:
Copied!
fishnet = geemap.fishnet(data, rows=6, cols=8, delta=1)
fishnet = geemap.fishnet(data, rows=6, cols=8, delta=1)
In [ ]:
Copied!
Map.addLayer(fishnet, {}, 'Fishnet 2')
Map.addLayer(fishnet, {}, 'Fishnet 2')