Excel data to make circles in 2Dplane is this possible?

Here is a first version that may work.

Result befor bake.

Excel reading

link for this plugin

Setup for the tags ( Tags) its the same for species and height

setup for circle at center

setup for interp. curve points

setup for the BS sorting

setup for baking on layer based on bs type.

for the text object i used elefront plugin.

the whole grasshopper canvas.

Hi,
@flokart
The grasshopper solution looks awesome, frightening in fact, how do you even understand all that, let alone know what to do, I am in awe of your skills, but I have zero experience in grasshopper, he needs maps now, Looks like something found in an UFO !
If I could take that and run it and out pops a map, fine, but I bet it involves my input. For you to create that is exceptional help and THANK YOU, if only I knew anything about grasshopper.

@Helvetosaur
@jeremy5
On the subject of normal Rhino coding, what would someone want to charge to code it so that excel file became that result shown with the data being allocated to the appropriate coloured layer as mentioned ?
I can then see if he is willing to pay for such.
PM me probably best.

Would the one off payment include any tweaking to iron out any initial issues ?

If it can be shown that the csv file generates the map result posted, and as Helvetosaur points out text placement tweaks etc are involved, that should be it. Perhaps his previous CAD operative moved some text by hand, or would it stay there when moved ?

I am win7 rhino 5 until I can get the PC rebuilt as the hardware is not enough for win10 but was fine for win7 rhino 5. I have had to go back to win7 whilst engineering time and money to solve that. Maps needed now though.

Cheers

Steve

Of course:
for the input - adress for the execel file.
for the output - choose the layer where you want the result.
but this needs also be done with rhino code.

I would never do it if the data is provided by someone who dont know how the data is used in the code…they mess up everything because of that.
In example in the excel sheet are sometime 3 values for the tree radius instead of one …i just skipped these excel cells and used a constant value…but first you need to detect them.

This is not a simple task …first is a text overlap detectection involved (simple) but then a rerange of the text with a minimal distance to the tree …difficult if there is not already a exisiting open source code available.

The grasshopper file is not too difficult and its possible for you to change it otherwise you have text code and its more difficult for you to handle it if something went wrong.
I can share the grasshopper file if you are interested.

Yes, no matter what you do, this is going to be a semi-automatic operation requiring a number of manual adjustments later - specifically concerning the text placements and avoiding overlaps. Also as @flokart mentioned, there are cells that have more than one value, specifically the trunk diameter in cm:

The .csv looks like this:

These cells will be rather difficult to parse, and assuming one can successfully, some sort of provision needs to be made - first value, average of values, etc. (I have something that looks like it works for this)

A scripted solution (as opposed to Grasshopper) is also possible, and advantage being that one has direct access to making layers, colors etc. in the document; the disadvantage is that it is not ‘live’ and so you cannot see the result in advance. However in any case, as stated above, you will still need to manually modify the Rhino file once all the text/geometry has been created/baked.

Hi,
V5 (V7 on win10 working if unplug all HDD and boot to) though win10 rejected usb_HDD_020 yet is fine in win7, 10 is a pain.)
V5 code if poss please.
Yes I can delete out multiple values or average them first myself. Then we have a csv good to go.

It will:-
…so column M sends the canopy to layer C2 or B2 etc etc.
I will colour that layer and thus they take on the grey red or green according to the BS cat.

Thats it, we have a map :slight_smile:

oh , and how does the easting northing B/C get to work with the dwg, as asked, as 0,0 is off the scilly isles, if thats a Rhino 0,0 then I will have a lot of scrolling to do !
my method could be…
If I establish the easting and northing in metres for the south west corner of the dwg base map, then subtract those E and N figs from the excel E and N figs after they are also con to metres, lets pretend the result is 1234 and 5678 (metres) place that corner of the map at 0,0, then circle tool initiate, enter R 1234, 5678 would place the circle at the trees location, diameter taken from the appropriate column.

and A has a TAG number and D a tree type, to be text placed at each tree.
Yes I am prepared to manually move tree text.
The original CADer charged variable rates so must have been doing some manual editing.

Grasshopper means issues, I sense it, because I have zero experience with it, also learning grasshopper, no time at present.

Just need to give the coding route for V5 (or V7 ) a go. V5 much preferred as my PC works in win7 ! as then I have access to all my normal PC not a thing intent on losing my usb drive DATA, I have no internal drives yet for win10.

yes agreed.

duplicate values were multi trunk, we take the biggest value only, I can delete out the other values manually before the code runs.

next step…
Please PM me a price for coding it. Please

Steve

See earlier post Excel data to make circles in 2Dplane is this possible? - #17 by jeremy5

A couple of notes/remarks:

In your original DWG file posted way above, there are the following layers/colors:

