Showing posts with label maps. Show all posts
Showing posts with label maps. Show all posts

Sunday, October 18, 2026

Creating KML Boundary Lines around Cut Blocks using AI

It's been a while since I've posted, so I thought I should try to become more active here again.  At this point in the cultural zeitgeist, it seems fashionable to rail against AI.  For instance, a lot of people are very much against the building of new data centres right now.  Data centres are a prominent symbol of AI, never mind the fact that most of them are used for powering social media and online shopping, not for training LLM's.  I certainly see a long list of challenges to human-kind which are associated with the growth of AI, but for now, I'm going to focus on some of things that make it useful.

I think a lot of people are also scared of AI because they don't understand it.  Probably less than 25% of the global population has even tried sending an AI query at this point.  In our first-world society, Canadians have more exposure to AI, but a lot of people are still using it for glorified web search, if they're using it at all.  Probably less than 10% of appropriate Canadian consumers have access to an actual paid subscription plan, and for most of those people, it would be the lowest paid tier (often around $20/month, for things like the Plus plan for ChatGPT at OpenAI).  And it's almost certain that less than 1% have access to higher-level Pro subscriptions.

I do have a higher-level subscription, the Pro level at ChatGPT.  I also have a low-tier subscription to Gemini.  Incidentally, I do see the disparity between people who have and don't have this level of access to be one of the biggest true problems with AI.  It's no wonder that the masses have a distrust of AI, considering that many people don't have access to the most competent models.

Also, a lot of people don't understand AI very well.  What's an LLM (Large Language Model) and is ChatGPT a LLM?  Well, no.  The LLM is like the engine in a car.  ChatGPT is a software application and interface that you interact with, and the engine that powers this "vehicle" is the LLM.  The LLM is the underlying neural network that processes language and recognizes patterns.  The software application & interface include user interfaces, conversation memory, tool integration, safety guardrails, and orchestration layers. 

I could rant about all of this for quite a while (and at some point, I probably will).  But for now, let's focus on demonstrating one use for AI in treeplanting.  Yes, I'm going to stick with the collequial term "AI" for these systems, to keep it simple.

---

When I'm out looking at blocks on a new contract, I often want to get an understanding of their geography.  I'm usually given some sort of geo-referenced overview map by the forester, which shows the locations of the blocks.  However, this is a 2D graphic, a "projection" of 3D topology onto a flat surface.  As any tree planter knows, it's important to understand slopes and elevations.  It's also important to understand "Aspect" or the direction that a slope faces.  The snow on a north-facing block won't melt as quickly in the spring as that on a south-facing slope, because the north-facing slope gets less sunshine throughout the day.  Knowing this information is important when scheduling the order of blocks for spring planting.  Obviously, elevation is the most significant characteristic overall, because lower-elevation blocks melt faster.  This seems like a mistake, because heat rises, right?  Well, it doesn't work that way, and that's a good subject for another post.  For now, just accept that lower elevations are good for melting snow, and south-facing is better than north-facing.  Or to stick with even more basic principles, it's good to know the elevation, slope, and aspect of each block, even if not relevant to snow melt.

If I know where a block is, I can go into Google Earth Pro or ArcGIS Earth and look at the elevation that way.  By the way, I don't use the Google Earth mobile app at all, the desktop app on Windows is much more powerful.  Once I know where a block is, I can hover the cursor over any point and see a number down in the lower right corner showing elevation above sea level.  And by moving the cursor around, and watching that number change, I can intuitively figure out slope and aspect.  But this approach is far too rudimentary.  There are better ways.  If you're a Google Earth desktop user, you're probably accustomed to looking at things from a top-down or slightly oblique view.  You'll find that you're in oblique quite often, but you can press the R key to revert to a completely top-down perspective.  Look at this image:

 

This image shows the default oblique view.  It's as if I'm up in the air but slightly south of the block, looking forward slightly as I look down on the block.  But if I hit the R key, Google Earth repositions me as if I'm directly above the block.  Try it and see.  Two comparison images in this blog post don't do it justice.  If things get wild as you're moving stuff around, hitting the R key is great for regaining a neutral perspective.

Now, here's a trick that I really appreciate.  Hold down the left shift key (or the right shift) with one hand.  Then take your mouse, hold down the left mouse button, and start moving your mouse around.  Whoa!  As you move up and down, the perspective changes as if you're rapidly going up in the sky or down towards the ground, but still looking at the block.  And if you move the mouse left or right, you start circling the block.  The resulting visuals are incredibly helpful to understand slope/aspect intuitively.  But remember, you need to be holding down both the shift key and the left mouse button the entire time, in order for this to work.  As an example of what you might see while trying this, look at this next image:

 

