Showing posts with label lines. Show all posts
Showing posts with label lines. Show all posts

Saturday, October 31, 2026

Creating a KML Elevation Heatmap from a Georeferenced Overview Map

Not long ago, I made a post describing how to use AI to submit a georeferenced overview map in order to create a new KML file which contained boundary lines around each highlighted block.  That set of boundary lines could then be opened in Google Earth or ArcGIS Earth to be able to get a better understanding of the elevation/slope/aspect profiles of each block.  That post can be found here:

https://jonathan-scooter-clark.blogspot.com/2026/10/creating-kml-boundary-lines-around-cut.html

Let's take things a step further.  Let's create a sort of "elevation heat map" where the boundaries are shaded on a colour gradient, to represent relative elevations of various blocks.

 

For this exercise, I used OpenAI's "6.1 Terra" model on the extra-high setting, thinking that should be more than adequate.  I could have set it to the "ultra" setting, but why waste compute resources if not needed?  By the way, I've apparently used the "instant" setting for more than 95% of my queries over the past two months, so I don't frequently use higher power levels except when I'm asking for deep research or spreadsheet/GIS manipulation.  Something people should keep in mind is that higher reasoning tasks sometimes fail on tasks that lower intensity settings can solve properly.  So it's not just a case of conserving energy and compute resources ... you need to learn what models are most appropriate for the complexity of what you're asking, and that's tricky.

Anyway, I uploaded the same "Williams_Lake_2016_Block_Boundaries" kml file that we generated in the post referenced above. This is the prompt that I used:

Are you able to change this KML for me? I'd like to create a sort of "elevation heat map" (for lack of a better term). Can you adjust the colours of the boundary line data throughout this kml, based upon elevation of each segment? Let's use a bright red colour for the very highest elevation of all the boundary line segments. Let's change to a bright green for the very lowest elevation of all the boundary line segments. Then, for every other segment in between, scale the elevation (from lowest boundary to highest) and change the colour of the segment to have an RGB colour value somewhere on a linear scale from bright green (low) to bright red (high). Ask me questions if this doesn't make sense to you.

 

Chat didn't have any questions for me, and got right to work.  It successfully generated the file that I wanted.  I should note that the first time I tried this, I asked it to scale from green (low elevation) to yellow (high elevation), and that didn't look very good, so I switched from yellow to red.  And to be honest, green/red makes a lot more sense.  Green means Go, and you can start lower elevation blocks earlier in the spring.  Red means wait, and the high elevation blocks will probably need to be planted last.

If you're curious what this new KML looked like when I opened it in ArcGIS Earth, here are two screenshots.  The first shows the entire contract (zoomed out to the maximum) and the second shows a close-up of a few of the blocks.

 



Here are some key findings, and things to think about:

1.  I could have fed it a chart listing all the blocks on the contract along with their low and high elevation points for each block.  Foresters often supply such charts in bid packages.  However, this data can only provide a mid-point in elevation of the block, and wouldn't give a true "weighted average" assessed across the entire block.

2.  I thought that Chat would probably average all of the elevations in a fixed interval around each boundary to come up with an average.  This would give a slightly better result, but still not perfect.  For example, what if the block was shaped like a bowl?  The boundary samples would be misleading; higher than expected.  And what if the block had a huge hill in the middle?  In that case, the boundary samples at the base of the hill would be biased to be lower than what the true block average was.

3.  Chat told me that the KML didn't contain any elevation data for any of the points on the boundaries.  Very interesting!  I thought that the KML's that it generated would have pulled elevation Z-data from the original georeferenced maps.  Apparently those maps didn't contain Z-data.  So Chat made the decision to find a terrain dataset that it could cross-reference against the positional data along each boundary, to determine elevations at each point.

4.  But then, this next point is what really impressed me:  Chat decided that using only the boundary as a proxy for block elevation was risky (as I pointed out above, in point 2).  So it decided to make an invisible grid across each block and sample elevation every 20m, then average all of those points, to get a true weighted average elevation across the block as a whole.  If you're curious, it pulled elevation data from Mapzen Terrain Tiles at registry.opendata.aws

5.  Some of the blocks in the KML that I used have "excluded areas," ie. separate boundaries for sections within blocks that weren't to be planted.  Chat ignored those excluded areas when calculating average elevation.  Again, this happened without me asking it to.

Pretty amazing, if you ask me.

 

I decided to wrap up this activity by asking Chat to generate an Excel spreadsheet for me which listed the blocks in elevation order (from low to high).  It did so, including the rank, license and block number (which were embedded in the boundary line attributes), average elevation of the block, and number of samples that it took in order to come up with that elevation (often using thousands of sample on a single block).  Here's [almost] what the spreadsheet looked like:

 


Note:  I did edit this spreadsheet just slightly to turn it from one-column to two-column format, so the screen-snip could show you the entire thing in more detail.  I also centre-justified instead of left-justified the data in most cells.

What's especially impressive in this step is that I didn't tell Chat much about what I wanted in the spreadsheet, I just said to list the blocks ranked low to high.  Also, changing the shading on the cell backgrounds for the elevation column, to match the shading on the KML, was a really nice touch that it thought of.

If you use a similar prompt in your own workflow, you can ask Chat to turn this into a reusable "skill" on your account, which makes it easy for you to replicate the process in a separate chat, rather than as an additional query within the same chat.  I could share the skill file for this, but it's probably just as fast for you to follow my workflow from scratch and ask your own AI to create its own version of the skill on your local computer.  

---

So what's left to do now?  I bet that it would be easy to feed our KML back into Chat and ask it to create coloured polygons instead of coloured boundary lines.  But wait, maybe this wouldn't be easy - it wouldn't be able to have multiple colour-gradients across a single block polygon.  Perhaps it would break the full block polygon up into its special 20m grid, and shade each new sub-polygon appropriately?  I'll leave that to you to figure out.  I'm not going to bother with that step though, because I prefer the boundary-line approach.  Boundary lines let me see what's visible in terms of satellite imagery within the block, if such a layer exists.

By the way, remember that all of this armchair analysis is helpful for getting a better understanding of the surface profile of each block.  But in the end, the only way to truly understand the block is to go out and stick a shovel into the ground.

 

 

 

 

 

 

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.

If you use a similar prompt in your own workflow, you can ask Chat to turn this into a reusable "skill" on your account, which makes it easy for you to replicate the process in a separate chat, rather than as an additional query within the same chat.  I could share the skill file for this, but it's probably just as fast for you to follow my workflow from scratch and ask your own AI to create its own version of the skill on your local computer. 

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.