[Gdal-dev] Tool to convert shapefile from [-180, 180] to [0,
360] range
Mateusz Loskot
mateusz at loskot.net
Tue Jun 13 21:07:36 EDT 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.
Hi Daniel,
I created small utility on basis of ogr2ogr according your needs, just
for fun and practice :-)
I attached it as a 180to360.cpp file, so it's a C++ application.
I hope this attachement will not be cutted off by the gdal-dev mailer.
It works only with shapefiles.
This utility just adds 180 to every x coordinate.
So, it works well only if input coordinates are in range frm -180 to
180, but it does not check it.
You have to compile it as ogr2ogr.cpp, here is small Makefile:
# Change FLAGS if needed
CPP = g++
LDFLAGS = -L/usr/lib -lgdal
CPPFLAGS = -I/usr/include $(CPPFLAGS)
180to360: 180to360.cpp
$(CPP) $(CPPFLAGS) $< -o $@ $(LDFLAGS)
Run it without any options and you will see the usage message.
In example:
./180to360 ~/tmp/sec.shp ~/tmp/test.shp
and test.shp includes features dumped from sec.shp with X coord conversion.
If there is something not working, just give me a note.
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 180to360.cpp
Type: text/x-c++src
Size: 11980 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20060614/db2b5e7d/180to360.bin
More information about the Gdal-dev
mailing list