Rotating all spatial features through 180 degrees

40 views
Skip to first unread message

Ian Oldfield

unread,
Jan 15, 2021, 4:27:41 AM1/15/21
to MapInfo-L
Hi,
At the risk of a suggestion that I possibly should be sectioned under the Mental Health Act, I am seeking advice on the possibility of rotating my data (bitmap, text, lines, polygons, labels) through 180 degrees, ie. to literally turn the map, etc upside down.

Here's my mitigation:  I am developing a fictious set of data (which I'm calling synthetic data) for the purposes of AI,ML development and analytical training.   The data is based on police-related scenarios, so whilst all the related features are completely fictional, the work has been done againts an OS open data map  but with road names removed, physical features changed and moved, along with adding artificial postcode polygons, etc, etc.

To improve anonymity and alignment with real-world places and people, I am examining the possibility, practicality and desirabilty of rotating the data.   For those suggesting I should have started with this, yep, I agree, but there is now 3 years effort!

Any advise, including amusing comments :-) would be appreciated.

Thank you

Ian Oldfield
ian (at) mapbrix.net

Warren Vick

unread,
Jan 15, 2021, 5:18:35 AM1/15/21
to mapi...@googlegroups.com

Hello Ian,

 

It’s been a while and I hope you’re well (i.e. not yet sectioned).

 

I would, of course, yield to any antipodean members in the group on “upside down maps” 😊 but it’s fairly straight forward to flip data with a horizontal plane. There may be a tool out there already, but a MapBasic program can iterate through the rows of a table, store the geometry object in a variable and then loop through all the coordinates. It’s important to remember that points/polylines/polygons can be “multi” in nature, so there would be an outer loop to go through the “parts” and an inner loop to iterate through the coordinates. With each coordinate, extract the x/y and then apply a transformation to the y coordinates. It could be as simple as y = MAX_Y – y. Once you’ve processed a single object, perform a SQL update to store the new geometry (usually using rowid).

 

Bitmaps may be a little harder unless there is any built-in transformation feature in Pro that I’m unaware of. Text objects may be slightly more complicated too since you’ll not only want to transform their position, but probably also orientation. e.g. 45 degrees -> 135 degrees. Horizontal labels will, however, probably stay that way unless they really need to be upside down due to representing something (e.g. in MasterMap Topo the building numbers are aligned on to the road the property belongs to).

 

Hope this helps.

 

Regards,

Warren Vick

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/e9652692-ac98-4dc0-a992-430602dee099n%40googlegroups.com.

Peter Horsbøll Møller

unread,
Jan 15, 2021, 5:27:55 AM1/15/21
to mapi...@googlegroups.com

Also remember that MapInfo Pro comes with a number of tools for rotating and mirroring objects.

 

Found in the Transform dropdown on the Spatial tab.

Just remember to use the same point to rotate the objects around.

 

 

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Warren Vick
Sent: 15. januar 2021 11:18
To: mapi...@googlegroups.com
Subject: RE: [MI-L] Rotating all spatial features through 180 degrees

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

 

Martin Hodder

unread,
Jan 15, 2021, 6:00:57 AM1/15/21
to mapi...@googlegroups.com

Hi Ian,

 

It sounds like an interesting project!

 

I am not sure why you would rotate the bitmap because that would still have all the data in the right place but just upside down – or maybe I misunderstand what you are trying to do. If you are trying to rotate each individual feature then I think that would have to be a MapBasic program. Of course points would not change much. Another option is to apply a random distribution offset for the points.

 

However – if you want to “flip” the dataset then I would export to MIF. Edit the MIF to add a TRANSFORM clause.

 

Use TRANSFORM 0,-1,0,0

 

And in theory that would flip the data by 180 degrees which give an upside down type map. I am not sure what use that would be.

 

A more complicated approach would be to apply an affine transformation to the data.

 

Regards

 

Martin Hodder

Higher Mapping Solutions

www.highermappingsolutions.com

 

From: 'Ian Oldfield' via MapInfo-L <mapi...@googlegroups.com>
Sent: 15 January 2021 09:28
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Rotating all spatial features through 180 degrees

 

Hi,

--

Ian Oldfield

unread,
Jan 15, 2021, 6:01:27 AM1/15/21
to MapInfo-L
Warren, Peter,