TREE_CAT_R - red(ish) 255,0,63
TREE_CAT_C - gray 132,132,132
TREE_CAT_B - blue 0,0,255
TREE_CAT_C_ROOT_PROTECTION - layer white 255,255,255 but all object colors 153,38,0
TREE_CAT_B_ROOT_PROTECTION - layer white 255,255,255 but all object colors 153,0,0
TREE_CAT_R_ROOT_PROTECTION - layer white 255,255,255 - all object colors by layer

From the above, it can be noted:
The colors seem a bit “sloppy”. Is the TREE_CAT_R layer supposed to be full red? The two dark red root protection layers “B” and “C” have color by object (the layers are white) but the two dark reds are not the same.

Also, the layers are named B and C not B2 and C2. The objects on the R layer are actually classified as U in the Excel file.

Regarding the X,Y coordinates in columns B and C: They are bizarre because they have 3 places after the decimal point - I would not expect that if the coordinates represented millimeters, because that would be indicating the coordinates down to the micron. Therefore I do suspect that they are in meters. If they are indeed in meters then they are relative to a geolocalized reference point quite a distance away - over 700 km. That issue needs to be resolved.

All the other dimensions appear to be in meters except the tree trunk diameter which is in cm.

As far as Rhino versions go, there is no method involved in this type of script that did not already exist in V5, so running it in V5, 6, 7 or later should not be a problem.

See my post above (16). These are Ordnance Survey co-ords in metres. The Ordnance Survey grid is the basis for all official mapping in the UK (see ordnancesurvey.co.uk). The area boundaries are shown somewhere (title block probably, not at computer to check).

Edit: You can feed the coordinates into Grid Reference Finder | OS Map as OS eastings and northings to see a local map.

Yes, thanks for the link. In fact the terms “Northing” and “Easting” imply the distances in those directions from the grid reference point, so it is logical that that point is at the southwest corner of a grid that covers entire UK… If you extend a north aligned line up from 0,0, you just touch the westernmost tip of Northern Ireland…

And if I enter the 5401 tree coordinates in the map, I do get a location in Scotland…

In any case the way to do this correctly is to create a file in meters that is georeferenced to the correct coordinates, and if someone wants to move the stuff away from that reference later, they do so at their own risk.

@Steve1

Here is a script to try. It runs in V5.
Note the following:

Everything is in meters and georeferenced to the UK grid coordinates.
There is no title block or anything like that.

I set the layer names/colors as follows (all can be changed):
TREE_CAT_R - red 255,0,0
TREE_CAT_C - gray 132,132,132
TREE_CAT_B - blue 0,0,255
TREE_CAT_C_ROOT_PROTECTION - dark red 153,0,0 (originally white but all object colors red)
TREE_CAT_B_ROOT_PROTECTION - dark red 153,0,0 (originally white but all object colors red)
TREE_CAT_R_ROOT_PROTECTION - white 0,0,0 (originally white)

I would suggest the root protection layer colors be changed to make stuff more readable.

The tree crowns will be circles if all the n,s,e,w values are the same
They will be ellipses if n=s and e=w.
Otherwise they will be freeform periodic curves passing through the 4 points
In the crown data there are missing entries or some are 0. Right now I substituted 0 for the missing entries, which makes a mis-shapen tree - already there in the existing file. I have a function wich can average this data and make something nicer but ‘fictive’. Where there are several trunk diameter values in the same cell, they are averaged.

The text blocks are one single block with three lines and carriage returns instead of the three separate lines in your example. This makes them easier to manipulate. Text height, font, justification and location are all settable. You will of course need to move these blocks around anyway where trees are dense. Default justification is left, middle and offset is 1 meter west and 0.5 meters north from trunk center.

Below is the base file in V5 with the original tree layers renamed and turned off. You can then test the script by importing the .csv and comparing the new data to the existing ones. Let me know what needs to be changed.

tree data Copy-csv.csv (34.4 KB)
Tree Report-Test File-MSH-V5.3dm (6.0 MB)
Edit: made a couple of refinements and reports if certain data is missing.
Edit #2:
Found a couple of bugs and added one new feature - all objects belonging to the same tree are now named with the tree tag (number). So to select all the elements of the same tree, just do a SelName and either type the number or choose from the list box.
ImportTreeDataV1.py (7.9 KB)

Edit #3:
Here is one last version which you may or may not prefer, it simply locks all the added geometry (circles, ellipses) except the text blocks, which facilitates dragging the blocks around while insuring nothing else moves. When done, just hit Unlock to unlock all the locked objects.
ImportTreeDataV1B.py (8.0 KB)

Hi,
@Helvetosaur

Not sure what you mean, as the excel file coords as you see take us to Fintry, so they are correct.
Georeferenced to the correct coordinates they already are, as they work.

As you see coords 0000, 0000 are in the Atlantic.

Q1. First task to do is place the .dwg base map on a layer in Rhino, where do I place its lower left corner in Rhino ?

