[Gdal-dev] Tool to convert shapefile from [-180, 180] to [0, 360] range

Charles Wivell Charles.Wivell at dnr.state.mn.us
Thu Jun 15 10:02:06 EDT 2006


The shift you should use if you want the values between -180 and 180 for values less than -180 would be:

if (value < -180.0) value = value + 360.0;

If you want to convert values between 0 to 360 to values between -180 to 180 then:

if (value > 180.0) value = value - 360.0;

if you are programming this, then everything should be in radians...


Chuck Wivell

MN DNR Grand Rapids MN

>>> "Curt, WE7U" <archer at eskimo.com> 6/15/2006 8:25 AM >>>
On Tue, 13 Jun 2006, Daniel Morissette wrote:

> Is anyone aware of a tool or script that would convert the longitude of
> coordinates in a shapefile from [-180,180] to [0,360]? The tool could be
> based on OGR or any other open source package.
>
> Just checking before writing something from scratch and reinventing the
> wheel.

Hey, that brings to mind something a few things I've been wanting to ask:

*) What should an application do with a shapefile that contains
polygons with longitudes in the -189.9 to -180.0 range?  Is there an
easy way to split up the shapes so they don't fall off the edge of
the earth?

We use some NOAA Shapefiles for weather alerts that cross that
boundary and our application doesn't like them.  I can tweak the
application, so just wondering whether to do that or split the
polygons multiples across that line.  To tweak the app would mean to
draw the polygon in two pieces anyway, one on the extreme right of
the view and one on the extreme left.  A bit of a pain
programming-wise.

I contacted NOAA about the files.  They thing it's fine to have
polygons cross that boundary.  Maybe it's just me that has a problem
with it?  I suspect they use ESRI software to generate them.

*) I tried some Mars Shapefiles that range from 0-360 degrees.  Our
application doesn't like that either.  Should an application check
the bounding polygon for the Shapefile and then apply a -180 degree
shift to all the longitudes if it detects this?  What to do with
polygons that cross it's 0.0 degree boundary (basically the same
question as the first above)?

--
Curt, WE7U.   APRS Client Comparisons: http://www.eskimo.com/~archer 
"Lotto:    A tax on people who are bad at math." -- unknown
"Windows:  Microsoft's tax on computer illiterates." -- WE7U
"The world DOES revolve around me:  I picked the coordinate system!"
_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org 
http://lists.maptools.org/mailman/listinfo/gdal-dev





More information about the Gdal-dev mailing list