I want to display the Ordnance Survey National Grid as a tile layer in my android application. I've downloaded the grid data as various shapefiles from here: https://github.com/charlesroper/OSGB_Grids My options are to display the grid using the MapsForge library locally on the android device or to import the grid data into my tileserver (setup using the Switch2OSM tutorial). I've decided to use my tileserver. So far i've tried:
I've also tried using shp2pgsql but my skills are not sufficient to understand the instructions :(. Anyway i had an idea - can't i simply add my grid shapefile to the tileserver's existing shapefiles and then let mapnik/tile_mod render the shapefile data along with the existing shapefile data? That is render the shapefile directly without importing it into PostgreSQL. So i uploaded my grid shapefiles to my server, uploading them to the directory /usr/local/share/world_boundaries. I restarted the tileserver and looked at the slippymap.html map - no sign of my os grid on the rendered tiles. Can anyone suggest how i'd add my os grid shapefile to my tileserver so that it's rendered along with the existing world boundary shapefile data? Thanks. asked 01 Jan '15, 10:22 warwound |
shp2pgsql is pretty simple. You'd usually run it like this:
That will import myshapefile.shp into database The number after -s is the EPSG code for the projection. 4326 is raw latitude and longitude, i.e. not really projected at all. The code for OSGB (the National Grid) is 27700. So if you use Alternatively, you might want to reproject on import - that is, read an OSGB shapefile, but store it in 4326 (or something else). That's easy too - just separate the two projections with a colon:
answered 01 Jan '15, 12:28 Richard ♦ |
I've now found the various .xml.inc files located in the mapnik-styles/inc directory. I updated layers.xml.inc adding a new entry: <!ENTITY layer-osgrid SYSTEM "layer-osgrid.xml.inc"> Then i created the file layer-osgrid.xml.inc: <Style name="osgrid"> <Rule> &maxscale_zoom4; &minscale_zoom16; <LineSymbolizer stroke-linejoin="round" stroke="grey" stroke-width="4" stroke-opacity="0.8"/> </Rule> </Style> <Layer name="osgrid" status="on" srs="&srs27700;"> <StyleName>osgrid</StyleName> <Datasource> <Parameter name="type">shape</Parameter> <Parameter name="file">&world_boundaries;/OSGB_Grid_1km</Parameter> </Datasource> </Layer> In my world_boundaries directory i uploaded the OSGB_Grid_1km.shp grid shapefile. I also used shapeindex to create an index file for OSGB_Grid_1km.shp. Lastly i ran this command: python generate_xml.py --dbname gis --world_boundaries "/usr/local/share/world_boundaries" --accept-none I deleted all cached tiles and restarted my tileserver hoping to see some grids rendered on the tiles but nothing gets rendered. I'll experiment more later... answered 04 Jan '15, 10:07 warwound |
The shapefiles are in OSGB36 projection, ESPG:27700, for osm2pgsql they need to be in WGS84 (ESPG:43260). However JOSM should manage the conversion, so you need to tell us what tags you have on the grid data. Even then you need some kind of rendering rules to pull them into a your tiles.
My goal is for my tileserver to serve semi transparent tiles which contain nothing but the grid data. I'll display these tiles as a tile overlay in my android application on top of the existing map tiles. So i'd display say Google's road map or satellite map tiles with my grid tiles on top.
For this project i don't want to display any OSM data rendered from PostgresSQL and i don't want to display the existing world boundary shapefile data. I just want a transparent tile with the grid data rendered onto it.
Is that possible?
How can i reconfigure my tileserver so that it renders just the grid shapefile and nothing else?