Showing posts with label software. Show all posts
Showing posts with label software. 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.

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.

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. 

 

Wednesday, December 24, 2014

Give a Gift to the World - Donate Spare Computer Time for Medical Research

As I write this, depending where you live in the world, today/tomorrow is the Christmas holiday for people of certain religions. Of course, there are billions of people around the world who don't celebrate Christmas, but who celebrate other holidays at certain times of the year when gift-giving is a tradition.

No matter what holidays you celebrate, or when you happen to read this post, how would you like to give a gift to the rest of the world? And it doesn't really cost anything (except a bit of electricity consumption when your computer is turned on).

The gift is participation in a volunteer "grid computing" project. Wait! I know, your eyes started to glaze over when you saw "grid computing."  Please, bear with me for a second!

There are literally hundreds of millions of computers around the world.  Many of them are inexpensive laptops or tablets for personal use.  You might not think that your "old laptop" is very powerful, but the interesting thing is that it is probably only "in use" for about 2-5% of the time when it's turned on.  The rest of the time, it's sitting there waiting for something to do.  Even when it looks busy, because it's streaming music or uploading a YouTube video, the brain of the computer (the CPU) is idle most of the time.

So it's possible (and easy) to set up your computers so when they're turned on but not in use, they're helping solve scientific problems that could benefit millions of people.  For example, my laptop is currently running projects to help study proteins.  This research is useful in fighting diseases such as malaria, cancer, Alzheimer's, and HIV.  My laptop is also helping to catalog a high quality model of our near galaxy.  It's also searching for pulsar stars, and working on a few other projects.  And it's not costing me a penny, other than my electric bill.

Ok, at this point, if you don't want to try to help cure diseases like cancer, Alzheimer's, etc., then you can stop reading.  But if I've aroused your curiosity, let me describe in more detail how it works, and I'll explain some of the specific projects that I'm supporting.


The Software:


The project is called BOINC, which stands for Berkeley Open Infrastructure for Network Computing.  Berkeley of course refers to the University of California at Berkeley.  You don't have to be very tech-savvy to make it work on your computer.  The people at Berkley set up the software to try to make it as user-friendly as possible, and to run in the background so you never notice it.

BOINC is currently available for a number of platforms.  For Windows, your computer must be running XP (service pack 2) or a more recently operating system, which should cover 99.98% of all Windows machines still functioning.  For Mac's, you need OS X 10.4 or later.  There are also versions for Linux and for Android, although the Android software is currently not working properly since Lollipop was released.  That should be fixed shortly.

Here is the download page for BOINC:  http://boinc.berkeley.edu/index.php


How It Works:


Basically, an institution that has a very large amount of data to process, but not enough computers to do it, can set up their project with BOINC.  People who decide to contribute computer time to a project will receive small chunks of data to process.  Your computer will spend a few hours or a few days processing this chunk of data, and then sends the results back to the project's institution.  The institution then sends you another chunk of data to work on.  This all happens in the background, so you don't have to spend any time answering or sending emails, etc.  And if you're worried about the internet usage, you can restrict the times that data is sent or received, and you can cap the bandwidth if you want.  But for most people, this won't be a big deal.  The bandwidth that most of these projects will send/receive in a day is probably less than you'd use watching a two-minute YouTube video.  If you're on Android on a phone, you can tell it to wait until you're at a free WiFi point to send/receive, so you don't use any of your mobile data.

The strength of the system is that the institution can be sending chunks of data out to dozens or even thousands of computers all around the world to simultaneously help work on analyzing data!  If you're curious about what happens to data that can't be processed, and whether or not it affects the project, there are safeguards.  For example, if you are processing info for a project and your laptop gets run over by a bus, there are deadlines built into each chunk of data.  So for this example, if the institution doesn't get results back from the data chunk that your computer is working on within say, 30 days, it sends the same chunk out to someone else's computer to analyze.


Slightly Technical Section:


You can ignore this short section if you want to avoid technical stuff!

If you want to really control the parameters for BOINC, you can customize a lot of stuff.  For example, I have mine set up so that after ten minutes of no activity on the computer, it starts to run.  I think this is fairly typical, although maybe the default is one hour.  But as soon as BOINC detects that you're using the computer (either through physical interaction such as a keypress, or high CPU usage such as watching a video) then it suspends operations until it knows that you're not using the laptop yourself.  This way, your laptop is never "slowed down" when you're using it.

For CPU usage, I have mine set so that BOINC doesn't run if my CPU is over 15%.  When it is running, I have it capped at a maximum of 95% of CPU.  For people with advanced graphics cards, which probably isn't a lot of people, you can allow BOINC to use the processing power of your card.  For example, I have a fairly nice nVidia GeForce 870M video card, so that's also helping to do calculations when BOINC is running.  BOINC supports quite a few nVidia and ATI/AMD cards.

