I'm not understanding how to get a reference from a .jpg file

2 views (last 30 days)
I have the following code: % read colorado tif file % Pathname = 'C:\Users\chammerschmidt\Documents\Projects\TerrainData\CombineBoulder_N39_N40_W106\'; Filename = 'N39_N40_W106_LatLong.jpg'; cd(Pathname) % states = geoshape(shaperead('usastatehi','UseGeoCoords',true)); stateName = 'Colorado'; co = states(strcmp(states.Name, stateName)); latlim = [min(co.Latitude),max(co.Latitude)]; lonlim = [min(co.Longitude),max(co.Longitude)]; [latlim, lonlim] = bufgeoquad(latlim,lonlim, 0.05, 0.05); % RGB = imread(Filename); WorldFileName = getworldfilename(Filename); R = worldfileread(WorldFileName,'geographic',size(RGB)); % figure(1) ax = usamap(latlim,lonlim); oceanColor = [0.5 0.7 0.9]; setm(ax,'FFaceColor',oceanColor) geoshow(states) geoshow(co, 'LineWidth',1.5,'FaceColor',[0.5 0.8 0.6]) geoshow(Filename,'DisplayType','image'); % disp('the end') And I am getting the error 'Error using internal.map.checkfilename>checkDiskfilename (line 172) Function WORLDFILEREAD was unable to find file 'N39_N40_W106_LatLong.jgw'.
Error in internal.map.checkfilename (line 55) [fullfilename, fid]=checkDiskfilename(filename, ext, function_name);
Error in worldfileread (line 50) worldFileName = internal.map.checkfilename(worldFileName, {}, mfilename, 1, false);
Error in ReadColoradoTiffile (line 16) R = worldfileread(WorldFileName,'geographic',size(RGB));'
And I don't understand how to get R. Chriss
  1 Comment
Stephen23
Stephen23 on 25 Nov 2014
Please edit your question and use the text formatting tools that are above the text box. There is one specifically marked "code", and using this (together with the preview pane underneath the text box) makes our lives a lots easier, as then we can actually read your code... it increases the chances of you getting the right answer to your problem!

Sign in to comment.

Answers (2)

Chad Greene
Chad Greene on 24 Nov 2014
Agh, it's tough to read proportionally-spaced code. I see an inconsistency in the file names you're calling. You've defined,
Filename = 'N39_N40_W106_LatLong.jpg';
however, the worldfileread function is trying to call a file called 'N39_N40_W106_LatLong.jgw'. Is that file extension a typo?
  2 Comments
Chriss Hammerschmidt
Chriss Hammerschmidt on 25 Nov 2014
I use the getworldfilename to change the extension to the .jpw. I guess I am not understanding. I could send you the code and the file so that it would be easier to read and debug if you would like. Chriss
Chad Greene
Chad Greene on 25 Nov 2014
Sorry, I don't know much about worldfiles. Hopefully someone else on the forum can help.

Sign in to comment.


Chriss Hammerschmidt
Chriss Hammerschmidt on 24 Nov 2014
I use the getworldfilename to change the extension to the .jpw. I guess I am not understanding. I could send you the code and the file so that it would be easier to read and debug if you would like. Chriss

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!