1

I have an image file that is a Robinson Projection Map of the world. I have a list of geo-coordinates. I would like to find the pixel-coordinates on the map that correspond to my the geo-coordinates I have. What is the best way of doing this?

Note that I'm developing a tool for this purpose --- I would like to be able to find the corresponding pixel-coordinate for any geo-coordinate. So I'm trying to create a function to project geo-coordinates to pixel-coordinates. I'm wondering if there's a standard way of doing this, or if I have to adjust for particularities in map distortion, etc.

Can anyone help?

1

It's a two-stage solution:

  1. project geo-coords (lat, lon) to a Robinson map (N, E)

  2. transform the map (N, E) to a screen window (row, col)

For stage 1, projection, you can use the ogr2ogr tool. Gothos explains how to use it for Robinson in particular transform-projections-with-gdal-ogr

The EPSG library is extensive, but doesn’t contain everything, particularly some global and continental map projections. GDAL / OGR can still do the job, but you’ll have to provide the tool with the proper frame of reference since the EPSG library doesn’t have the info. Let’s say we want to project our WGS file to the Robinson Projection, which is not part of EPSG.

First, go back to spatialreference.org and search for Robinson. Its ID code is ESRI 54030 – not part of the EPSG library. Click on the link for the projection to open its window. You’ll be able to look at the projection data in a number of standard file formats. Select OGC_WKT from the list, and it will open the text in a new window, showing you the parameters of that projection. In your browser, go up to file, save as, and save the file as robinson_ogcwkt.txt in the same directory as the shapefile you want to reproject.

Now that you have the projection info stored in the text file, run the following command to make the conversion:

ogr2ogr -t_srs robisnon_ogcwkt.txt world_rob.shp world_wgs.shp

Stage 2, transformation, is much simpler scale and shift. See Help with "projected XY to screen xy" conversion algorithm? for example. Or you can use the gdal_translate tool. See Re-project raster image from Mercator to Equirectangular

  • Thanks -- that was helpful, but there was an easier way to do it in Python. – Newb Aug 29 '14 at 16:59
1

What I did to solve this problem was:

  1. I used the pyproj library to convert from WGS84 to Robinson as here:

    import pyproj
    crs_from = pyproj.Proj(init='EPSG:4326')
    crs_to = pyproj.Proj('+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
    x, y = pyproj.transform(crs_from, crs_to, LONGITUDE HERE, LATITUDE HERE)
    
  2. Then I realized that the Robinson Projection had an x-scale of (-17005833,17005833) and a y-scale of (-8625154,8625154) and then simply scaled the Robinson-Projected x,y from above to the pixel-coordinates of my map (by finding the pixel-dimensions of my map, dividing, and offsetting for blank space surrounding the map).

  • Thanks for following up, and glad to know it's easy in python. – Martin F Aug 30 '14 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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