One-click Digitizing in QGIS: Use Segmentation and GeoAI to SAVE TIME with the Geo-SAM Plugin!
Jul 14, 2025
Install and use the QGIS Geo-SAM plugin to digitize features in just one click! Geo-SAM uses the Segment Anything Model to encode and segment imagery with a few easy clicks. This is a huge time-saver for anyone who does a lot of manual digitizing! How to install QGIS: https://youtu.be/eAJZRFHkXEY QGSI Geo-SAM plugin documentation: https://geo-sam.readthedocs.io/en/latest/installation.html Check out my website for more: https://opensourceoptions.com
View Video Transcript
0:00
Hi folks, welcome to open source
0:02
options. Today I want to show you how
0:05
you can easily segment or digitize
0:09
features in QGIS using some geo
0:13
specifically using the segment anything
0:16
model that's adapted for geospatial
0:19
imagery. And to give you an idea of what
0:21
I'm talking about, let's go ahead and
0:24
just take a look here. If I zoom in here
0:26
on this area, you can see there are some
0:28
rocks. If I come into my geo my geio sam
0:32
tool. We'll use the geio sam plugin. I
0:34
have some different options for doing
0:36
this. I can use these points here. I can
0:38
click on a object and you can see that
0:41
it gets segmented just like that. I can
0:44
go back and clear those. Once I add that
0:46
in, I can save it and I can digitize
0:50
these rocks very very easily just with a
0:54
single click of a button. So, it's super
0:56
easy to do and I want to show you how
0:58
you can do that here in this video. So,
1:02
the first thing we're going to do is
1:03
we're going to show you how to install
1:05
this plugin because it can be a little
1:07
involved. The next thing we have to do
1:10
is we have to encode the imagery. We
1:12
can't just use the imagery we have. We
1:13
have take that imagery, run it through
1:15
an encoding process so the model works
1:18
on it, and then we can do this very
1:20
simple one-click digitizing. So, let's
1:23
go ahead and get started.
1:25
The first thing that we need to do is we
1:28
need to go find the Gio SAM QGIS plugin
1:33
and we're going to look at this
1:34
documentation.
1:35
I'm going to come down to read the docs
1:37
here. Um, and I'll put this link for you
1:39
in the description so you can just click
1:41
right on it. But we're going to have to
1:44
follow this installation exactly. It's
1:45
going to be a little more involved than
1:48
some of the installations you may have
1:51
done. Now, I want to make sure that I
1:55
list something important here, and that
1:57
is to do it the way I'm going to show
1:59
you. You need to have installed QGIS
2:02
using the OSGO4W
2:05
network installer. And I have a video
2:07
that shows you exactly how to do that.
2:09
It's my preferred way to install QGIS.
2:13
and it's going to give you the OSG4W
2:16
command prompt that we can then use to
2:18
update the QGIS Python installation.
2:22
We'll need to add some packages to that
2:24
installation for this plug-in to work.
2:26
It's really easy to do, but if you don't
2:29
have QGIS installed the way that the
2:31
video I've linked below, my QGIS
2:33
installation video, if you don't have it
2:35
installed the way that shows, you're
2:36
going to have some issues. So, the first
2:39
thing we're going to do is we're going
2:40
to open the OSG04W shell as an
2:44
administrator. Now, it's possible that
2:47
if you've installed this uh using just
2:49
the standalone installer uh that that
2:52
you'll be okay, I would recommend
2:54
installing it the way I've shown you
2:56
just because it makes things so much
2:58
easier and you know you've done it the
2:59
right way. So, let's go ahead and I'm
3:01
going to come down here and I'm going to
3:02
search for OSG4W shell. You can see that
3:06
here. I'm going to write I'm just gonna
3:08
we can open this or open as
3:10
administrator. The way I've installed
3:12
mine um I can just open it like this and
3:14
we'll be okay. That's going to pull up a
3:18
command prompt like so. Now you can see
3:21
here we have two versions to install.
3:23
There's a GPU version. Um not everyone
3:26
has a GPU. Um so I'm going to go through
3:29
the CPU version. The CPU version is also
3:32
less involved. The downside is that
3:34
you're going to it's going to be much
3:36
slower to encode the images. Okay. So,
3:39
if you want to have fast image encoding
3:41
and you have a GPU, you can follow this
3:45
version. You need to make sure you
3:46
install the CUDA toolkit properly. Uh,
3:50
which there are tutorials out there for
3:51
how to do that. Let's go with the CPU
3:53
version. We're going to grab this line
3:56
of code. Actually, I'm going to just
3:57
grab from install over here.
4:01
I'm going to copy that. I'm going to go
4:04
back to my command prompt, my OSG4W
4:09
shell. Oh, I have two open. I'm just
4:10
going to close this other one so it's
4:12
out of the way. And I'm going to type
4:13
pip, which is the Python install
4:16
package. And I'm going to in paste this
4:19
in. So, I want to install these
4:20
packages. And I'm going to hit enter.
4:23
Now, when this runs for me, you're going
4:25
to see a different output because I've
4:26
installed these packages already. um it
4:29
will go through and it will install all
4:31
those packages for you and it will put
4:33
them on your QGIS Python installation
4:36
which is where you need them. All right,
4:38
once you have that, this is for Windows
4:40
users here. If you're using Mac or
4:42
Linux, you can see uh the other
4:45
instructions here. It is just maybe a
4:47
little more involved, but you can do
4:49
that there.
4:51
Now, the next thing is to install the
4:53
Geo SAM plugin. So on Windows, I want to
4:57
go to the path where my QGIS plugins are
5:00
going to be installed.
5:02
And I can do that by copying this path
5:05
here and opening up
5:09
uh my file explorer. And here I'm going
5:12
to p paste in that path and hit enter.
5:16
And you can see it takes me there. So
5:18
I'm in my app data QGIS QGIS3 profiles
5:22
default Python plugins. And you can see
5:25
here these are the plugins that I have
5:27
installed and I don't have that plugin
5:30
installed. Even though I have installed
5:32
the Python packages that it
5:34
dependencies, I have not installed the
5:36
plugin. That's what we'll do next. So
5:39
here um I'm going to come and I'm going
5:43
to download this file. Now
5:47
I'm going to click
5:50
um here to go to a new tab. We'll open
5:55
this in a new tab. Um we'll go to GitHub
5:57
to show where this release is. And so we
6:00
can see the latest release here. It's a
6:03
stable release version 1.3.2.
6:06
And if I scroll down, you can see the
6:09
code we have here.
6:12
Now there are three things. There's a
6:15
tar.gz GZ, a zip, and an update.zip.
6:19
I'm going to start by downloading the
6:21
source code.zip.
6:26
Let's save that.
6:30
It might take just a minute here. I'm
6:32
also going to get the code update.
6:34
Notice this is published later. Um, and
6:36
I just want to make sure I have the
6:37
latest code. And I'll show you how to
6:38
make sure we have everything updated.
6:41
Okay. So, I'm going to save that.
6:44
Now I'm going to show this uh in the
6:47
folder which is in downloads. Actually
6:48
if I go to my downloads folder here I
6:51
have downloads here. We can refresh this
6:54
and you can see we have this GIOSM 1.3.2
6:58
and the GIOSAM code update. I'm just
7:01
going to grab these and copy them over
7:03
into my plugins folder to make them
7:05
easier to work with. You can download
7:07
them directly here if you would like to.
7:10
Now I'm going to right click here and uh
7:13
I'm going to use sevenzip and I'm going
7:15
to go show more options sevenzip. I'm
7:18
going to extract here.
7:22
But now this is going to be important.
7:24
You want to make sure that you have this
7:27
structure. So when you click into this,
7:30
you want to see these files immediately.
7:32
Oops. When you click into the unzipped
7:36
or unpackaged folder, you want to see
7:38
this file structure here immediately and
7:40
not listed under a subfolder. If they're
7:43
listed under a subfolder, you can just
7:44
copy and paste or change your extraction
7:46
method to get it in this format. Now,
7:49
the next important thing is to change
7:52
this file name so that it is just gio
7:55
without the version number. Okay, so we
7:58
have that there. I'm going to delete
8:00
this folder to clean things up. Now, the
8:03
next thing is to update the code. So,
8:06
I'm going to right click here, do the
8:08
same thing. I'm going to click on show
8:09
more options, going to do sevenzip, and
8:12
you can install sevenzip for Windows for
8:14
free. And I'm going to click extract
8:16
here.
8:18
And now I get this notice that it's
8:20
going to overwrite files. And I do want
8:23
to overwrite the files. Okay. Okay. It
8:26
says, "Would you like to replace an
8:27
existing file with a new file?" And I'm
8:29
going to say yes to all. And that will
8:32
give me the update.
8:35
If you don't rename this file, it's not
8:37
going to give you the update. It will
8:38
just put these in a new Gio SAM folder.
8:42
Okay. So now that's going to be updated.
8:44
So I can click here and delete this. Now
8:47
I'm going to open QGIS. And when I do
8:49
that, this new plugin,
8:52
the geo sound plugin will be available
8:55
for me. So, I'll just pause for a second
8:57
while uh QGIS opens up.
9:02
Okay, QGIS is open. Let's go into
9:05
plugins, manage, and install plugins.
9:10
If I click on the install tab,
9:13
you will notice that I have geos right
9:16
here. Yours may be clicked off, but if
9:19
you go ahead and click that on, make
9:21
sure that it's activated and then you
9:23
can click close. And what happens is
9:26
once you've done that, you will see
9:27
these three
9:30
uh icons appear on the toolbar.
9:35
Now, we can also access this from
9:38
plugins, geos tools. We have
9:40
segmentation, image encoder, and the
9:43
encoder co-pilot. We're just going to
9:46
use the image encoder and the
9:47
segmentation options today. The first
9:50
one we want to use is the image encoder
9:52
which we can access here or from the
9:55
toolbar. And what this will do is we'll
9:57
take an image and encode it so we can
9:59
then segment it. Let's go ahead and let
10:02
me find the image I would like to encode
10:06
to start out here. Uh, I believe I have
10:09
one
10:10
in my downloads.
10:17
And let me just
10:20
make sure I can find that real quick.
10:23
It's not in my downloads. It's here in
10:25
the surfaces folder. I'm just going to
10:26
pull this one in like that.
10:29
And you can see that image here. It's uh
10:32
up this creek. Now, I'm not going to
10:35
encode this whole image because it would
10:37
take a very long time, but I will show
10:39
you how to do this for a portion of the
10:40
image. I'm going to come and click on
10:43
the image encoder here.
10:45
It gives me this prompt. It asks for the
10:48
input raster. I then need to select some
10:51
bands. I'm going to select bands one,
10:53
two, and three for red, green, and blue.
10:55
Band four uh is not an alpha band. It's
10:58
something else. We're not going to worry
11:00
about that now. And I will click okay.
11:03
Now the processing extent I don't want
11:05
to process this whole image. It would
11:06
take a very long time with the CPU. I'm
11:09
going to draw on the map canvas to do a
11:12
very small portion uh of this. And what
11:16
I'm going to do is just this portion of
11:18
the image right here.
11:22
And the next thing I need to do is go
11:25
back to the documentation to show you
11:26
something important that we have not
11:28
addressed yet. Um, we need to go back to
11:32
the documentation on the installation.
11:35
So, we've downloaded and configured the
11:37
folder. We have the plug-in folder
11:40
configured. As I showed you, we just
11:41
need to make sure that we have the
11:42
proper file structure. We have activated
11:45
the plugin. Now, we can go over to the
11:48
usage of the geoam tools. Now, we want
11:51
to go over and start with the image
11:53
encoder. So, we're going to click on the
11:55
image encoder option here.
11:58
And you'll notice to do this, we need to
12:00
download the SAM checkpoints. So these
12:02
are the segment anything model models.
12:06
And I recommend starting out with this
12:07
model here, the large model. Okay, so
12:10
you want to use uh the base model you
12:12
can use for coarser imagery. The large
12:14
is a good place to start. And the huge
12:16
is going to be best if you want to get a
12:18
lot of detail. So you can play around
12:20
with these. We need to download these
12:22
and point uh our plugin to them. So, I'm
12:25
going to just click on this one and
12:27
redownload to show you what it's like.
12:29
So, I'll redownload that so you can see
12:31
that I'm doing it the same way you will
12:33
do it. And as we go to the image encoder
12:36
back in QGIS,
12:38
um it's going to ask us for the SAM
12:41
checkpoint path. And that is what we are
12:44
downloading right now. I just received
12:47
the notice that my uh model checkpoint
12:50
was downloaded. I'm going to go
12:51
reference that here. Now, click here.
12:54
I'll go to my downloads. I just click on
12:56
that model checkpoint and click open.
12:59
And then here I need to make sure I
13:01
select the proper option. I downloaded
13:03
the large model here, the VIT_L.
13:06
So I need to select that here. I'm going
13:09
to turn off use GPU if CUDA is available
13:11
because I did not install a dependencies
13:13
and I don't want there to be any
13:14
confusion.
13:16
Next, I'm going to load the output
13:17
features in the geo sam pool after
13:20
processing. And then here, this is where
13:22
the model features, the image features,
13:24
the encoded features will be saved. So
13:27
I'm going to come and just change this.
13:29
I'm going to save to a directory and I'm
13:32
going to
13:34
make a new folder and I'm going to call
13:36
this uh my test features.
13:41
We have a let's go up a level.
13:46
Let me delete this folder. I don't want
13:48
to put it here.
13:51
Let's go up a level and let's make a new
13:53
folder and we'll call this the test
13:55
features.
13:57
So, we'll select this test features
13:58
folder. This will save it in your
14:00
plugins directory if you don't do that.
14:02
So, you don't need to do this, but I
14:03
just want in a place I can easily find
14:05
it and delete it if I want to. And now I
14:08
will click run.
14:10
And this will start encoding
14:14
um the images. It will take some time.
14:18
Um, depending on the size you do, it can
14:21
take um, from a few minutes to several
14:23
hours. So, I'm going to pause this while
14:26
it finishes encoding. You can see we're
14:27
at 8% completed here. Um, and I will
14:32
pause that. Now,
14:35
you can get an idea for how long this
14:37
will take by the total batch number.
14:39
Here you can see there are 12 batches.
14:41
We've completed four of the 12 or we're
14:44
working on four of 12. So when this
14:45
completes, we should be at 33%
14:48
done. And we are. And I'll come back
14:50
with you once this is all finished
14:52
encoding.
14:54
Okay. So our image is finished encoding.
14:57
I can close this now. And now I can open
15:01
up the segmentation
15:03
uh tool. So let's go segmentation. Now,
15:06
you'll notice when I open this up, it
15:08
added in this test image, this demo
15:11
image. I can adjust this by going to
15:14
options
15:16
and turning off the load demo image.
15:20
And then I can remove this image.
15:24
Let's uh remove that layer.
15:27
And let's zoom to this layer.
15:32
There we go. And now when I show the
15:35
boundary, it didn't show up there.
15:38
That's okay. But we can go to our IO
15:42
paths. And here I want to select this
15:46
where I saved those images. So I can
15:48
come here and I can browse. Um I put
15:52
this. You'll notice here that in geos
15:53
features that this path here in my
15:56
plugins, that's where I saved that. So,
15:58
if you just select the default path, you
16:01
go there, go to your your GEOSM uh
16:04
plug-in location in your app data
16:07
folder, you can find your features
16:09
there. I put mine in downloads and in
16:13
test features
16:15
and it went into here. So, I can select
16:17
that folder
16:19
and now I can load that.
16:22
We got an error. Hopefully, it's not a
16:24
fatal error. I want to create a new
16:27
location for my output features to go.
16:29
These are the ones I will create. So,
16:30
I'm going to click create
16:32
and we'll put that up here. I'm going to
16:35
make this a geo package and we'll call
16:38
this uh test features
16:43
and we'll save it. Oops.
16:49
Test features and save.
16:56
Oh, it's because I didn't put a file.
16:58
Let's go test
17:00
features.gpkg.
17:03
And now let's save it. And now we have
17:04
this test features geo package. I go to
17:08
options
17:10
and
17:12
it shouldn't show me the boundary. It's
17:14
not showing me the boundary, but that's
17:16
okay. We can still do this. Um, we can
17:18
go to our prompts. And now we have a few
17:21
different prompts. Let me find
17:24
the location we were looking at. I
17:26
believe it was this location here.
17:30
And we can use for this is for
17:32
foreground points. This is for
17:34
background points. So we can use points.
17:36
So if I want to select say uh this piece
17:39
of vegetation, this tree opens out of
17:42
the feature boundary.
17:44
So I found the issue. It is that I
17:47
didn't load the correct folder. So let's
17:50
go here. Let me go to my downloads. I
17:53
put the features and test features. They
17:56
went in this April 9th, 2019 ortho. And
17:59
inside of there is another folder. And
18:01
if I go in there, um, I need to come up
18:03
and click this folder here, the SAM
18:05
features VITL bands 123. If I load this,
18:09
we should have this work. So if I click
18:11
select folder, and now if I click load,
18:15
there we go. Now I get uh a message
18:20
saying that was successful. And once I
18:22
have that, I've already created my go
18:24
package where the outputs will go. Now I
18:27
can zoom in. I can go to my prompts. I
18:31
can select foreground and background
18:33
points. So let me show you how this
18:34
works. So we have foreground here. I can
18:37
zoom in on a feature. Let's say I want
18:39
to digitize this tree or shrubbery,
18:41
whatever it is. I can click on it
18:45
and
18:47
it will usually give me a polygon. All
18:50
right, so I found the issue here. Also,
18:52
this test features layer was created
18:58
when I had the wrong input folder and so
19:02
it created it at the location of the
19:05
other um of the demo image. So, I'm just
19:09
going to remove this. Let's remove this
19:11
layer and we're going to create a new
19:16
layer.
19:18
Um, we'll put this up here. We'll call
19:21
this test call the same thing test
19:24
features geo package. We'll click save.
19:28
We will overwrite it.
19:31
Now, let's try this again and see if
19:33
things work. So, if we go to our prompts
19:35
and we click our foreground, uh, we
19:38
should get a polygon. and I click here
19:40
and there you go. You can see we have a
19:42
polygon. And now maybe I want to get a
19:44
polygon for this one. I can just click
19:45
on it and I get another polygon. And you
19:48
can see here that I haven't saved that.
19:50
So it connects those two polygons
19:52
together into one feature. Once I have
19:54
that, I can click save and it will save
19:57
those into my geo package. Now let's say
20:00
I want to use a different method. I can
20:02
click on bounding box and I can come in
20:06
and I can select uh these features here
20:09
roughly. That wasn't quite big enough.
20:11
So I can clear that and I can try a
20:13
little larger bounding box and it
20:15
selects that entire in that entire uh
20:18
feature and I can click save here and I
20:20
can go through and I can do this for all
20:24
of these features. Now we might run into
20:27
some issues and let me demonstrate this
20:29
here. Hopefully, it's large enough. If I
20:32
try to do a very large area, it's not
20:34
large enough. Let me try something else.
20:36
Something up here.
20:39
Okay. You'll notice it just selected one
20:41
little portion there. Or if I tried to
20:44
get all of these uh defoliated things
20:47
here. Hope I got all of them.
20:50
But if you try to do this, maybe try to
20:52
do the water. If you try to do this with
20:53
some larger with some larger features
20:59
and that didn't really Oh, it got didn't
21:01
really do anything.
21:03
If you try to do this with larger
21:04
features, you will run into some issues.
21:07
You got some out there. And that's
21:09
because um the way this segmentation
21:12
works is it works on 1,024 by 1024
21:16
pixel chunks. And so if you try to
21:19
segment something larger than that, uh
21:21
you will get some issues or some
21:23
artifacts. Um let me show you one. Let
21:26
me try to get one other uh example here.
21:29
Let's say I'm trying to segment
21:30
something here and I click on this and I
21:33
want to add some of these points and it
21:35
just selects too much. We can put in
21:37
some background points to try and
21:40
exclude different aspects of this and
21:44
try to shrink it down to what I'm
21:45
interested in. Um, I'm going to cancel
21:48
that. It's not what I want. Let's try to
21:49
Let's try something this water over
21:51
here. I'm going to select some
21:52
foreground like this and some foreground
21:56
here. And that expanded it out pretty
21:58
well. Um, but maybe I don't want to get
22:02
these little dirt patches. So, I click
22:04
background on that, background there,
22:07
background on that. And you can see how
22:09
it adapts in real time to adjust with my
22:13
selections.
22:15
So that's how easy it can be and you can
22:18
save that uh that feature also to your
22:21
shape file uh to your geo package. Now
22:24
when I open this up,
22:26
you can see that we have uh a feature.
22:30
We can select these here. Uh let me just
22:33
slide this out of the way a little bit.
22:39
You can see that we can select those
22:41
features that we have digitized uh
22:44
through our segmentation model. And so
22:46
this can be a very big time saver, a
22:49
great way to integrate uh what you call
22:51
artificial intelligence or deep learning
22:54
into your GIS workflow. Okay, I hope you
22:57
found this useful. Um as always, open
22:59
source options.com has more information.
23:02
You can go there, sign up for the email
23:03
list so you get notified as our free
23:05
courses start coming out. Thank you for
23:08
watching. If you liked this, give it a
23:09
thumbs up. Share it with your friends.