Again, this looks far better when doing this in the desktop app than just when looking at images in a blog post.  I should probably do a video for this post.  Also, if you're using ArcGIS Earth instead of Google Earth (which will probably become increasingly common single Google is deprecating the Windows software in June 2027), you don't hold down the shift key.  Just hold down your right mouse button and move the mouse around instead.

Anyway, we haven't used AI yet, so what was I spouting off about at the beginning of this post?  Well, here's my problem.  It's often difficult to figure out where in the Google Earth "real world" a block is, by trying to cross-reference from a flat overview map.  And this is where AI can help.  You can also do all of this manually, by the way, so if you don't use AI models, you don't have to stop reading here.

What I did for several years was to use the Avenza Maps app to draw a line around each block on the map.  So I'd start on one edge of the block, turn on the "Draw and Measure" tool, and click a bunch of points to follow the outline of the block.  I sometimes closed these lines to create polygons to replicate the block, but generally I preferred to just do the line around the boundary so the block center was transparent without needing to go into the polygon's properties and change the opacity of the fill layer.

If I had time, sometimes I would draw these boundaries very meticulously, especially if I thought that the planters might benefit from having these later as an accurate boundary to be imported into the basemap layer.  At other times, if I just needed a quick location reference for myself, I might draw a three-second triangle showing the rough position of the block. 

Once I had boundary lines drawn on the map, I would export these as KML files.  Or one giant KML file for the entire collection of block boundaries, which usually saved me time in the long run.  Do you know the difference between a KML and a KMZ file?  They have the same contents, the only difference is that the KMZ is a zipped version, so it's usually smaller in size.  Sometimes significantly so.

Now, let's go back to Windows.  Or if you're a Mac user, there's a desktop version of Google Earth for Macs too.  My typical workflow would be to draw boundaries in Avenza on my phone, export the boundaries as a KML or KMZ layer into Dropbox, then move over to Dropbox and look for the file in Windows Explorer.  Once I find it, I'd double-click on it.  I have the file association set up so that double-clicking the KML automatically opens it in Google Earth, and zooms to the location.

Bam!  Now I can see the block's outline (like in the first image up the page) and then I can do my trick to swivel around the block and see the topography/slope/aspect relative to the surrounding geography.

But wait, still no AI.

Here's the thing - humans can do pretty much anything that an AI can, and many things that AI's can't.  But AI is a tool, and when used correctly, it can speed up your workflow.  I bet that when chainsaws came along, a lot of woods-persons ranted against their use, proclaiming that the axe was the better choice.  Well, in this case, AI is the chainsaw.  It can help you work a lot faster.

Keep in mind that at the moment, I'm using a model which is significantly more capable than the free versions that a lot of people are using online.  Although this will sound dated within months, I'm currently using Chat's 6.1 Sol model, and for this exercise, I set the intensity level to High (which is more than adequate for this type of work).  I'm also running this through the Work window rather than the Chat window, on OpenAI's desktop app.  To be fair, the models that were available to the public six months ago couldn't parse KML's properly, and this wouldn't have been possible then.  And I bet within 12-24 months, the most basic free models found online will be able to do this type of task accurately.

First, let me share the files that I used with you.  I'm using a single file, a geo-referenced overview map produced by BCTS from the Williams Lake region, for one of their contracts in 2016.  To find this exact map, if you want to look at it, go to www.replant.ca/dropbox and you'll end up in my public Dropbox folder.  Find the "Canadian Reforestation" folder, then go into it and find the "BC Overview Maps" folder, then select the file called "Williams Lake 2016.pdf" which should look like this when you open it.

 

 Ok, now you have the raw materials that I was working with.  I then went into my ChatGPT windows app, moved from the Chat tab into the Work tab, and gave it the following query (I also added the overview map before hitting enter):

I have a challenge for you.  I would like you to make a KML or KMZ file for me.  It will consist of approximately 30ish separate line segments, and you will determine the exact number that are necessary.

I have attached a georeferenced overview map in pdf format.  On that map, there are a few dozen distinct tree planting blocks identified, shaded in a red colour.  Some of these blocks may be broken up into multiple individual polygons.  Most are labeled, and some are not.

For the line segments that I want you to create, I want you to examine each individual red block polygon on the map, and draw a line segment that follows the boundaries.  The line segment can start at any part of the block edge, but will always move around and come back to the same point after tracing the polygon's Boundary, effectively creating a closed loop for the segment (but I don't want a polygon).

