python - How to apply image processing in shape file or raster -


i wish use matlab or python image processing arcgis files. goal process shape file or raster normal image. can anypart of , process image algorithm. add coordinates information show in arcgis. searched web , found there way it. can use tif image in matlab. big matlab process cut tif using small area in arcgis. please see code , link of it. there way , easily? suggestion helpful.

thank you.

clc;close all;clear;  %below using matlab blockproc read large file,but failed read tiff  % src_filename='f:/1.tif';  % fun = @(block_struct) block_struct.data;  % b = blockproc(src_filename,[5 5],fun);  %   % %----------below how transform coordinates----------------------------------------------------------------  % code from:http://www.cnblogs.com/denny402/p/4684770.html    [pic,r]=geotiffread('f:/lenoir/lidar2007/1.tif');  [m,n,~]=size(pic);      figure(1),imshow(pic)  hold on; scatter(n/4,m/4,500,'r.');    [lon,lat]=pix2map(r,m/4,n/4)  figure(2),mapshow(pic,r);  mapshow(lon,lat,'marker','.','markeredgecolor','r');    axis off;    disp(['(',num2str(m/4),',',num2str(n/4),') -> (',num2str(lon),',',num2str(lat),')']);     %r.rasterwidthinworld  x=r.xlimworld(1)+(3/4)*r.rasterwidthinworld;    y=r.ylimworld(1)+(1/4)*r.rasterheightinworld;  figure(3),mapshow(pic,r),axis off;  mapshow(x,y,'marker','*','markeredgecolor','r');  [row,col]=map2pix(r,x,y);  figure(4),imshow(pic);  hold on;  scatter(col,row,100,'r*');    disp(['(',num2str(x),',',num2str(y),') -> (',num2str(row),',',num2str(col),')']);

in relation earlier comment find piece of code below showing simplified example of possible manipulations based on country border file downloarable indicated page.

first read in shape extract bounding box germany, plot , add coordinates. use shapewrite create new shape, read new shape , plot it.

in second part plot germany polygon , save , image, read in again , use imshow draw it.

does help?

clear close  % https://github.com/jalbertbowden/world-data/blob/master/world-borders/tm_world_borders-0.3/tm_world_borders-0.3.dbf countryshape = shaperead('tm_world_borders-0.3.dbf');   countrynames{1}='germany'; countrynames{2}='united kingdom'; countrynames{3}='netherlands'; countrynames{4}='france'; countrynames{5}='belgium'; countrynames{6}='denmark'; countrynames{7}='norway';  figure = 1:size(countrynames,2)     xboundary = countryshape(strcmp({countryshape.name},countrynames{i})).x;     yboundary = countryshape(strcmp({countryshape.name},countrynames{i})).y;     maxx = max(xboundary);     minx = min(xboundary);     maxy = max(yboundary);     miny = min(yboundary);     outerbox_x = [minx maxx maxx minx minx];     outerbox_y = [maxy maxy miny miny maxy];      subplot (4,2,i)     hold on     plot(xboundary,yboundary,'k-')     plot(outerbox_x, outerbox_y,'r-')      actual_id = find(strcmp({countryshape.name},countrynames{i}));     countryshape(actual_id).x = [countryshape(actual_id).x outerbox_x];     countryshape(actual_id).y = [countryshape(actual_id).y outerbox_y]; end     shapewrite(countryshape,'newshape'); countryshape2 = shaperead('newshape.dbf');  id_of_germany = find(strcmp({countryshape2.name},'germany')); xboundary2 = countryshape2(id_of_germany).x; yboundary2 = countryshape2(id_of_germany).y; subplot (4,2,i+1) plot(xboundary2,yboundary2,'k-')  figure fill(xboundary(~isnan(xboundary)),yboundary(~isnan(yboundary)),'r')  im = getframe(gcf); imwrite(im.cdata,'myimage.png'); newim = imread('myimage.png'); imshow(newim) 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -