NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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:

  • Converting the shapefile grid data to osm (xml) format using JOSM and then importing the osm data to my tileserver using osm2pgsql. This fails to import anything, i suspect the osm tags are not recognised by osm2pgsql.

  • Converting the shapefile grid data to osm (xml) format using Merkaator and then importing the osm data to my tileserver using osm2pgsql. This fails with osm2pgswl reporting many 'BoundingBox' tag not recognised errors.

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's gravatar image

warwound
11112
accept rate: 0%

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.

(01 Jan '15, 11:23) SK53 ♦

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?

(04 Jan '15, 07:46) warwound

shp2pgsql is pretty simple. You'd usually run it like this:

shp2pgsql -s 4326 -I myshapefile.shp table_name | psql -d database_name -q

That will import myshapefile.shp into database database_name, creating a new table called table_name.

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 -s 27700, that will read a shapefile in OSGB, and store it in the database like that.

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:

shp2pgsql -s 27700:4326 -I myshapefile.shp table_name | psql -d database_name -q
permanent link

answered 01 Jan '15, 12:28

Richard's gravatar image

Richard ♦
30.9k44279412
accept rate: 18%

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...

permanent link

answered 04 Jan '15, 10:07

warwound's gravatar image

warwound
11112
accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×196
×87

question asked: 01 Jan '15, 10:22

question was seen: 6,133 times

last updated: 04 Jan '15, 10:07

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum