26

I am looking for a small-scale and easy way to present one or more polygon shapefiles online (on a municipal website without any existing map-server infrastructure, to be precise). Right now, I'm doing all work with QGIS, and I would prefer to stay all open-source (there is no budget left for any big software investments).

Researching this topic resulted in a overwhelming number of possible approaches, and left me quite confused. What I am looking for is

  • being able to show categorized polygons in a thematic map (- if possible, it would be nice to get popups or to be able to retrieve attribute information - but that's highly optional)
  • I would prefer to do most work (styling, etc) in QGIS
  • OSM as base map would be perfectly fine

So far, custom map tiles on an OSM base map look like the thing I'm looking for (or is there a better solution)? What would be the best way to create these tiles?

3
  • 2
    Does it have to be a Raster based (Web tiles) solution? Would it be okay for a vector solution?
    – Mapperz
    Commented May 18, 2011 at 14:30
  • No, not at all. I just figured it would be the easiest way (create tiles, create index.htm or code block to paste into existing web page, copy to server directory, done). I worked with GMapCreator once before on a private project, and it was a very quick way to get things done.
    – SAnderka
    Commented May 19, 2011 at 14:01
  • How many polygons in your shapefile do you have? If its under 1000, maybe @Mapperz's comment on a vector solution is the way to go. The simplest solution is to use the Google Maps API to draw polygons and create information pop-up windows--no need to create and store non-interactive tiled images. Tiled images of a map are best for highly dense information such as showing satellite imagery, roads, or census tract boundaries.
    – b_dev
    Commented Jun 13, 2011 at 5:16

6 Answers 6

15

For a simple way to do this starting with QGIS you could use QGIS Mapserver which can serve maps that you design using the normal QGIS interface. Alternatively you might want to go with GeoServer which is Java based and probably easier to install. Since both programs serve maps using open standards if you start with one and need to switch later there is no need to change the client.

Once you have a system set up to serve out WMS maps you'll want a client front end. I'd recommend OpenLayers as it is pretty simple to get started with and easily expandable. It handles WMS, WMST and OSM tiles with no problems.

Ultimately you may need to move to tiles for your WMS layers (say you start getting more than a 50-100 requests per minute on reasonable hardware) then you'll want to look at putting a tile cache in front of the map server. If you used GeoServer then you can use GeoWebCache which is built in or you could use TileCache.

8
  • My problem is that I'm working as a freelance advisor within a municipal administration at the moment. The local IT staff is quite thickheaded and tries to keep all sorts of "suspicious" opensource-stuff from their machines (I fought a long long battle for QGIS). Therefore I really would like to avoid any solution that needs to be installed as a "software" on the municipality's webspace.
    – SAnderka
    Commented May 19, 2011 at 14:08
  • My dream solution would be something I can prepare on my own and just copy to their webspace, insert in the html/JS-code and be done. Whether it's raster or vector data doesn't really count in the end. I'm the only one understanding the technical difference anyway... And all everybody else cares is a nice and easy presentation of our data for our citizens.
    – SAnderka
    Commented May 19, 2011 at 14:15
  • 1
    you just need to explain to them that web mapping is not something you can do easily with no software. Sure you can throw some simple tiles on a web server but it won't look good at all scales, it's hard to maintain and difficult to add features to when the mayor wants more.
    – Ian Turton
    Commented May 19, 2011 at 14:16
  • So, I looked into Geoserver (as a part of the Open Geo Suite package), and it looks pretty good. I imported my shapefile, styled it, even got the preview running on localhost. But how do I get these maps online on my webspace? Am I missing something? Bookmarks etc. obviously won't work since they refer to my local harddrive. I worked my way through all possible tutorials and how tos, but that topic never seems to be discussed? Could someone point me in the right direction?
    – SAnderka
    Commented May 22, 2011 at 16:46
  • you put GeoServer on your web server and copy the data directory from you local machine over to the remote machine.
    – Ian Turton
    Commented May 22, 2011 at 17:30
8

being able to show categorized polygons in a thematic map (- if possible, it would be nice to get popups or to be able to retrieve attribute information - but that's highly optional)

I would prefer to do most work (styling, etc) in QGIS

OSM as base map would be perfectly fine

All this can be done within QGIS and the ogr2layers plugin. The workflow is simple:

  1. Style your data in QGIS. Use the old symbology as I had issues with the New Symbology when using the ogr2layers plugin.

  2. Launch the ogr2layers plugin and define the openlayers settings (such as map size, map controls, basemap, etc). This will create a directory containing the index.html and your data layers converted as geojson files.

  3. Upload the directory into the webserver.

Note that this is only for simple webmap. For creating custom basemaps and other webmapping features, check out iant and Peter's answers.

2
6

Another option is TileMill -- it supports tiling, interaction and cartography in an easy to use web-based interface, including style definitions in a proto-CSS language called cascadenik. Using TileMill, you can crank out mbtiles files which can be consumed with something like TileStream. That said, there are still some tricks with deployment of the mapped outputs, but this would give you a nice platform for generating high quality tiles.

1
  • Watch their demo video on the front page, it's very impressive!
    – joshdoe
    Commented May 19, 2011 at 11:35
6

I decided to provide some information on which way I finally went for my tiled map service. Pure JavaScript and GeoJSONs weren't a solution, because I have to handle roughly 40k polygons and 33k points. So I went for tiling. Oh, and I still don't have a access to root server, so I can't set up GeoServer or something similar (wouldn't be financially feasible for a single client at the moment)

After some researching and reading, I finally settled with OpenLayers (after some showcasing with GMaps). Eric Hazzard's great book "OpenLayers 2.10" (Packt Publishing, 2011) really, really helped me a lot because it also covers some JavaScript basics and debugging tips.

I did all my vector data work in QGIS, of course, thats definitely the way to go for a small freelancer like me (I also know quite some ArcGIS stuff from university, but QGIS has been offering all I ever needed so far).

Styling the map and creating the tiles was a bigger challenge. First, I went along with "GMapCreator" by CASA, but layering multiple shapefiles proved to be tedious (I have to provide point data over polygons, and then a municipal borderline enclosing everything). It is absolutely possible to do this in GMapsCreator (and I did it for the showcase stage), but it takes 3 full rendering cycles (first you create tiles, then the existing tiles get "overdrawn" with later features - rendering in the right order is important!), and the styling menus are slightly bulky and confusing. Saving your map and editing it later is also a complicated issue.

TileMill seemed very promising, especially their CSS-like styling, so I looked into it. Unfortunately, it's Mac or Linux only, so that might scare some people off. I really liked what I saw, so I set up a Ubuntu partition on my hard-drive, downloaded it and styled my maps. Documentation on the styling syntax is sometimes a little scarce, but watching their demo video (linked on the main site) answers almost everything. It's possible to do some interesting stuff with nested and/or conditional styles, and some basic CSS understanding should really get you where you want to go.

In the end, TileMill renders a nice, single *.mbtiles file. I don't think there is a way to directly display these in OpenLayers (at least I couldn't find one?), so it was time to use another tool: mbutil. This tool "unzips" the mbtiles-File in to a regular folder structure containing the tiled pngs of my data on the selected zoom levels.

