Register | Login
Attackpoint - performance and training tools for orienteering athletes

Discussion: Veg or png to dxf for OCAD?

in: Orienteering; General

Apr 27, 2020 8:59 PM # 
Mr Wonderful:
I thought I read on here about a way to take something like the KP vegetation and end up with an editable .ocd type object, maybe dxf or similar. But my searches thus far have been fruitless, or my memory was wrong in the first place!

Any hints or tips? Thanks in advance, not much else to do right now except make maps!
Advertisement  
Apr 27, 2020 10:25 PM # 
Spike:
Joakim Svensk has a little program to create shapefiles from KP vegetation. There's a link on this page (Swedish page):

https://stefansolsida.wordpress.com/2017/08/06/gor...

I have used QGIS. The basic steps are to open the vegetation.png file. Then:

(1) raster > conversion > polygonize.;
(2) In the processing tool box use "vector geometry simplify";
(3) The last step is to use the processing tool box to smooth the simplified vector (vector geometry smooth").

Step (1) is enough to get a file you should be able to open in OCAD. Steps 2 and 3 are only needed to simplify and smooth the shapes to make them less blocky. You can probably do similar smoothing in OCAD.
Apr 28, 2020 1:12 AM # 
haywoodkb:
The vegetation PNG has an associated "world file" for georeferencing, and the newest OOMapper has a vector tracing option. It should be possible to turn the vegetation template into vector symbols within OOMapper.
Apr 29, 2020 5:40 AM # 
cedarcreek:
There’s a recent thread on Facebook about this:

https://www.facebook.com/groups/485564718218028/pe...
Apr 30, 2020 7:31 AM # 
Terje Mathisen:
My own set of tools do just this, i.e. the last stage of my batch file that processes lidar will first do a point cloud to vegetation raster step, one for each tile of typically 256x256 or 128x128m, then it converts each of those tiles to a DXF file before optionally combining all the tiles into a single DXF covering the entire map.

In order to work best, my program require you to calibrate the vegetation recognizer, typically by surveying a few percent of the target area in order to come up with a set (10-30) of reference patches of vegetation, at least one for each type of vegetation that should be mapped as a particular shade of green, green stripes, white or yellow.
May 1, 2020 4:04 PM # 
MIclimber:
I too have the ultimate goal of trying to auto generate veg that is generalized and vectorized for import into OCAD for easy initial base map creation. Have been stumbling around on this part for weeks. It's fairly disappointing that OCAD does not have this type of function natively built in and forces you to do tedious field work / drawing veg by hand or accept their pixelized raster veg.

Joakim's polygonize program errors out on my file, even though the example works. I get a MemoryError, polygonize returned -1. I have 16 colors apparently versus the example having only 7. I'm hoping to hear back from him, as this one if it works seems to be the easiest to work with.

I tried Qgis as well, and was somewhat successful. I was able to convert raster to vector, then simplifying and smoothing, but then everything just turned red and it seemingly lost all my colors. I was able to export to .dxf and import then into OCAD. The smoothly and generalizing objects were sublime, so if I could figure out how to retain original colors that would also be easy to work with. But as it stands, editing each object and changing colors is also way to tedious for my liking.

Trying to run Terje's lidar-adaptive batch on a win10 machine on my .laz file, but it keeps erroring out on the .pl scripts. Getting the file does not have an app associated with it. I added .pl to the win environment variables - pathext section, but that did not help. Hoping Terje or someone can advise what I'm doing wrong.

Thanks,
Steve
May 1, 2020 4:29 PM # 
jjcote:
In the Qgis case, can you select all of the objects (Select By Symbol), and just change the color of all of them in one step?
May 1, 2020 8:21 PM # 
Terje Mathisen:
@MIclimber: I have just updated my mapping page, so that the lidar-adaptive script has all the latest programs.

https://tmsw.no/mapping/lidar_adaptive.7z

Please remember that you _have_ to first install a compatible Perl version, i.e. I recommend ActiveState Perl for Windows, 64-bit version (if you have a 64-bit Windows).

Good luck!
May 1, 2020 10:12 PM # 
MIclimber:
Hi Terje,

Thank you first of all.

I am using your latest scripts and have perl from active state installed already. I am not a programmer so I don't really understand perl beyond that I successfully installed it according to the version command. I tried reinstalling perl, I'm not sure if that made it worse, as now I can not get it to go into an activated state like before. I don't know if that is required or not. I tried a few things I saw online, but unsure if it had any effect.

Anyways whatever I did, I tried running your script again, and now the process partially ran, which I'll consider progress. It created tiles, but once again errored out once it hit the 4 .pl scripts saying it's not associated to an app. Any advice on how to fix this? I assume this is now a windows issue and not a perl issue? As I mentioned I added .pl to the PATHEXT in advanced settings already.
May 2, 2020 4:59 AM # 
Terje Mathisen:
You do need both perl.exe in the PATH and .pl associated with that executable.
A workaround is to edit the batch file and prepend all the xxx.pl commands with
"C:\Perl64\bin\perl.exe" or wherever you have the binary, that way you don't need either the PATH or PATHEXT to be setup.
May 5, 2020 8:23 PM # 
MIclimber:
I tried again to add to the system/user environment variables for PATH, but still did not work. However, adding the full path name inside the script to the .pl cmds worked, so thank you!
May 6, 2020 7:31 AM # 
Terje Mathisen:
OK, in that case you have probably installed this in a different directory than me (\data\orientering\), in which case you would have to adjust the PATH entry at the top of the batch file. Full paths work always though. :-)

Please report back with what sort of results you are getting!
May 6, 2020 4:47 PM # 
MIclimber:
I'm happy to report I was successful in creating a veg dxf and importing to OCAD using Terje's batch script. It auto created and merged into one dxf file. I imported to OCAD where it retained the symbol code, but didn't actually change to the proper color, even though I used the .crt file. But it was not a big deal, as only had a few colors. I used the change all object by symbol tool and quickly amended to the correct color. There was a bit of cleanup work, with deleting some extra features that I didn't need, like picnic tables and artwork, but again, fairly easy to do with selecting all by symbol type. A side note, was that for whatever reason, Terje's gif output did not load into OCAD properly, loaded as all black. Not that I needed the gif now that I had the dxf, but this led me to figuring out how to use QGIS to convert the gif to geotiff, which that properly imported to OCAD. KP's png had no issues either importing, so not sure what is up there, since the gif opens normally and the world file was fine.

Anyways, I wanted to run a comparison of the different methods, but I have not heard back form Joakim about getting polygonize to run fully. I did also attempt to do a test with QGIS. Which while perhaps using QGIS is more user friendly and I was able to follow the previously mentioned steps to get a dxf, it did not retain the symbol coding, even using Terje's crt file. So while QGIS might produce nicer curves in the objects, having to go thru and individually edit the objects to the correct color symbol is a non starter. Maybe there is a crt out there that keeps the code references in tact for QGIS, not sure?

So, I'm pretty happy that I've gone from a brand new user of OCAD to processing lidar, creating a viable base map with decent veg, all of which was auto generated and probably can be done in a few hours once process is honed in.
May 7, 2020 5:56 AM # 
Terje Mathisen:
Good to hear this!

You should in fact have gotten the proper ocad objects types, i.e. with white/yellow/green/stripes, did you try to apply the veg2dxf.crt file while importing the merged dxf?

Re. solid black (or any other color) filling the screen: This is most probably an artifact of the import process, when it happens I usually get a single object covering everything, but by just clicking on it and then deleting it, the normal/actual objects turn up underneath it.

Can you zip up and send/upload somewhere the dxf and crt files you tried to import?

PS. If you import my dxf without any crt file, then you can do a bulk conversion afterwards, using the [Map] [Convert Imported Layers to Symbols] function where you can either try to load the crt or use [Add all] to locate all symbol types in the dxf.
May 7, 2020 4:33 PM # 
MIclimber:
Ok that is where the confusion came in. veg2dxf.crt is in your old "mapping" bundle. I used the lidar_adaptive_vegetation.crt assuming that was the update to use. Now I realize that is for the gif creation I assume. Perhaps veg2dxf.crt should be included in your new bundle and the basemap page could use an update? Or a readme added to your new bundle? With info scattered about online and cobbling together instructions here and there, I may have easily misunderstood as well. Maybe I'll run another test now that I know which crt to use, and/or this other command to convert all.

I can email you the dxf file sure. Again thank you, for the help and what you've created.
May 7, 2020 6:47 PM # 
Terje Mathisen:
OK, I should definitely clean up my .crt file setup! I tend to create them programmatically in parallel with other conversion tasks, but those are never properly in sync so I'm just using a small static set which is what I should include. :-)

No need to ship the dxf over!
May 8, 2020 2:10 PM # 
MIclimber:
Just as a follow up for others who may stumble upon this in the future. I went back and used Terje's veg2dxf.crt in his "mapping" bundle, on my merged.dxf file from his "lidar adaptive" bundle and it did in fact convert the objects to colors without having to manually change them. So this method will work start to finish! Assuming you can install python, perl, lastools, unpack the scripts, and know a bit of dos commands...

On a side note, I attempted to do the same with my qgis dxf export using Terje's crt and it did not work. I also tried to do the map-convert imported layers to symbols function, and that also did not work on the qgis file. So perhaps it needs it's own crt to be successful, not sure.

So for me I was able to get Terje's script to work and import successfully into OCAD. QGIS might be more user friendly, but there would be additional training/knowledge to take place in order to over take ease of use.
May 17, 2020 6:40 AM # 
Jagge:
I never had need for vectorizing the vegetation image. If I auto generate map for instant use I find it better to have lost of green shades I don't edit it anyway, so no need of vectors or converting them to only three ISOM shades. And if I edit it, I ijust do some color palette editing, tuning green up or down. Easy to do when it's paletted raster image. And if it is for mapping, I prefer not doing any filtering to not lose any useful information. Often human eye identifies vegetation edges and features in unfiltered granular image pretty well, better than after image being pushed though filter algorithms and converted to only three shades of green. And there is no point converting such granular image vector, it would be equally impossible to edit.

May 17, 2020 6:58 PM # 
Terje Mathisen:
Jagge & I have agreed to disagree here. :-)

I.e. his algorithm tend to create more immediately useful contours and vegetation than my own, but my DXF vector vegetation have been reported, by several WOC-level mappers, to provide very useful information even if I by design tend to include more information than you want in the finished map: The important thing is to get most of the boundaries accurately located, at that point the mappers find it easy to modify a patch by changing type or even delete it.

Quoting one of the JWOC mappers: "In every place where you have generated a vegetation boundary, we can see it in the terrain, i.e. we understand why it is there. We still delete/ignore quite a few of them in order to generalize the map to make it more readable, but having those boundaries is really helpful."

It is well worth noting that in the mapant.no project which I'e been running for a couple of years now (most of the data has now been made accessible to us, but in formats and with an organization which is far less usable than the one selected in Finland), with very significant help from Henning Spjelkavik and Jan Kocbach, we decided to use Jagge's instead of my code for these functions! Since what we are producing is just raster maps, going the extra stage via vegetation vectorization would just increase the processing time without giving us any additional information.
Jun 21, 2021 3:04 PM # 
MIclimber:
Stumbled back across this post, after a year or so on & off of searching online for info and playing around with the map making process, I've become fairly proficient and much more informed, still a long way to go in understanding everything in drawing and standards. But generally, from raw lidar I can go thru lastools to merge tiles and change data from feet to utm, which is most common where I am, to generating a new map via OCAD new map wizard and then also use's Terje's script to generate vector vegetation, to avoid that pixelated look OCAD uses. I found the key to Terje's process was to put in many bench mark points in the bench mark file. The time it takes to auto generate a map, is not insignificant, and further the time it takes to get a map accurate is a labor of love. For me, spending scores of hours field checking and mapping the old fashioned way is quite off putting. With all due respect to competition level standards and those that came before me, the best way for O to become more popular here in the US, is to make access easier. Having only a handful of people that have the knowledge and skills to make a map / be an event director, is in part a limiting factor for our sport growing. If I did not have the flexible time and passion I have, a normal person that perhaps is just basic computer literate would have given up trying to make a map from scratch nearly instantly. Some day perhaps all of these processes and platforms will come together in a UI friendly one run, less than hour, program or app, so that anyone who wants to make a map would be able to do so, with almost no training. Ideally even perhaps, just an Omap layer in google earth. For now, I'm pretty happy I've come this far and can get myself into just enough trouble to produce a useable map! Here's my latest:

Jun 21, 2021 3:28 PM # 
gordhun:
I have a question about that map snippet from Great Seal State Park. There is a lot of auto-generated green on it.
Does the green refer to the height of the vegetation in the area or to the thickness of the vegetation in the area? If the former what use is it to the orienteer on the run?
By the way using the menu
Import Open Street Map segment to OCAD using the new map wizard
Download and add relevant tiles from USGS already in .laz format
Place Strava heatmap segment in background and check for accuracy of trails
Use OCAD Background Online Map Service to trace in additional detail
gives you a pretty good map in a matter of hours.
You can't do this everywhere. It depends on the availability of LiDAR on theUSGS site and not all the country is covered but it definitely works in SE Ohio where that Great Seal Park is. I know I made a couple of maps in and around Athens OH a few months ago.
Jun 21, 2021 5:11 PM # 
Mr Wonderful:
Gord, some of the info on it is here. It's not just height.

http://tmsw.no/mapping/basemap_generation.html

I accumulate the number of points from each of the four relevant classes (Ground/Low/Med/High Veg) that hit in each 2x2 m square. After trying many different classifiers I ended up with a model where I look for the vegetation and cliffsrelative distribution of points in each height group. In order to get significant results I needed to average the distribution over a circle centered on each square, the averaging is weighted so that the central points are more significant, dropping down to zero about 5 m away.

gen-laz-vegm.pl -cores 4 tiles_classified\tile*.laz

The results of this can be very noisy, changing classification for every 2x2 m block, so I have to filter them with a second low-frequency pass, this was based on an idea from Jarkko Ryyppö's mapping generator which also employs a two-stage process.

In my code I use a simple majority vote for a center-weighted area around each block: Whichever classification is most common wins.


OCAD's can work well enough for local stuff too if you have some other map to calibrate your settings with, it's just awful to look at since it's blocky, for no good reason.

Dear OCAD, just generate editable, nice looking vegetation. I'm not going to spend 80 hrs field checking stuff for 100 people who will never notice and 3 people who could but won't care because they are happy to be out there. I'm not making WOC champs maps here! My audience is far better served by quantity over quality.
Jun 21, 2021 6:05 PM # 
MIclimber:
The auto generated veg is a representation of the thickness based on height sure, same as the contours are auto generated and are a representation of the ground data. It's not 100% accurate by any means, but save spending hundreds of hours field checking, it's pretty representative and usually accurate enough for the common person on the move. The beauty of Terje's script is that while out scouting controls, you can then easily come back to the pc and edit each matrices, but not have to spend the time to draw each and every veg location manually. Or even further if the area warrants a thickness change, simply add more benchmarks and reprocess. We typically gps all of our trails, as heat map is difficult to work with and also not always accurate. What you are saying is true, in a matter of hours you have can a map with current processes, my point above is, that is akin to analog, and we need to move to digital and be able to auto generate a map, in minutes not hours. There needs to be an all in one easy to use app, integrated with gps, that combines PP, OCAD, Veg scripts, Or, Livelox, Uslynigo, etc into one place. We (someone much smarter and more resourced than me) need to think about the future of how map making be made much much... much easier so that any one with some level of interest can partake.
Jun 21, 2021 7:33 PM # 
origamiguy:
I have read Terje's web page and I was able to create a small map for a Boy Scout camp, just to have something for a presentation and demonstration. That was a few years ago. I'm getting back into mapping. Are there any more comprehensive guides, like a Mapping for Dummies? There's a lot of information in Attackpoint, but it's all scattered.
By the way, I recommend Rapid Environment Editor for changing the Windows environment variables. If you do it a lot, like I do, it saves a lot of time.
https://www.rapidee.com/
Jun 21, 2021 8:02 PM # 
MIclimber:
Not that I found, hence why it has taken me many multiple attempts at getting a proficient process. And that is in part because it is fragmented to begin with and then within that multiple ways to do certain aspects. Lidar pre processing, then processing and drawing in OCAD, then probably additional veg work, then course design, all separate areas of advanced knowledge required. You probably have to learn lastools before you can do anything with OCAD. Which I have watched hours of YouTube for, thankfully that exists. But OCAD help should be labeled a table of contents, it is abysmal. Sadly I would have paid to take an online class from them in how to truly understand it’s capabilities, but doesn’t seem like that exists. There are still mountains I’m sure I don’t know yet. You have to know someone and cobble together forum posts here, and if you’re not already a developer or command line type person, well just getting perl installed as example is an accomplishment in itself.