Thank you so much for your prompt and helpful replies.   I'm quite happy with the bitmap rotation, just need to edit some of the labels in PaintShop Pro or similar (I'd already 'rubbed out' over 1,000 roadnames and replaced them with text in Mapinfo).  Took about 10 mins....or actually was it nearer to weeks? :-{  The things you learn about labels and MIF/MID files!

I'll experiment with a small subset, look at the Transformation tools and let you know how I get on.

Kind regards

Ian.

Warren Vick

unread,
Jan 15, 2021, 6:09:50 AM1/15/21
to mapi...@googlegroups.com

Hi Ian,

 

Just a follow-up to say that “flip” (which I think is what you want) and “rotate” are different, unless the rotation is of the entire map (like a raster) rather than object-by-object.

 

The transform option highlighted by Martin looks useful, but I guess it depends on whether you want to just view the map flipped or permanently set it in the underlying data. It your AI/ML methods are using the coordinates, it’s important that the engine receives transformed coordinates.

 

/W

Ian Oldfield

unread,
Jan 15, 2021, 6:11:30 AM1/15/21
to MapInfo-L
Hi Martin,

Thank you too.   I think you have a bit more knowledge on what I'm doing, but essentially I'm using a 5kmx5km bitmap of a part of London, so I want to make it less obvious to those of us with a good sense of the geography, even without labels.   Whilst I have changed every street name, handcoded both the point data for housing and created 1500 postcodes by hand, it is apparent in many cases what the real-world address would be.  If I'm to suggest Mr Smith is a robber and lives at 22 Madeup Street, but it's apparent where that actually relates to, I could get some flack... or worse.

I appreciate your steer on how to do the flip, thank you.   Worse case (for me), I might have to finally pay for this and your previous help!

Kind regards

Ian

Ian Oldfield

unread,
Jan 15, 2021, 6:19:02 AM1/15/21
to MapInfo-L
Hi Warren,

If it makes sense, I want to literally turn the whole data upside down (N -> S) - the bitmap as I mentioned is simple - but I have c.200,000 points,objects, lines, text.   It will need to be properly orientated so all the coordinates / text angles, etc are aligned/compliant.   I added over 1000 road names by hand, rotating and resizing them and then added 1500 postcode polygons, again by hand, so it would all need (if possible) to re-align.   As you will gather, as well as the bitmap, I have about 45,000 ITN segments so again, these will need to rotate and be correctly labelled (with my synthetic road names).

As mentioned, I'll do some experimenting and then.... call for help!

Thank you

Ian.

Martin Hodder

unread,
Jan 15, 2021, 7:18:37 AM1/15/21
to mapi...@googlegroups.com

Hi Ian,

 

In that case the MIF transform should work. You will need to use the 4 parameter to move it back in position so if it a 2500m tile then something like

 

TRANSFORM 0,-1,0,2500

 

Should flip then move back into position but flipped.

 

As I said I have not actually tried it but in theory that should work.

 

However the text will be the difficult one to know if this will work as it is handled in a slightly odd way in MI.

 

Let us know how it goes!

 

Regards

 

Martin Hodder

Higher Mapping Solutions

www.highermappingsolutions.com

 

From: 'Ian Oldfield' via MapInfo-L <mapi...@googlegroups.com>

Sent: 15 January 2021 11:19
To: MapInfo-L <mapi...@googlegroups.com>

Image removed by sender.

image002.jpg

Ian Oldfield

unread,
Jan 15, 2021, 11:22:09 AM1/15/21
to MapInfo-L
Hi Martin, Warren, Peter,

I have yet to test Martin's proposal, but a quick & dirty experiment is looking promising.   I firstly flipped the bit map (doing a N-S mirror as rotating didn't work as desired) and then put a cross-hair on the centre using the cosmetic layer.   In turn, I selected the text layer (my road names) and then the postcode polygons and for each one used the MapCAD rotate Objects tool, clicked on the cross-hair accurately and then rotated left 180 degrees.   I probably would need to make some adjustments to about 5-10% of the text labels but overall very pleased.

I will try Martin's suggestion (if I can work out how to add the command to the MIF file) and see if that creates a 'cleaner' result.   The tile is 5000x5000.

Of course, I need to edit some of the bitmap labels, but in terms of the overall job that's a breeze.

I am so pleased with this, thank you all so much.  If I complete all the geometries satisfactorily it will hugely reduce the risk of upsetting anyone.    A sample of the output is below, anyone guess where Grosvenor Common actually is? :-)

Kind regards

Ian.

Flipped_Map.png

Ian Oldfield

unread,
Jan 17, 2021, 8:10:41 PM1/17/21
to MapInfo-L
Gents,

I used the MapCAD - Rotate Objects tool using the centre of the bitmap as the origin for rotation (the centre is 527500E, 172500N)   One major setback is the limit on the number of objects that it can handle; that said 10,000 rotated okay but there appears to be a bit of 'drift' with the data which ends up in some cases a few metres further East and North than expectation but that assessment is against the raster which may have been affected by the rotation.  Likewise, some of the text was a little adrift but I managed to re-position with a couple of hours effort.

The c.1500 postcode polygons appear to have rotated very well (as in, line up with underlying raster) as can be seen in the map above but I've yet to process the line (road) data.

In dealing with the point data and being more at home with Excel or SQL than MapBasic my calculations to rotate the point data are:
If X1 > 527500 then X2 = 527500-(X1-527500) else X2 = (527500-X1)+527500
If Y1 > 172500 then Y2 = 172500-(Y1-172500) else Y2 = (172500-Y1)+172500

I have yet to test this beyond a very small sample but it appears to be okay.   Any further advice/suggestion/code snippet greatly appreciated.

Thank you again for your time and expertise.

Kind regards

Ian Oldfield

Reply all
Reply to author
Forward
0 new messages