Finally, I uploaded all these files to my FTP-Server, did some heavy reading on OL to get my webmap up and going (you add the created tiles as a TMS layer, but guessing the right source url and layer name took some time and googling) and then burned some hours fiddling around with basic html/CSS issues. I wanted a 100% width/height map with a floating legend following my clients "corporate" (it's a municipality, as mentioned) identity guidelines.

Oh, and so far I use Google Maps as base layers, but that might get replaced soon by some custom aerial pictures served via WMS (not provided by me, but the state's survey and geodata administration).

I hope I didn't forget anything important, but if I did, please feel free to ask! I'll check this thread occasionally.

2
  • Tilemill is now available for Windows too. There's also a relatively recent thread on the Openlayers Users mailing list about using mbtiles as a data source (haven't tried it). Commented Mar 28, 2012 at 18:14
  • Ah, thanks, good to know. Definitely have to try that out, it has been a little annoying to switch between win7 and ubuntu the whole time.
    – SAnderka
    Commented Mar 30, 2012 at 16:48
3

If you have under 1000 polygons, consider @Mapperz's comment on a vector solution--no need to create and store non-interactive tiled images if you only have a few polygons.

Tiled images are optimal for highly dense information such as showing satellite imagery, roads, or 50,000 census tract polygons.

The simplest solution for a small number of polygons is to convert the shapefile to a KML and upload it to Google My Maps.

If you code in Javascript, the most interactive solution is the Google Maps API (or OpenLayers) to draw polygons and create information pop-up windows. You can start by converting the shapefile polygons, using the GDAL library, into a geoJSON file (a Javascript way of storing geographic information).

Or if you went the tile route you could store tiles on Amazons or Google's cloud for no in-house hassles.

This Thematic Mapping blog entry has a nice summary of the advantages of vector approach over the tiles approach that you are considering.

Good luck!

1
  • I found that about 500 points treated as vector on a single view tends to slow things down to a crawl. We tile everything over 500 points. Commented Feb 27, 2013 at 22:33
1

I feel for you mate, as ive been slowly working my way to the same conclusion. Having learnt QGIS, i tried quantamnik and mapnik. But while it will port the qgis styling its a one way trip and the styling systems arent 1 for 1 hence you have to learn the the mapnik styling anyway. I am guessing that the same applies to the qgis mapserver export function. There doesnt seem to be an "easy way" to upskill on mapserver, just hoe it and allow lots of time.

Mapnik, geoserver, mapserver, it seems theres devotees of each but mapserver seems to be the middle road.

Having said that there is one shortcut i found and that is qgis has a command line option to rasterize a qgis map to resolution and bounds of your choosing, and creates a worldfile. With this you can use maptiler or gdal2tiles to tile one layer at a time. Would be no good for 20 zoom levels obviously, nor do i know what the max png size limit is.

2
  • 2
    QGIS MapServer is different from MapServer.
    – Ian Turton
    Commented May 19, 2011 at 14:12
  • 2
    Because of this potential for confusion, it should be called QGIS Server.
    – underdark
    Commented May 21, 2011 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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