In [ ]:
Copied!
# %pip install geoai-py
# %pip install geoai-py
Import library¶
In [ ]:
Copied!
import geoai
import geoai
Create an interactive map¶
In [ ]:
Copied!
m = geoai.Map(center=[47.031260, -99.156360], zoom=14)
m.add_basemap("Esri.WorldImagery")
m
m = geoai.Map(center=[47.031260, -99.156360], zoom=14)
m.add_basemap("Esri.WorldImagery")
m
Use the drawing tool to select an area of interest (AOI) on the map. The selected area will be used to search for NAIP imagery.
In [ ]:
Copied!
if m.user_roi is not None:
bbox = m.user_roi_bounds()
else:
bbox = [-99.1705, 47.0149, -99.1296, 47.0365]
if m.user_roi is not None:
bbox = m.user_roi_bounds()
else:
bbox = [-99.1705, 47.0149, -99.1296, 47.0365]
Search for NAIP imagery¶
In [ ]:
Copied!
items = geoai.pc_stac_search(
collection="naip",
bbox=bbox,
)
items = geoai.pc_stac_search(
collection="naip",
bbox=bbox,
)
In [ ]:
Copied!
items
items
Visualize the search results¶
In [ ]:
Copied!
geoai.view_pc_items(items=items)
geoai.view_pc_items(items=items)
Download NAIP imagery¶
In [ ]:
Copied!
geoai.pc_stac_download(items, output_dir="naip", assets=["image"])
geoai.pc_stac_download(items, output_dir="naip", assets=["image"])
Object detection¶
In [ ]:
Copied!
geoai.object_detection_batch(
input_paths="naip",
output_dir="water",
model_path="water_detection.pth",
window_size=512,
overlap=128,
confidence_threshold=0.5,
batch_size=4,
num_channels=4,
)
geoai.object_detection_batch(
input_paths="naip",
output_dir="water",
model_path="water_detection.pth",
window_size=512,
overlap=128,
confidence_threshold=0.5,
batch_size=4,
num_channels=4,
)
Convert raster to vector¶
In [ ]:
Copied!
geoai.raster_to_vector_batch(
input_dir="water", output_dir="vector", min_area=100, simplify_tolerance=1
)
geoai.raster_to_vector_batch(
input_dir="water", output_dir="vector", min_area=100, simplify_tolerance=1
)