« Previous : 1 : 2 : 3 : 4 : 5 : ... 8 : Next »

GDAL 파일 열기

* 헤더파일 포함
#include "gdal_priv.h"

* 파일 열기
  Access옵션에 따라 읽기전용 혹은 읽기/쓰기 용으로 열수있다. 리턴값이 NULL이면 열기 실패이다.

// 읽기/쓰기
// GDALAccess Access=GA_Update;
// 읽기 전용
GDALAccess Access=GA_ReadOnly;
GDALDataset* pGDALDataSet=(GDALDataset *) ::GDALOpen(_Pathname, Access );

* 영상 크기 정보 가져오기

// 넓이 가져오기
int Width = pGDALDataSet->GetRasterXSize();
// 높이 가져오기
int Height = pGDALDataSet->GetRasterYSize();  

* 밴드개수 가져오기
int BandCount=pGDALDataSet->GetRasterCount();


* 좌표정보 가져오기
  좌표정보는 Affine 파라미터로 사용되며 다음과 같은 값으로 지정되어 있다.
 adfGeoTransform[0] /* top left x */
 adfGeoTransform[1] /* w-e pixel resolution */
 adfGeoTransform[2] /* rotation, 0 if image is "north up" */
 adfGeoTransform[3] /* top left y */
 adfGeoTransform[4] /* rotation, 0 if image is "north up" */
 adfGeoTransform[5] /* n-s pixel resolution */

double GeoTransform[6];
CPLErr Err=pGDALDataSet->GetGeoTransform(GeoTransform);
if (Err==CE_None) // 좌표정보가 있는 경우.
{}

* 오버뷰 개수 및 화소데이터 타입 가져오기

  GDALDataSet로부터 GDALRasterBand를 가져와야 한다. 주의할 점은 밴드 인덱스는 1부터 시작한다.
GDALRasterBand* pRasterBand=pGDALDataSet->GetRasterBand(1);
if (pRasterBand)
{
// Overview 개수 가져오기
int OverviewCount=pRasterBand->GetOverviewCount();
//  화소 데이터 타입 가져오기
GDALDataType DataType = pRasterBand->GetRasterDataType();
}


* 화소데이터의 크기와 이름 가져오기
   GDALGetDataTypeSize()와  GDALGetDataTypeName()함수를 이용하면 데이터타입의 크기(Bit단위)와 데이터 타입 이름을 가져올 수 있다.
// 화소 데이터 Bit크기
int DataTypeSize = GDALGetDataTypeSize( DataType  );

// 화소 데이터 타입의 String 가져오기
CString    DataTypeName = GDALGetDataTypeName(DataType());

* 파일닫기
::GDALClose(pGDALDataSet);  


Posted by chungki

2012/03/19 17:12 2012/03/19 17:12
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/305

[Base] Range

* 1차원 값의 범위를 저장하는 기본 클래스


// 잘못된 사용 방법

mRange<mF64, mF64>     ElevationRange;
ElevationRange.Min = -10.;
ElevationRange.Max = +10.;

// 올바른 사용 방법

mRange<mF64, mF64>     ElevationRange;
ElevationRange.Define( -10., +10.);
mRange<mF64, mF64>     ElevationRange(-10., +10.);

mF64 MinMax[2]={-10., +10.};
mRange<mF64, mF64>     ElevationRange(MinMax);



// 길이 구하기
mF64 Length = ElevationRange.Distance();

// Min과 Max의 거리를 10만큼 더 늘린다. ElevationRange.Extend(5.0); ElevationRange.Extend(5.0, 2.0);

// 변수의 Min,Max가 정의되었는지 확인. If (ElevationRange.IsDefined()) { }



// 연산 operator의 활용
mRange<mF64, mF64>  ElevRange(-10., +10.);
mRange<mF64, mF64>  ScaledRange=ElevRange*10.;

ElevRange *= 5.; ElevRange /= 2.; ElevRange += 2.; // Offset ElevRange |= 15.;

Posted by chungki

2010/03/05 00:01 2010/03/05 00:01
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/299

[Base] Pair

* 두 개의 관련 개체를 저장하는 데 사용되는 기본 클래스

mPair   IDName1(10, _T(“James Jeong”));
int ID = IDName1.first;
CString Name=IDName1.second;

mPair   IDName2;
IDName2.first = 5;
IDName2.second = _T(“Brian Kim”);


 
mPair< mF32, mF32>     MinMax1(-10.f, 10.f);

mF32 Min=MinMax1.first;
mF32 Max=MinMax1.second;

Posted by chungki

2010/03/04 23:47 2010/03/04 23:47
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/298

잠시 쉴겸 해서 만들어 보았다. 시스템 메모리를 사용안하고 파일기반으로 데이터 처리를 하고 싶을때 사용하면 된다. 물론 속도가 많이 느리겠지만 앞으로 최적의 속도를 위해서 꾸준히 업데이트 해야 겠다.
Meomry Map File을 사용하기 때문에 win32환경에서 작동된다.
인터페이스는 CArray와 동일하게 만들었다. 아직 속도검사는 하지 않았다. 심심할때 메모리기반 배열과 비교를 해봐야 겠다.
아래는 예제이다.
01: // FileArraySample.cpp : Defines the entry point for the console application. 02: // 03: 04: #include "stdafx.h" 05: #include "FileArray.h" 06: 07: int _tmain(int argc, _TCHAR* argv[]) 08: { 09: TFileArray<UINT> IntArray; 10: 11: 12: IntArray.Open(_T("d:\\aaa.tmp")); 13: IntArray.RemoveAll(); 14: 15: for (UINT i=0;i<10;++i) 16: IntArray.Add(i); 17: 18: for (UINT i=0;i<IntArray.GetSize();++i) 19: printf("%u \n", IntArray[i]); 20: 21: for (UINT i=0;i<IntArray.GetSize();++i) 22: { 23: UINT v=i+1000; 24: IntArray.SetAt(i,v); 25: } 26: 27: for (UINT i=0;i<10;++i) 28: { 29: UINT v=i+10000; 30: IntArray.Add(v); 31: } 32: 33: for (UINT i=0;i<IntArray.GetSize();++i) 34: printf("%u \n", IntArray[i]); 35: 36: IntArray.Close(); 37: 38: return 0; 39: } 40:
소스 :

Posted by chungki

2010/02/25 01:38 2010/02/25 01:38
, ,
Response
A trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/297

GDAL 기본설정

1. 헤더파일 포함

#include <gdal_priv.h>
2. 라이브러리 파일 포함
#pragma comment(lib, "gdal15.lib")

3. GDALALLRegister
GDAL에서 제공하는 함수들을 사용하기 위해서는 반드시 GDALAllRegister()함수를 먼저 호출하여야 한다.
MFC 어플리케이션에서는 일반적으로 APP클래스의 InitInstance()함수에서 호출하면 된다.

4. GDALDestroyDriverManager
GDAL를 사용하고 난 후에는 반드시 GDALDestroyDriverManager()함수를 호출하여야 한다.
MFC 어플리케이션에서는 APP클래스의 ExitInstance()함수에서 호출하면 된다.

Posted by chungki

2010/01/13 13:28 2010/01/13 13:28
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/294

GDI+ GradientFill API 예제

CDC* pdc = GetDC();
HDC hdc = pdc->m_hDC;
 
TRIVERTEX		 tvx[5] ;
GRADIENT_TRIANGLE grdt[4] = {{0,1,2},{0,2,3}};
 
