Hello, I am trying to use Maperitive to generate tiles, then use those osm tiles as the map background layer in my application. The map features on other layers are created by MapInfo. It looks like the osm tiles and features in other layers don't align in y-coordinates. I figured this is to do with MapInfo is using NAD83 projection, but osm tiles are in Mercator projection. I wonder what is the best way of generating osm tiles in NAD83 projection. Do I have to generate tiles in Mercator using Maperitive, and then re-project tiles to NAD83 projection using MapProxy? Thanks.

asked 30 Sep '13, 12:23

hua%20zhang's gravatar image

hua zhang
accept rate: 0%

closed 15 Oct '13, 10:07

SomeoneElse's gravatar image

SomeoneElse ♦


For info, this grew out of a previous discussion here.

(30 Sep '13, 12:34) SomeoneElse ♦

The question has been closed for the following reason "Questioner requested question closed (see comment below)." by SomeoneElse 15 Oct '13, 10:07

The OSM PostGIS 0.6 schema ("pg_snapshot") is built on the WGS-84 projection, as can be seen by one of the (many) lines of its creation script:

-- Add a postgis point column holding the location of the node.
SELECT AddGeometryColumn('nodes', 'geom', 4326, 'POINT', 2);

To convert them to a new projection (in this case "NAD83", SRID 4269 as listed here), you cannot simply set the SRID of the column:

UPDATE table SET the_column_4326 = ST_SetSRID(the_column_4326, 4326);

Because the ST_SetSRID() function does not perform a projection transformation, as described on the documentation.

Therefore, you have to use the ST_Transform() function, saving the result on another column that has the SRID of the NAD-83 projection. For example:

SELECT AddGeometryColumn('nodes','geom_4269', 4269, 'POINT', 2);
UPDATE nodes SET geom_4269 = ST_Transform(geom, 4269);

And then using the new column as the source of the data, or issuing a few more commands to replace the old column with the new one. Please note that things may get somewhat complicated should the columns be part of indexes, for example.

Make sure that you have the NAD-83 projection installed on your PostGIS spatial_ref_sys table. If not, you can always add it (from the spatialreference.org site (careful with the line breaks):

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 94269, 'epsg', 4269, '+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs ', 'GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]]');

You may also try to perform the transformation "on the fly" changing the source code of your interface, or maybe creating views from the tables, but probably it would be very CPU expensive (and probably very slow as well).

Additional material obtained from this StackOverflow question

EDIT: Fixed some typos, added link to st_transform reference.

permanent link

answered 01 Oct '13, 12:00

MCPicoli's gravatar image

accept rate: 24%

edited 01 Oct '13, 12:03

Thank you very much MCPicoli. Is that possible to modify Maperitive to generate tiles in NAD83 projection? If yes, could you give me some guideline on how to modify the source code? Thanks.

(08 Oct '13, 04:29) hua zhang

Sorry, very little experience with Maperitive.

(08 Oct '13, 18:40) MCPicoli

Thanks you very much for your help MCPicoli.

It turned out to be a mistake in my end. I am drawing the tiles on the display region using the wrong y-coorinates. There is no need for projection conversion. The map looks beautiful. Thanks.

(15 Oct '13, 01:25) hua zhang

Can anyone help me to close this question please? Thanks.

(15 Oct '13, 01:26) hua zhang

Follow this question

By Email:

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



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:


question asked: 30 Sep '13, 12:23

question was seen: 5,895 times

last updated: 15 Oct '13, 10:07

powered by OSQA