[udig-devel] NPE when loading tif image

Kelly, Brendon (SAPOL) Brendon.Kelly at police.sa.gov.au
Tue Aug 1 23:12:54 PDT 2006


Hi,

I'm using the following code to load a tif map image in my mapeditor.

URL url = new URL(
    "file:///D:/ESRI/maps/adelaide/raster/adlk1205.tif");
List<IService> services =
CatalogPlugin.getDefault().getServiceFactory().acquire(url);
IGeoResource resource = services.get(0).members(new
NullProgressMonitor()).get(0);
List<IGeoResource> resources = new ArrayList<IGeoResource>();
resources.add(resource);
Project project = (Project) ApplicationGIS.getActiveProject();
ApplicationGIS.addLayersToMap(null, resources, -1, project);

In the same directory I have a file called adlk1205.tfw and adlk1205.prj
using GDA94 projection as detailed in the FAQ.  When I run the
application I get:


java.lang.NullPointerException
	at
org.geotools.gce.image.WorldImageReader.parseWorldFile(WorldImageReader.
java:662)
	at
org.geotools.gce.image.WorldImageReader.prepareWorldImageEnvelope(WorldI
mageReader.java:492)
	at
org.geotools.gce.image.WorldImageReader.read(WorldImageReader.java:297)
	at
net.refractions.udig.catalog.rasterings.AbstractRasterGeoResource.findRe
source(Unknown Source)
	at
net.refractions.udig.catalog.internal.worldimage.WorldImageGeoResourceIm
pl$IGeoResourceWorldImageInfo.getBounds(Unknown Source)
	at
net.refractions.udig.catalog.internal.worldimage.WorldImageGeoResourceIm
pl$IGeoResourceWorldImageInfo.<init>(Unknown Source)
	at
net.refractions.udig.catalog.internal.worldimage.WorldImageGeoResourceIm
pl.getInfo(Unknown Source)
	at
net.refractions.udig.project.internal.commands.CreateMapCommand.run(Unkn
own Source)
	at
net.refractions.udig.project.command.CommandManager$Executor.execute(Unk
nown Source)
	at
net.refractions.udig.project.command.CommandManager$Executor.run(Unknown
Source)
	at
net.refractions.udig.project.command.CommandManager$Executor.run(Unknown
Source)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:76)


Is geotools trying to parse a file other than what I've provided?  I
thought that the .tfw file is the world file.  If I load a shape file
using the same code above, everything works fine.

Contents of adlk1205.tfw:
-------------------------
                   2.00000000000000
                   0.00000000000000
                   0.00000000000000
                  -2.00000000000000
              268061.86976340000000
             6139176.21239500000000

Contents of adlk1205.prj:
-------------------------
GEOGCS["GDA94", 
  DATUM["Geocentric_Datum_of_Australia_1994", 
    SPHEROID["GRS 1980", 6378137.0, 298.257222101,
AUTHORITY["EPSG","7019"]], 
    TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 
    AUTHORITY["EPSG","6283"]], 
  PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
  UNIT["degree", 0.017453292519943295], 
  AXIS["Lon", EAST], 
  AXIS["Lat", NORTH], 
  AUTHORITY["EPSG","4283"]]




Regards

Brendon Kelly
---
Application Programmer
Information Systems & Technology Service
South Australia Police
Ph: 8204-2414



More information about the udig-devel mailing list