# Generating Map Tiles for MGRS Grid Graticule?

I'm possibly a bit out of my league here, but ready to get my hands dirty. I want to generate map tiles for a MGRS grid graticule similar to http://tiles.mapbox.com/mapbox/map/afghanistan-mgrs.

I need to create a function that takes a map boundary (probably something like two lat,lng pairs for the map corners) and the output image dimensions and returns an image. I'm looking at using Proj4 to convert map coordinates to pixel coordinates. I'm looking for some open source or starter code for calculating the MGRS grid lines. Most libraries I've seen are for translating a single coordinate which is fine for calculating the grid cell, but I'm not sure how to get the grid cell boundaries/plot the grid lines.

I'm looking at this for a mobile application so something in Java or C/Objective-C is my end goal.

Can someone give me a push in the right direction?

UPDATE

Refining my requirements a bit here...

I need to create a function that returns a 256x256 image given lat,lng boundary and zoom level. The zoom is a standard slippy map like zoom where the lowest zoom level is 1 which as 1 256x256 tile for the entire world and zoom level 2 has 4 tiles, and so on. For each tile and corresponding zoom level, I would like to draw the MGRS grid graticule boundaries and add a MGRS center label at the center of the MGRS grid cell.

there are some ways for drawing a grid on a map. i havent tried them before bacause i have never needed it.

1.you can check out matplotlib library for drawing grid on a map but it looks like a bit complex. it supports lots of projection.

you can find its doc here as Basemap Matplotlib Toolkit 1.0.3 documentation.

2.for qgis, you can try GridPluginLayer which overlays a user-definable grid on the map.. its source code here.

3.in arcgis, you can use MakeGridsAndGraticulesLayer_cartography function for creating grid. you can get some information here.

Syntax

MakeGridsAndGraticulesLayer_cartography (in_template, in_aoi, input_feature_dataset, output_layer, {name}, {refscale}, {rotation}, {mask_size}, {xy_tolerance}, {primary_coordinate_system}, {configure_layout}, {ancillary_coordinate_system_1}, {ancillary_coordinate_system_2}, {ancillary_coordinate_system_3}, {ancillary_coordinate_system_4})

4.with javascript, you can check out this example on google-map. there is some information in source code...

another javascript binding on google-maps here with utm and i think it can help you so more from others...

Example Result:

``````Coordinates for point you clicked
Datum WGS84

UTM
Z13  454908,4451473

Decimal degrees:
Lat,Lon 40.212456,-105.5299
Lon,Lat -105.5299,40.212456
``````

i hope it helps you...

• any idea what the usage license is on the last one? – spy Feb 9 '18 at 0:57