From the BOINC Manager program, if you want to get really technical, go into View and switch to Advanced.  Then go into Tools and select Computing Preferences.  This is where you can play with your CPU and network and hard drive usage settings.  You can also determine whether or not it auto-loads when you boot your device, or whether it has to be turned on manually.  You can also temporarily do a suspension of processing with a single click in the Manager program.  For instance, I have mine set up to auto-boot and run most of the time, but just in case, I suspend it when my computer is rendering large video and audio files (although it shouldn't run then anyway because my CPU is too busy).

Although BOINC runs on all major platforms, not all individual projects using BOINC are able to run on all platforms.  For example, many projects can't take advantage of GPU processing, and some projects only run in Windows and Mac environments.


Cool Stuff:


BOINC on all my machines has a screensaver, which I've turned on.  I've matched the screensaver start time to my "start BOINC processing after 10 minutes of downtime" setting, so when BOINC starts, the screensaver comes on.  You don't have to run the screensaver.  However, for some of the projects, it's pretty cool, and it's a nice conversation piece if someone notices it and asks what your computer is doing.  You can tell them that you're saving the world.

To get to your screensaver settings in Windows, go to Control Panel then Display then Personalization.  I have mine set to never blank, run the generic BOINC portion for 1 minutes, then run project screensavers for 1 hour.  So it keeps switching back and forth between the generic one (1 minute long) and then an hour of various project screensavers.  Within the project screensavers, I have it set to switch every 2 minutes, so there's more variety.

Some of the screensavers keep spinning or displaying changing graphics of stuff being studied, so a single screenshot isn't very exciting.  But here are screenshots from two projects that my laptop is running, from the Rosetta and Einstein projects:




These screensavers have captured the attention of many people who have been by my house to visit.


Projects:


Here are some of the projects that I'm supporting.  I have them set to cycle automatically, so my laptop processes one for an hour, then moves on to the next, so they eventually all get an equal share of my computer's time.  In the preferences, you can allocate different percentages of your overall CPU to various projects, in case there are some projects that you want to support more than others.

Milky Way 
This project is creating a highly accurate three dimensional model of the Milky Way galaxy using data gathered by the Sloan Digital Sky Survey.  They have a facebook page and website and YouTube channel, like many of the other projects.

Rosetta
Determining three dimensional shapes of proteins in research that will hopefully lead to a cure of some major human diseases, including diseases such as HIV, malaria, cancer, Alzheimer's, etc.

SkyNet POGS
An astronomy project studying sixteen different properties of galaxies, and also helping to produce an atlas to help astronomers better understand the distant universe.

MalariaControl
Sponsored by the Swiss Tropical Institute, this project is doing modelling/simulations of large human populations to determine optimal strategies for delivering mosquito nets, chemotheraphy, and new vaccines that are currently under development and testing.

Einstein
Searching for spinning neutron stars (pulsars) using data from the Arecibo observatory.  Volunteers helping with this project have already discovered several dozen pulsars over the past couple years!

SETI
This is the project that got BOINC started over a decade ago.  This project searches through data gathered by various observatories and looks for non-naturally occurring radio signals from outside our solar system, in other words, the search for extra-terrestrial intelligence.  So far, none have been found, but people continue to search.  You probably know this joke: "What's the biggest sign that extra-terrestrial intelligence actually exists?  That they haven't tried to contact us."

World Community Grid
This one, sponsored by IBM, is actually a group of non-profit projects on things like research into HIV/AIDS, cancer, tropical and neglected diseases, solar energy, clean water, and many more.  For instance, there is an Ebola research project available from this group.

If you want to see a more complete list of projects to choose from, go here:

Obviously, there are dozens of projects available to chose from.  You can contribute to just a single project, or you can contribute to a dozen or more.  Your choice.  You'll find that most of the projects specifically fall within research areas within the following fields, due to the data-crunching requirements of these areas of study:  astronomy, math, physics, quantum physics, biology & life sciences, and medicine.  Just remember that you have to install BOINC itself before you start participating in a project.


Getting Started:


After you install the BOINC software, you'll have to go to the "load project" section and pick a project that you want to support.  After that's set up, load another project if you want.  You'll probably be impatient at first to see it start working.  Give it time.  When you first install it, it needs some time to download data to process, to think about how to set things up, and so on.  Also, your stats screens and screen saver will display stats showing how many "work units" your system has completed.  Don't expect those to go up right away!  It may take hours or a day or two before your system finishes processing the first batch of data, then the data has to be sent back to the project sponsor and verified.  So it may look like you've processed 0 units of work for a few days, and then all of a sudden it'll jump up to hundreds or thousands of units processed.  Be patient.


Final Thoughts:


You may wonder how many people are participating in these projects?  As of today, it appears that about 236,000 people from around the world are contributing computer time to various BOINC projects.  They are doing this on about 481,000 computers.  By the way, many users are running BOINC on several machines and tablets and phones simultaneously.  For instance, I have it running on three devices in my house.

There are many web pages showing the stats and progress of various projects.  Some users gather together in "teams" to 

I highly encourage you to contribute to this project.  Seriously, what do you have to lose?  Some people leave their computers running all night, doing nothing!  Think of how good you'll feel if you know that your computer isn't dormant, it's helping advance research in the cure of diseases that kill millions of people every year!

Also, the screensaver options are great.  They've really drawn attention to the project when people see them.  The whole concept is a great conversation starter.  Next time you have friends over to visit, wouldn't it be cool to say, "Hey, I just set my computer up to help study a potential cure for Ebola."

If you're worried about the electric bill, remember that it's not going to cost you anything unless you leave the laptop on longer than you normally would have.  And realistically, leaving a computer on overnight, year-round, to contribute to these projects is not much different than donating $20 once a year to a local charity.

Even if you only have a single computer running the BOINC software, and it's only running a few hours each day, you're still contributing to a great cause.  And what about your computer at work?  If you're not on a special networked computer, maybe that one can also be allowed to BOINC?  You better check your company's policies first, but some companies are fine with this.  After all, it's for a great cause. 

Once again, here's the link to get you started:


Please, share this post with other people you know who might be interested in learning about these projects.  I've just added share/retweet/like buttons below.  There are probably lots of people out there who would love to contribute to some of these projects, but just don't know that the possibility exists.