// Red
tvx[0] .x	 = 0;
tvx[0] .y	 = 0;
tvx[0] .Red	 = 0xff00;
tvx[0] .Green = 0x0000;
tvx[0] .Blue	= 0x0000;
tvx[0] .Alpha = 0x0000;
// Green
tvx[1] .x	 = 400;
tvx[1] .y	 = 0;
tvx[1] .Red	 = 0x0000;
tvx[1] .Green = 0xff00;
tvx[1] .Blue	= 0x0000;
tvx[1] .Alpha = 0x0000;
// Blue
tvx[2] .x	 = 400;
tvx[2] .y	 = 300; 
tvx[2] .Red	 = 0x0000;
tvx[2] .Green = 0x0000;
tvx[2] .Blue	= 0xff00;
tvx[2] .Alpha = 0x0000;
// Yellow
tvx[3] .x	 = 0;
tvx[3] .y	 = 300;
tvx[3] .Red	 = 0xff00;
tvx[3] .Green = 0xff00;
tvx[3] .Blue	= 0x0000;
tvx[3] .Alpha = 0x0000;
GradientFill(hdc, tvx, 4, &grdt, 2, GRADIENT_FILL_TRIANGLE);
 
ReleaseDC(pdc);

Posted by chungki

2009/12/03 19:41 2009/12/03 19:41
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/293

GeoTIFF Sample

Posted by chungki

2009/11/14 06:57 2009/11/14 06:57
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/291

Delaunay

Delaunay Triangulation

Posted by chungki

2009/11/14 06:55 2009/11/14 06:55
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/290

Microsoft Visual C++ 2005 Redistributable Package

VS2005용 배포용 패키지이다. 여태까지 버전이 2개가 있는줄 알았는데 자세히 찾아보니 3개가 존재하였다. 내 컴퓨터는 Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update    버전이 설치되어 있어서 본인 컴퓨터에서 컴파일을 하고 다른 사람 컴퓨터에서 실행을 하니 안되었다. 2005 SP1 Redistributable Package버전을 설치했기때문에 안되는 문제였다.

그래서 이런저런 방법을 찾아보다가 결국 DLL의 버전을 확인을 해본 결과 ATL Security Update버전이 있다는걸 알아냈고 내 컴퓨터에 이 버전이 설치되어 있는 걸 확인했다. 그래서 다른 컴퓨터에 ATL Security Update버전을 설치하니 문제없이 작동했다.
 

vcredist_x86(vs2005).exe

Microsoft Visual C++ 2005 Redistributable Package (x86)

vcredist_x86(VS2005_sp1).exe

Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)(version='8.0.50727.762')

vcredist_x86(VS2005_sp1_ATL_Security_Update).exe

Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package ATL Security Update(version='8.0.50727.4053')


Posted by chungki

2009/09/19 11:04 2009/09/19 11:04
Response
No Trackback , 2 Comments
RSS :
http://www.chungki.net/tc/rss/response/289

사용자 삽입 이미지

 CXTPToolBar* pToolBarCombo = pCommandBars->Add(_T("Combo"), xtpBarTop);
 pToolBarCombo->SetBarID(IDR_MAINFRAME + 3);
 
 CXTPControlColorBoxCB* pControlCombo = new CXTPControlColorBoxCB;
 pToolBarCombo->GetControls()->Add(pControlCombo); //(xtpControlComboBox, ID_FILE_NEW);
 {
       pControlCombo->SetColorBoxMode();
       int nIndex=pControlCombo->AddString(_T("White"));
       pControlCombo->SetBoxColor(nIndex,RGB(255,255,255),RGB(0,0,0));

       nIndex=pControlCombo->AddString(_T("Red"));
       pControlCombo->SetBoxColor(nIndex,RGB(255,0,0),RGB(0,0,255));

       nIndex=pControlCombo->AddString(_T("Black"));
       pControlCombo->SetBoxColor(nIndex,RGB(0,0,0),RGB(192,192,192));
       pControlCombo->SetCurSel(0);
 }

Posted by chungki

2009/09/02 10:32 2009/09/02 10:32
,
Response
No Trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/288

« Previous : 1 : 2 : 3 : 4 : 5 : ... 8 : Next »

블로그 이미지

Nice !!!!!!!!

- chungki

Notices

Archives

Authors

  1. chungki

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
73374
Today:
5
Yesterday:
20