Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
inverse map projections

Subject: inverse map projections

From: Zackary Johnson

Date: 11 Oct, 2008 22:14:02

Message: 1 of 2

I have a projected image (image.shp), that I would like to convert into latitude and longitude for use with geoshow.m. I've tried projinv.m and minvtran.m to no avail. The readme.txt with the image file says,

------------------
The files are stored in the Robinson projection. The parameters are
        Units meters
        Spheroid sphere
        Logitude of central meridian 0 0 0.000
        false easting (metres) 0.00000
        false northing (metres) 0.00000

Feature type: Polygon
Data Layers: (Shape File Name, Layer Title, and Layer Description)
------------------

The mstruct I'm using for both projinv and minvtran is:
------------------
mstruct =

     mapprojection: 'robinson'
              zone: []
        angleunits: 'degrees'
            aspect: 'normal'
     falsenorthing: 0
      falseeasting: 0
       fixedorient: []
             geoid: [1 0]
       maplatlimit: [-90 90]
       maplonlimit: [-180 180]
      mapparallels: 38
        nparallels: 0
            origin: [0 0 0]
       scalefactor: 1
           trimlat: [-90 90]
           trimlon: [-180 180]
             frame: 'off'
             ffill: 100
        fedgecolor: [0 0 0]
        ffacecolor: 'none'
         flatlimit: [-90 90]
        flinewidth: 2
         flonlimit: [-180 180]
              grid: 'off'
         galtitude: Inf
            gcolor: [0 0 0]
        glinestyle: ':'
        glinewidth: 0.5000
    mlineexception: []
         mlinefill: 100
        mlinelimit: []
     mlinelocation: 30
      mlinevisible: 'on'
    plineexception: []
         plinefill: 100
        plinelimit: []
     plinelocation: 15
      plinevisible: 'on'
         fontangle: 'normal'
         fontcolor: [0 0 0]
          fontname: 'Helvetica'
          fontsize: 10
         fontunits: 'points'
        fontweight: 'normal'
       labelformat: 'compass'
     labelrotation: 'off'
        labelunits: 'degrees'
     meridianlabel: 'off'
    mlabellocation: 30
    mlabelparallel: 90
       mlabelround: 0
     parallellabel: 'off'
    plabellocation: 15
    plabelmeridian: -180
       plabelround: 0
------------------

What am I doing wrong? Or do I need more information?
Thanks in advance, Z

Subject: inverse map projections

From: Rob Comer

Date: 12 Oct, 2008 12:48:01

Message: 2 of 2

Your mstruct looks fine; it seems to match what you'd get from:

>> ax = axesm('robinson');
>> mstruct = getm(ax)

But because your filename ends in ".shp" and because the readme says "Polygon," I suspect that you actually have a polygon shapefile, not an image file. You could run SHAPEINFO on it for a quick confirmation.

In this case, you can import your polygons into a structure array (a "mapstruct") with Geometry 'Polygon' and X and Y coordinate fields, using SHAPEREAD. Then apply minvtran to the X and Y data of each element, and store the results back in another structure array that's identical to the first, but with Lat and Lon fields instead of X and Y fields (a "geostruct"). (In some cases, polygons that touch the edge of the map may need additional adjustment to close properly, etc.)

On the other hand, if you really have an image, then you need to resample it. The following demo should get you started:

<http://www.mathworks.com/products/demos/shipping/map/mapexunprojectdem.html?product=MG>

although it uses a DEM, which is similar to a one-band image. In the case of an RGB image, for example, you'd need to resample each band separately.

Rob Comer
Mapping Toolbox Development
The MathWorks, Inc.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us