For me I’m using lastools to prep the Lidar, then ocad to process and import from Open Street and draw water/depressions, use aerials to draw in as much as possible where still needed such as buildings and power lines, using Terje to create veg, my own garmin gps data for trails and special features, and then purple pen for event creation, in conjunction with google earth and Basecamp, for setting and design, and when using e punch, Or for live scoring. If anyone needs help on any of the steps feel free to email me.
Jul 1, 2021 1:32 PM # 
dofishman:
BSA Compass and the Boy Scouts of America are putting on a week long mapping course (Map My Camp) the last week of July. You are more than welcome to attend. I will report on what the course covers in August. I hope it will pull together the software that is out there, and put it into a nice package I can reference when I run into trouble.

Myself I am not a LASTools person and that is why I like OCAD over some of the other programs out there.

If you want to make suggestion on how OCAD can improve their mapping program I suggest you contact Brian Coleman the North America OCAD representative.
Jul 1, 2021 3:53 PM # 
gordhun:
I think there isn't one comprehensive instruction book for mapping and LiDAR because there isn't one way of doing things.
However there is one BEST way to start every orienteering map whether you are using Open Orienteering Mapper or OCAD. That is to open a new file in the mapping program of your choice. Then import the areas you want from Open Street Map. Later versions of OCAD make it particularly easy and convenient by providing a feature called New Map Wizard. Now it is important to know that what you get to import from OSM will depend on what people like you and me have previously uploaded to OSM. Sometimes you may just get the framework of the major roads around the area. Sometimes you get a lot of detail. US universities seem to have great information posted to OSM, as if they were geography department projects but nothing I have seem rivals the detail you will find for Moscow's Kremlin where individual benches, lamp posts, souvenir stands and more are already on the map. It is as if someone in Moscow had a sprint OI map of the Kremlin and loaded it to OSM. One point to keep in mind: OSM maps are oriented to grid north (or maybe it is true north) Doesn't matter. OCAD gives us the option to make the map oriented to magnetic north. Select that option!!
Okay in the US how do you load the LiDAR? There are lots of ways and it is situational - what can you find, where. My go to place is the USGS National Map Viewer. They give us an easy to use search tool that will tell us quickly whether they have the LiDAR tiles we are looking for or not. If they have it then for free you can download the LiDAR information as .laz files and directly import the tiles to that georeferenced map you started from Open Street Map. You get to choose the contour interval, whether you want vegetation information, slope gradient information, etc.
So you have a map with the OSM outline of roads and sometimes a lot more information and the LiDAR information of contours. Do you have an O map? Not quite yet.
Eventually you are going to want to go out in the field to check the map information against reality. However before you go there are two steps that help improve the map and save a lot of time, sometimes a hell of a lot of time.
1) Download and put in background a Strava heatmap for the area. This gives you a chance to check the OSM map trails against the trails that are actually being used by the folks in the area.
2) a) With OCAD go to Background Map - Online Map Service and for a geo-referenced map we get an air photo of the area, enlarged to our preference, placed in background and they become a tremendous source of additional information, particularly with regard to additional buildings, vegetation boundaries, ponds and the like.
b) With OOM I think you can get the same step by going to any air photo service, downloading what you desire and placing the photo in background.
How easy is it when you find the right files? Well last night while watching a hockey game I made one base map of an area of 7 x 4.5 km and then another of about half that size early this morning before going out to play golf.
So what is the gist of my advice here? Before you go messing around with LASTools and other less than user-friendly tools try see if you can find the ready made ;las or ;laz tiles.

Please login to add a message.