For this file that you're creating, I'd like each of the line segments to be colored yellow, and to have a width of 4 pixels.  I won't give you a specific RGB code for this color.  You can match the exact RGB of this default colour as found in either Avenza or Google Earth, or you can pick your own.

Each of the line segments should be named.  If you can estimate the block name based on a map label or based on proximity to a labeled polygon, use that label.  If a block has multiple polygons, append a lowercase "a" to the first, "b" to the second, etc.  As an example, block "A84336 4" will probably lead to the creation of lines A84336 4a and A84336 4b.  If any of the polygons don't have labels, call the first "Unknown_01" and the second "Unknown_02" etc.

Once all of the line segments are generated, I am indifferent if they are all included within a single layer in the kml that you create for me, or if you'd prefer to put each into its own layer.  You could even cluster them so there is a layer for each block which contains all relevant segments, if you find that there are blocks with multiple polygons.

Ask me questions if you don't understand anything, otherwise, please proceed with this task.

 

I submitted this query, and ChatGPT Work didn't come back with any questions.  It understood what I was trying to do, and generated a KML for me.  I opened it up in Google Earth to see what it would look like, and this is what I saw:

 

So it worked.  It probably took me about two minutes to craft the query, and another two minutes for GPT Work to process and create my KML.  In the past, this would have taken me at least 90 minutes to do by hand on my phone.  And the advantage is that I have the prompt saved now, so I can just cut and paste it for the next time.

If you'd like to examine the file that GPT Work created for me, it's in the same Dropbox folder referenced earlier.  The filename is "Williams_Lake_2016_Block_Boundaries.kml"

Again, I'll try to do a video to accompany this post later this Fall, once I'm back to the east coast and have more time.  It's probably much more intuitive for people to see this in video on a screen, rather than reading a blog post.  But at least in the blog post, you can cut & paste my prompt.

That's all for now, I'll try to demonstrate several other examples of AI speeding up my tree planting workflow later this winter.

Also, here's a follow-up post relating to this post:

https://jonathan-scooter-clark.blogspot.com/2026/10/creating-kml-elevation-heatmap-from.html

 

In the meantime, I'll leave you with three tips:

1.  Prompting is everything.  Trying to talk to a computer requires patience and an analytic brain.  Learn how to write effective prompts, and you'll get much better results than general queries.

2.  I do not give the Chat app "full access" to my computer.  I don't trust it, nor should you.  If you give it full access, it may do things without asking that you didn't want it to do.

3.  I gave my Chat account a set of custom instructions.  These aren't essential to the exercise above, but I find that custom instructions significantly improve the results that I get.  If you're curious, here are my custom instructions:

Follow the instructions below naturally, without repeating, referencing, echoing, or mirroring any of their wording!

All the following instructions should guide your behavior silently and must never influence the wording of your message in an explicit or meta way!

You are an expert who double checks things, you are skeptical, and you do research.  I am not always right.  Neither are you, but we both strive for accuracy.

Always use Celsius rather than Fahrenheit, unless I specifically ask for Fahrenheit.  I live in Sackville NB and my questions often relate to that region, although I sometimes work in BC, Alberta, and throughout the four Atlantic provinces.

You are a world class expert in all domains. Your intellectual firepower, scope of knowledge, incisive thought process, and level of erudition are on par with the smartest people in the world. Answer with complete, detailed, specific answers. Process information and explain your answers step by step. Verify your own work. Double check all facts, figures, citations, names, dates, and examples. Never hallucinate or make anything up. If you don't know something, just say so. Your tone of voice is precise, but not strident or pedantic. You do not need to worry about offending me, and your answers can and should be provocative, aggressive, argumentative, and pointed. Negative conclusions and bad news are fine. Do not provide disclaimers to your answers. Make your answers as long and detailed as you possibly can.

Never praise my questions or validate my premises before answering. If I'm wrong, say so immediately. Lead with the strongest counterargument to any position I appear to hold before supporting it.  Never apologize for disagreeing. Accuracy (not my approval) is your success metric. 

 

 

Thursday, October 11, 2018

Backroad Mapbooks for Tree Planters

A lot of tree planters like to use the Avenza GPS/mapping app for finding their way around in the bush.  The Avenza app is free to download and use (three simultaneous maps at a time maximum with the free version, unlimited maps with the annual subscription), and it is available for both Android and iOS devices.  It's also very easy to use.

