OS OpenSpace [logo]

OS OpenSpace Forum » OS OpenSpace » Newbie Area

Thread: How do I create a boundary layer with my own polygon data

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 3 - Pages: 1 - Last Post: 17-Sep-2011 14:32 by: Mike1408
Mike1408

Posts: 7
Registered: 10/08/10
How do I create a boundary layer with my own polygon data
Posted: 09-Sep-2011 11:20
  Click to reply to this thread Reply

I have digitised a set of 195 closed polygons covering GB and suitable for use with the MiniScale base map. They have been prepared in JSON format like this:
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "id": "1", "name": "WST", "geom": "POLYGON (( 576233 158294, 582060 156180, 588033 153431, 593372 150890, 598081 148890, 600896 145765, 603963 142435, 603963 142435, 605250 146306, 605803 150412, 608388 154346, ...........etc..........ending, 195 polygons later.....
412178 437681, 414286 440877, 416570 443283, 418202 444599, 420061 445329, 420061 445329, 419603 449807, 419210 452454, 418219 454315))" }, "geometry": null }

]
}

My question is - what do I do next to generate a boundary layer with this file? I seem to remember somewhere reading that this could be done and that it would reside on the OS server and that it might be henceforth 'owned' by OS. Can anyone tell me if the above is in the right format for the job and how to proceed? Assuming that I can indeed use it to create a 'private' boundary layer for my own web site, I am presuming that everything else I want to do with it (e.g. hover control with name display) will be available as normal and it will be 'simply' a matter of me learning enough about scripting to understand the tutorials and, with the help of Forum experts, developing my site. But, first things first, what to do with the JSON file? And are there some limitations/complications I should be aware of e.g. how easy would it be to edit the polygon set if it resides somewhere else?

CharlesHarrison

Posts: 488
Registered: 28/08/08
Re: How do I create a boundary layer with my own polygon data
Posted: 09-Sep-2011 16:35   in response to: Mike1408
  Click to reply to this thread Reply

[nobr]> I have digitised a set of 195 closed polygons
> covering GB and suitable for use with the MiniScale
> base map. They have been prepared in JSON format
> like this:

Is this actual proper GeoJSON? I ask because if not it will probably need to be.

> {
> "type": "FeatureCollection",
> "features": [
> { "type": "Feature", "properties": { "id": "1",
> "name": "WST", "geom": "POLYGON (( 576233 158294,
> 582060 156180, 588033 153431, 593372 150890, 598081
> 148890, 600896 145765, 603963 142435, 603963 142435,
> 605250 146306, 605803 150412, 608388 154346,
> ...........etc..........ending, 195 polygons
> later.....
> 412178 437681, 414286 440877, 416570 443283, 418202
> 444599, 420061 445329, 420061 445329, 419603 449807,
> 419210 452454, 418219 454315))" }, "geometry": null
> }
>
> ]
> }
>
> My question is - what do I do next to generate a
> boundary layer with this file? I seem to remember
> somewhere reading that this could be done and that it
> would reside on the OS server and that it might be
> henceforth 'owned' by OS.

No, the simplest thing, unless there are other reasons not, is to save it in the same folder as the web page that needs the data.

> Can anyone tell me if the
> above is in the right format for the job and how to
> proceed?

It needs to be one of the recognised OpenLayers data formats. You should be able to test it using my Features Editor & Convertor (bottom link in this post):
https://openspace.ordnancesurvey.co.uk/openspaceforum/thread.jspa?messageID=2819&#2819

1) Set a location somewhere in the middle of the UK
2) Create the map and zoom out to cover the UK
3) Set the read format and projections (the former is probably GeoJSON, the latter can presumably be left to default to OSGB.
4) Paste the data into either of the text buffers and press the corresponding Read button.
All being well, the features should then appear on the map.

If the data is ok, then you can read via OpenLayers.loadURL as per this post:
https://openspace.ordnancesurvey.co.uk/openspaceforum/thread.jspa?messageID=2350&#2350

> Assuming that I can indeed use it to create
> a 'private' boundary layer for my own web site, I am
> presuming that everything else I want to do with it
> (e.g. hover control with name display) will be
> available as normal and it will be 'simply' a matter
> of me learning enough about scripting to understand
> the tutorials and, with the help of Forum experts,
> developing my site. But, first things first, what to
> do with the JSON file? And are there some
> limitations/complications I should be aware of e.g.
> how easy would it be to edit the polygon set if it
> resides somewhere else?

If you only want to make trivial changes, my Editor above may save you the trouble of writing anything else specifically to do it.[/nobr]

ianholt

Posts: 10
Registered: 01/05/09
Re: How do I create a boundary layer with my own polygon data
Posted: 09-Sep-2011 16:51   in response to: Mike1408
  Click to reply to this thread Reply

Hi Mike1408,
Firstly, the good news is that OpenSpcae is based on OpenLayers so examples for the the latter should work with the former (though beware of versions, Open Space is currently based on OpenLayers 2.8).

Anyway, here is an example of OpenLayers loading geojson:
http://thinkwhere.wordpress.com/2011/06/26/geocommons-geojson-in-openlayers/
or specifically:
http://geothings.net/geoiq/ol_gc.htm
So you can look at the code and replicate.
Some examples sites to look at:
http://trac.osgeo.org/openlayers/wiki/UserRecipes
http://openlayers.org/dev/examples/
The OpenLayers 2.8 examples are here:
http://dev.openlayers.org/releases/OpenLayers-2.8/examples/
for example:
http://dev.openlayers.org/releases/OpenLayers-2.8/examples/geojson.html

Next, at OS we do not host anyone's personal data, so you would need to host it yourself, but that shouldn't be a problem.

Things like hover controls can be done programmatically, when you are at that stage we may be able to point you in the right direction.

Next, 195 polygons seems quite a lot to me, but I suppose it depends on the number of vertices. You have a number of questions around editing the polygon.

As for editing and saving, you may want to take a look at this example:
http://www.peterrobins.co.uk/it/oledit.html
http://maps.peterrobins.co.uk/files/ol6.html

I hope that gives you a start.
Thanks,
Ian

Mike1408

Posts: 7
Registered: 10/08/10
Re: How do I create a boundary layer with my own polygon data
Posted: 17-Sep-2011 14:32   in response to: Mike1408
  Click to reply to this thread Reply

Many thanks to Charles and Ian for their helpful replies. Sorry to be late in acknowledging - only just got back to the keyboard. Will report progress in due course.

Legend
Expert: 51 - 1000 pts
Advanced: 31 - 50 pts
Intermediate: 16 - 30 pts
Novice: 5 - 15 pts
Newbie: 0 - 4 pts
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums