Browsed by
Month: July 2012

Unintentional Art? – QGIS + Generalizer + Lines to Polygons

Unintentional Art? – QGIS + Generalizer + Lines to Polygons

Not exactly what I intended (I’m trying to turn paper drawings into vectors) but I quite like the result…

When Maps go Wrong?

CityEngine 2012.1 New Features & I was right…

CityEngine 2012.1 New Features & I was right…

Okay please excuse me whilst I engage smug mode …. perhaps I should ask for more in my blogs!  If you’re not sure why I said that, read this: “Will you SketchUp your CityEngine, please?

The new 2012.1 CityEngine!

Okay so I was asking for it to be made easier to use, not to just put in some rudimentary 3D modelling/editing tools into CityEngine (like SketchUp’s…), but it’s a start!

Push/Pull tool anyone?

As this screenshot from the Mid-Morning Plenary at this years ESRIUC in San Diego shows that’s what they’ve done.   I hope they made it so that the model you create is described as a CGA rule so you can use it elsewhere but I doubt it..

Looks like there might be some distance measuring capabilities in there too at last, as it’s a much needed feature.   When a manual model is created it seems that the length of the line is displayed.

There are some other icons also along that toolbar as well so I’m very curious to know what they are.

One thing that puzzles me is the lack of a beta program for CityEngine, I’ve asked and been told there isn’t one.  However the guys at Honolulu seem to be getting the latest releases… is this a government customer thing?

I’ll be posting more on this later and perhaps some thoughts on what the guys in Honolulu are doing.  I’m particularly interested in there public consultation ideas…

A CityEngine Project Update

A CityEngine Project Update

My CityEngine rules are really coming on now but I need time to think about how best to write the rules.   One thing I have started to learn is it’s really important to identify early on what attributes you want to control and which elements of the model you want to switch off.

You can use the case statement and an attribute with a true of false value to create that switch.   In practical terms it means you can fold many rule files into one, and at the flip of a switch reveal attributes that were previously hidden.

The example here shows my urban area (somewhere in a modern sub-division in the Middle East) in basic Google Earth style, but flip the on switch and the same model is now coloured according to a set of rules testing the lots area, red is too big, turquoise is near to the required lot size and green is within the lot area range I want.

Forget my choice of colour, this is a genuinely useful rule, being able to see what impact changes in the rule file are having is fantastic (but only if you’re a planner I suspect).

CityEngine’s power really comes when you see it as a design tool, it is by no means perfect but you can quickly set up a rule file and see the results of your ‘rules’ or planning standards very quickly.   What I hope is that ESRI allows ArcGIS to get some of CityEngine’s functionality, especially the dymanic street network capabilities of setting road and pavement widths…

I may put up a video showing just how quick this model refreshes itself… it’s interesting seeing how CityEngine runs the rule over you model colouring each model in turn…

Excel Macro – Convert Cell Fill Colour to Hexadecimal Code

Excel Macro – Convert Cell Fill Colour to Hexadecimal Code

Exciting code being posted today I know, this is related to a previous post (CityEngine rule creation using Excel) but could come in use in other projects that use hexadecimal colour codes…

First create a new macro called “ConvertToHex” and use the following code:


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim str0 As String, str As String
Dim cel As Range
For Each cel In Selection
str0 = Right("000000" & Hex(cel.Interior.Color), 6)
str = Right(str0, 2) & Mid(str0, 3, 2) & Left(str0, 2)
cel = "#" & str & ""
Next cel
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

Customize your toolbar and add this macro as a button, then select a cell and change its fill colour, then making sure you’ve still selected the colour cell press the macro button or run this macro, voila it should write in the cell it’s hexvalue!

A quick Python Label Expression in ArcGIS

A quick Python Label Expression in ArcGIS

Well I’ve been wanting to label certain features based on certain attributes (I  know exciting stuff), ArcGIS allows you to do this and until release 10 you were scripting this in VBScript.   Of course everyone is going Python now so I’m starting to use it…  The following is really a note for me to come back to, but it may help or interest others….

Right-click your layer you want to label, in the Layer Properties dialog box select the Labels Tab check Label features in this layer and click on the ” Expression Button”.   In the Label Expression dialog box select Python as the Parser and check the Advanced box.

Use this code:


def FindLabel ( [DistrictName], [QuarterCentre] ):
	if [QuarterCentre]:
		return  "<BOL><UND>"  + [DistrictName] + "</UND></BOL>"
		return [DistrictName]

Ensure you’ve tabbed everything as well, make sure you declare all the fields you want to use at the top. This basically checks the QauarterCentre field and if it has a value Bolds and Underlines the label.  Otherwise it just labels the feature.   To do the opposite you can use “if not [QuarterCentre]”.

For more information goto the ArcGIS 10.1 help here.

CityEngine rule creation using Excel

CityEngine rule creation using Excel

Okay I’m a planner so I use Excel a lot especially for population statistics and analysis of landuses and planning standards.   It would be nice to turn some of our planning standards tables into rule files for CityEngine to make.  For now though I’m trying out a number of workflows to test plot sizes.

What I wanted to do was choose the colours of my plots based on its area, this method allows me to pick a cell fill colour in Excel and run a macro over it to create the hex code which using the magic of CONCATENATE function creates the correct syntax.

The Excel sheet you see above can then be copied and pasted into a CGA rule file in CityEngine, the results below show that the colours I’ve choosen have come in well in CityEngine….

Why use this method?  Well I’m thinking of combining some of our data within CityEngine and this could be a handy way of doing it.   Here I can relatively easily copy additional test areas once and excel, using formulas, can create the rest of the rule file.

I’ll be posting a test Excel sheet soon here, as well as the macro code for take a cell fill colour and creating the hexadecimal code from it.

UPDATE(02/08/2012) You can download the Macro-Enabled Spreadsheet from this post.