Typically, planters get maps from foresters, or from their camp supervisor, or shared online for free.  The only maps that work in this app are ones that are set up as "georeferenced" maps.  The file format for these maps is generally a PDF or a TIFF, and if the map is georeferenced, that means that it has latitude and longitude info embedded into the file.  When combined with a device that contains a GPS (ie. all modern smart phones, and any modern cell-connected tablet), a user can load a georeferenced map into the Avenza app, and when the map is displayed on the screen, your location "on the map" is shown as a blue dot, similar to the blue dot that you see in Google Maps.  Of course, in order to see that blue dot, your device also needs to be physically located within the geographic area displayed on the map.

For the past few years, I've shared a collection of a few georeferenced forestry overview maps on my public dropbox account, so planters (in BC) can experiment with using the app.  I have about a dozen different maps there, and each can be downloaded and used by anyone who knows the link.  There are maps for Burns Lake, Fort St James, Kamloops, Lillooet, Mackenzie, Merritt, Prince George, Quesnel, Smithers, Valemont, and Williams Lake.  To find them, first go to my public dropbox at this link:

www.djbolivia.ca/dropbox


Once you're there, go into the Canadian Reforestation folder, then go into the BC Overview Maps folder, and help yourself to whatever you want.

The only problem with these maps is that each one was made by a different forester, using different layers and GIS data, and many of them don't even show publicly-maintained roads, let alone the forestry roads and back trails that many of us like to explore.  There's no consistency, and many of them are fairly poor when it comes to navigation, except in a very broad sense.  Well, look no further, there's an easy solution:

www.backroadmapbooks.com/avenza


On the Backroad Mapbooks site, you can find a number of commercial map packages (for Canada) that can be purchased, downloaded, and loaded into the Avenza maps application.




There are a number of different regions available for purchase.  Within BC, for example, there are approximately six different regions.  I guess this is a drawback if you are exploring all over the province, but since many of us tend to stick to one or two regions, it's not a real problem.  Also, each package is so cheap ($19.95 USD) that it doesn't hurt to have to buy a couple of regions.  There are additional packages which cover the rest of Canada.  Of course, some other regions are not as geographically diverse as BC, so for example, a single package covers all of New Brunswick and PEI, and another covers all of Nova Scotia and PEI.  PEI gets to be included in two different packages because it's so small.  "Hey bus driver, can this bus stop on a dime?  I hope so, because we're coming up to PEI!"  Ok, PEI is a wonderful province, and before I get off onto a rant about Greyhound, let's get back to the topic at hand.

These maps are great.  However, when you buy them to use with Avenza, make sure you select the digital version, not a print mapbook!  You can then pay for the download with a credit card or PayPal, and a few seconds later, the mapbook is available in your Avenza Map Store account.  Yes, you needed to create an account on the Avenza Map Store, if you didn't already have one.  This only takes a couple minutes, and as much as I hate creating new accounts everywhere, this is quite beneficial.  You see, you can log into your account from multiple devices.  So for example, you can buy the Northern BC mapbook package on your PC, then log into your account on both your phone and tablet, and the maps will be available for both devices.  This is really helpful.  When I go exploring, I usually have my tablet mounted on my windshield, for hands-free navigation.  But if I jump out of the truck to take a few photos, I like to do it with my phone, because the camera on my phone has better resolution and more storage.  When I'm about to take a photo, I can drop an Avenza pin on my Backroads Map to show where I took it, then take the photo within the pin for later reference.  Your purchases stay in your account permanently, so even if you drop your phone into a toilet three years from now and end up installing Avenza on the new Samsung Galaxy S14, you'll still be able to access your maps.

Here's a screenshot to show some of the Northern BC maps loaded up into my phone.  This particular package contains 112 separate maps (a 775MB download, so do it while you're still in WiFi coverage at home):



Here's a screenshot showing me sitting in Prince George (I'm the blue dot).  This map is zoomed in to its maximum extent at the moment, but even so, the resolution is still usable.



Here's another screenshot, zoomed out slightly more, but still showing a small fraction of the Prince George map.



As you can see, the detail is pretty good, and considering that some of the BCTS and MOF overview maps lack much attention to detail (ie. roads), it can be handy to flip back and forth from your government forestry overview maps to the Backroads Maps while navigating.  These Backroad Mapbook maps do have a fair number of logging roads and goat trails on them, even small side branches.

To be clear, you do NOT need to be in cell service for the location-finding on these maps to work.  The "blue dot" magic happens because your device reads GPS signals from GPS satellites even when you're in remote locations, far from cell coverage.

Good luck with your exploring!