Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

First at all, I want to say that I am geocoding enthusiastic but have no formal background on GIS. I'll do my best to use the right wording and make myself clear what I am striving for.

Also the only tool I have available for this task is Python. This is a project I am working on in my own time but hopefully will kick off at work if I manage to produce something meaningful.

I have downloaded the Code-Point® Open from the Ordnance Survey that contains postcode units (~1.7M) for Great Britain and converted eastings & northings to Lat & Lon in WGS84.

From postcodes I've also created sector, district & area levels and a custom level that regroups areas into North, South, East & West. So my final product is a csv file that contains the levels mentioned above plus Lat & Lon. The granularity of my file is postcode level

What I want to do is to create a layer for each level and then use them later on TileMill or google map in order to create a thematic map where each patch/polygon will change color based on specific events.

In my view, what I need to do is to group these coordinates based on each level, create a collection of polygons and then create or export them as a layer (or shapefile??).

I've been looking to Shapely but I am not sure whether is the right tool for it and online examples don't make much of a sense to me due to my lack of knowledge on this matter.

Can anyone please point me out on the right direction or provide me with a small piece of code as example?

Any advice will be highly appreciated!

[EDIT 1]

I created my layer as per the below instructions but can't see my area polygons yet.

enter image description here

[EDIT 2]

I've all over again 3 times and still don't get to see the polygons - I've checked my csv file and the area column has values as expected (120 areas). Here it is another screenshot with layer metadata.

enter image description here

And here it is a screenshot with all layers apart from original - it shows nothing.

enter image description here

[Edit 3]

Query option disabled.

enter image description here

[Edit 4] After 4hrs processing I get to see my polygons:

In summary these are the steps:

  1. Import csv file
  2. Export file as shapefile
  3. Re-import shapefile (could be new on a new project)
  4. Apply the query logic
  5. Apply the Convex Hull and wait.
  6. that's pretty much

enter image description here

share|improve this question
1  
When you say you only have python is this a restriction based upon restriction on installed software at your work computer? When I started our GIS program at my workplace I used QuantumGIS it is free and you could do this in a few minutes with it. Without, we are talking about heavy-heavy math programming if it is even possible without installing third-party modules. –  RomaH Nov 24 '12 at 2:21
    
Yes, that's correct - but I can install it in my personal laptop and once I have the layers (I presume these are shapefiles) I can use them in TileMill or googlemap (I guess for GM I need to export them in a diff format like geoJSON?) without having QuatumGIS? –  Altons Nov 24 '12 at 9:15
    
You have already the data in a CSV file correct? With lat/long for each point? If so QGIS can handle CSV data nicely and we can create polys from there and export to any desired format. I will post an answer explaining how you can once you can get QGIS on your laptop. –  RomaH Nov 24 '12 at 14:55

1 Answer 1

up vote 3 down vote accepted

With your complete CSV file in hand and QGIS installed on your laptop this is what you need to do. Sorry if this seems like much if you haven't used QGIS before, but use it and learn it; it will be your best friend in this stuff.

You want to use Add Delimited Text Layer. If you cannot find it on your plugins toolbar you might need to activate/install from Plugins > Manage Plugins or Plugins > Fetch Python Plugins. Start import row as needed to avoid titles and finally set XY Fields to their appropriate columns. If it is every Postal Code in GB then it might take a few seconds to render unless you have a powerful laptop; in this case I would turn off the render engine but since you are a novice, seeing what you are doing helps you understand the process.

enter image description here

This should result in a layer with a bunch of point data, and if you go to the Attribute Table you should see all of your extra fields as well.

Now go to Vector > Geoprocessing Tools > Convex hulls. Select your point layer as input. Select Create convex hulls based on input field, select the field upon your polygons will be created and select a save file name for the new layer. The result should look similar to below.

enter image description here

Now you have your polygons based upon your nodes and your selected column. You just repeat for each column value and create layers until you have all your desired polygon. In this example I created the polys based upon a field in the point layer where I assigned groups of points values 1 through 3.

Here you can see some issues you might need to remedy.

First, all outside points define the edge of the poly. It may look odd but if you are just using the poly as an aggregation symbol it shouldn't be a problem. You can remedy this by apply Vector > Geoprocessing Tools > Buffers first and then using the resulting layer to build the hulls off of.

Secondly, you might have some overlaps which we will fix with hand digitizing, and thirdly we have some gaps (which may not be an issue for you) which we will fixing with digitizing as well.

Select your layer and click the edit layer button. Go to Edit > Snapping Options. Activate snapping on your layer, to vertex, and set the tolerance to a setting that seems right for your work. You may have to change a few times, depends on your zoom level and resolution for your work.

Now select nodes of the polygon and move them to suitable locations to avoid overlap and gaps. Use the snapping function to create seamless, juxtaposed polygons. I may want to turn off your point layer to make it easier to see the poly nodes. You can double click a polygon's border to create new nodes if you need them. Click your Save Edit to save your work occasionally and then clicked the Edit Layer to finalize your work.

The de-facto format for layers is the Shapefile. but you can right click and save Save As... your file to many formats. Save your layers to whatever is best for your needs.

Learn to use QGIS it will make quick work of such things and won't require (most of the time, ha) you to create complex workflows to complete tasks.

A word about online mapping; It sounds like you are doing what did, starting from a budget of nothing. Google Maps API's term-of-service don't allow closed network use unless you have a corporate license, which cost money. OpenLayers and LeafletJS are free map APIs but don't have the map tiles built-in like Google's. But there are many tile service out there, most which work with OpenLayers and LeafletJS, but look and see which will fit your needs the best. You can visit Open Street Map's website for information about some free services. If you have a medium-sized company that isn't passing out your information like candy, usage will be low and you can safely use these without making a system admin mad.

In any case you will need to pickup some knowledge of Javascript, HTML5, web development, etc to effectively create online maps if you don't know this already.

If you are not comfortable with this just quite yet look at using QGIS' layout designer and just create some printed graphics with your data. The layout designer is a little primitive to say that of InDesign or ArcGIS but it still very nice. If the data doesn't need to be bleeding-edge updated, say once a month, this might work for now.

share|improve this answer
    
Thanks for the detailed explanation! Im just working my way through GDAL, GSL & QGIS installations (I have a Mac). Will come back to you asap - thanks again! –  Altons Nov 24 '12 at 18:52
    
RomaH: I followed all the steps and have 2 layers, one with 1.7M postcodes and another with the area polygons - my problem is I can't see the area layer. when I unselect uk-area-latlng (csv file) then I got blank in the frame. –  Altons Nov 25 '12 at 0:26
    
Oh I may have forgot a caveat. I am not at my computer to test but right-click and save your CSV layer as a shapefile, and import the new shapefile to build your poly off of. Let em know if that works. –  RomaH Nov 25 '12 at 2:41
    
Nope nothing. I've added another screenshot with the metadata - hopefully will give some clues of what's going on. –  Altons Nov 25 '12 at 10:30
    
Are you using version 1.8? If so, I am having similar issues here at home. When I DO get it to work, it skips creating the first region and creates the others. Maybe a bug, I'll look on their tracker and report it, though the log doesn't report a problem. However, I think I maybe found a workaround for it. Right-click your points layer and select Query and enter YourFieldName != ''. It should return any point that isn't NULL in that column. When I ran the convex hull on this, it created the polys without a problem. –  RomaH Nov 25 '12 at 18:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.