If I place it at 0,0 then the trees will be plotted far away from the map.
If I establish the south west corner co-ordinates of the map and move it to those coords the map will be well beyond normal usage distance, probably off the inbuilt world boundary.
I have run the .py and I see the drawn items are 687095 North of Rhino 0,0, so 0,0 is in Aatlantic where OS 0,0 is.

I am of the idea to establish the coordinates in metres for the lower left corner, subtract the figs from the A and B values, and the resulting values are eastings and northings from the south west corner of the map.
This will make the code plot the trees on the map in the vicinity of rhino origin 0,0. :grinning:

I will make sure all data is in metres in the excel csv file.

The tree crowns will be circles if all the n,s,e,w values are the same
They will be ellipses if n=s and e=w.
Otherwise they will be freeform periodic curves passing through the 4 points

I like the tree shapes, I had pondered on a box and fit an elipse, then it needs four elipses and each trimmed to its quarter of the canopy, this is lovely that you have got, I must find out what a freeform periodic curve is ! :heart_eyes:
FURTHERMORE I compare shape of a tree and it matches the original CADer shape, so he also used a periodic curve. FANTASTIC. :heart_eyes: :clap:

In the crown data there are missing entries or some are 0.

Q2. I dont see any missing entries though ? please give examples.

I see however you have since adopted my mention of the largest figure is what gets used, looking at the .csv, so GOOD.

I see 0 0 0 3 and admit its most odd, as trees dont grow in one direction without growing a little sideways as well. He is to ‘have a word’ with the surveyors and revise such tree shape data, probably 0.25 0.25 0 3 giving a 0.5m wide canopy.

Q3. what happens if code finds a silly entry, does it crash or ignore or ?

Thats good, the way I would have created them if doing it by hand. Yes expect to move some around. The locked version is GREAT .

I will test what you have done , updating my comments as I do so.

This is great stuff. see PM

Many Thanks

Steve

Yes. Not the way to do this.

There is no “inbuilt world boundary” in this case. As you are working exclusively with curve and text data, distances far from the origin are not critical (as they would be for meshes) and things will still be drawn accurately.

I would absolutely not do that. As soon as you start moving things around you lose the geo reference and all can go pear-shaped rather quickly. The best approach is simply to leave everything where it is supposed to be and tolerate the large coordinates/distance from 0.

You can create a local saved CPlane that moves the local 0 to somewhere in your drawing, that’s a good thing to do if you keep the reference displacement stored in something like Notes for future reference. That way everything always stays correct relative to world 0/grid 0.

Note there are also supposed to be a dozen or so reference points in the file, but the layer they should be on - SURVEY_POINTS - (I think) is unfortunately empty.

It is simply a closed freeform NURBS curve that is also smooth at the curve seam (that’s the periodic part), so that it doesn’t have any built-in kinks. (In NURBS technical terms, a periodic curve does not have a full-multiplicity knot - a kink spot - at the seam). When you draw a freeform closed curve manually in Rhino, it automatically makes it periodic. Using MakeNonPeriodic on such a curve will introduce a kink spot at the seam. Make a closed NURBS curve, make a copy of it and run MakeNonPeriodic on one. Then turn on control points for both and see the difference, try moving the point at the seam.

5532 for example is missing an entry for south. You don’t pick this stuff up by eye, but the script does of course and throws an error if you don’t check for it (which is how I found this one).

No, the script does average the values if multiple values are found. For example 5521 has four entries:


They average out to 9 cm. If you find the tree after import, the trunk diameter is drawn at 0.09 meters. If you want the largest value however, I can change the script to do that.

I tried to anticipate as many errors as I could and find workarounds. If it absolutely can’t find critical data like XY coordinates, it simply ignores that tree number and goes on to the next. You will get a message box with an error report listing any skipped tree numbers when the script finishes. Hopefully the script should not error out ungracefully, if it does, I missed some error checking somewhere, post an example and I should be able to fix it.

The idea is always to have a robust tool, which means you have to build in a lot of error checking. In any case, it will never provoke a Rhino crash or loss of data, in the worst case the script just stops somewhere unexpectedly and you get some kind of arcane message on the screen. Hitting Undo undoes everything the script did.

Hi,
V5
I went through the cells and compared and every time the largest value only existed hence thinking you had coded it that way for tree trunk diameter. If you can tweak code then all the better.

When I come to create pdf of the map, from what I recall, of pdf making 0,0 has to be at the lower left of the pdf page, it wont do selected object. Also exporting something from Rhino intp Photoshop, 0,0 needs to be lower left of the selected items.

so a saved Cplane where zero is such would do the job.

It is most unsettling to open Rhino and plot something and its massive scrolling upwards to find it.
I am used to working with a grid turned on. so the grid will be massive.

I presume when Cplane is set to originSWmap any code run will place trees well off the map.

I will have to get used to it being a massive scroll exercise, or select all and zoom selected.

Print to pdf however will I am sure need a Cplane origin at map corner., so turn on the saved Cplane originSWmap

Steve