4

I have written a radar weather app using osmdroid for map tiles, and manually overlaying NOAA ridge radar data. Everything Is working great except that the radar images are unprojected, while the openstreetmap tiles are in transverse Mercator projection. The weather lies within the bounds it should but the data is distorted.

I see three ways to fix this (in order of preference) but am having trouble with all three:

1) find a source of radar data already projected in mercator - hours of Googling later, I've found nothing 2) programmatically reproject the images right after I download them. Does anyone know a good API for this? 3) project them on the fly, perhaps with openlayers.im reading that can openlayers reproject,but can it be used over top of an osmdroid mapview?

Any ideas? Thanks for any help Mike

2
  • @2: gdalwarp is a pretty powerful tool for raster image reprojection. But as you're talking about already tiled data this approach might require additional work.
    – tyr
    Aug 3, 2013 at 6:55
  • Looks like gdal is the way to go, but I can't seem to find a good implementation of it on android. What does everyone else use? Thanks!
    – Raptrflite
    Aug 4, 2013 at 2:46

1 Answer 1

0

GDAL is the way to go. There is no official Android build that I know of however some people have been successful in getting it running on Android. For example, Nutiteq has a build in the libs folder of their AdvancedMap3D sample project. Put the contents of both armeabi folders in your project's lib folder and you should be able to access the GDAL packages.

Then take a look at the GDAL in Java page. Look at the gdalinfo.java sample to get a feel for how to load and examine the parts of a GDAL dataset. To reproject your dataset, you will do something along the lines of:

SpatialReference sr = new SpatialReference();
sr.ImportFromProj4("+proj=merc +datum=WGS84");
String result[] = new String[1];
sr.ExportToPrettyWkt(result, 1);
String oldProjection = mDataset.getProjection();
String newProjection = result[0];
Dataset newDataset = gdal.AutoCreateWarpedVRT(mDataset, oldProjection, newProjection, gdalconst.GRA_NearestNeighbour, 0.0);
Dataset savedDataset = mDriver.CreateCopy(outpath, newDataset, 0, new String[] { "COMPRESS=LZW", "PREDICTOR=2" }, null, null);
newDataset.delete();
savedDataset.delete();

You may need to make a few adjustments, but that should get you most of the way there.

2
  • I can't seem to get the imports to be recognized: "import org.gdal.gdal.Band;" for instance. I spent the better part of the evening trying to get the libs and the .jar to be added properly in the module settings (dependencies/libraries). The 'GDAL in java' page mentions the bindings API. Is this what I'm missing? Thanks a lot for all your help!
    – Raptrflite
    Aug 9, 2013 at 1:04
  • It looks like you need to add the contents of the org folder to your project too. This contains all the SWIG bindings. There may be other prebuilt GDAL libraries out there too if you dig around.
    – kurtzmarc
    Aug 9, 2013 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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