搜索此博客

2018年12月17日星期一

GeoTIFF file adds GCPs projection information


Georeferencing from GeoTIFF is supported in the form of one tiepoint and pixel size, a transformation matrix, or a list of GCPs[1].

Result after Thermal Noise Removal of Sentinel-1 imagery contain georeferencing information composed of one tiepoint and pixel size. Add georeference information refer to reference [2].

The georeference information like this :

Georeference information adding method is in 2.2.3  Adding georeferencing.



[1] https://www.gdal.org/frmt_gtiff.html
[2] https://download.osgeo.org/gdal/workshop/foss4ge2015/workshop_gdal.pdf


2018年11月16日星期五

Error Matrix



分类值 \ 真值
A
B
错分误差
用户精度
A
a
b
b / (a+b)
a / (a+b)
B
c
d
c / (c+d)
d / (c+d)
漏分误差
c / (a+c)
b / (b+d)


制图精度
a / (a+c)
d / (b+d)


总体精度



(a+b) / (a+b+c+d)

Kappa Coefficient = 




Reference:
http://blog.sciencenet.cn/blog-228125-292483.html


2018年11月13日星期二

Cleaning the Disk C

My computer has only 1.8 G today, I found that directory C:\Users\Baikal\Downloads\WinSxS too large, there are many old system files editions here, so I download a small software[1] to clean it. 

I didn't backup my data and files of it , bless for me it won't have some error.
It becomes bigger no longer red.

All right, there is nothing wrong!

Very perfect skills! In hyperlink, there is developer information, which is below.

姓名: 张善友
职业: 软件工程师
毕业于: 兰州大学2001
目前居住于: 中国深圳
目前就职于:深圳友浩达科技







13 Nov.2018 at 20:00 








Reference:


2018年11月2日星期五

Journey of writing paper of applying for Geography Master

Yesterday,Dr. Hui asked me to arrange my current study result to a paper, then submit the paper to Journal of BNU, Natural Sciences. If the paper will be submitted, the low-level paper at least relieve my guilty of my geography Master's degree. However, as I know, my result is very bad to submit the journal and maybe I won't achieve above wish before June in 2019. 


Whatever, first thanks for my supervisor PhD. Hui he is a perfect associate professor. The process of writing paper and modification will be good for me and improve my level and horizon. 

First Challenge:
Today(Nov. 2nd) ,  I encountered the first problem that adding reference. JBNU demands that format of reference papers should has only the first authors for paper and others using et al. Hyperlink[1] is my search result, but I cannot get anything after do as it said.

I think I knew why I failed after the parameters modification. I should use the existing IEEE format style to change. Hyperlink [1] doesn't illustrate very clear in output style of IEEE copy , in reality, this style generated in selection of IEEE style.
Succeed!

Fig.1 shows the original IEEE output style. Fig. 2 is JBNU template of references. All the modifications are achieved in Edit->Output Styles->Edit "IEEE Copy"( Modification window as Fig.3).
Fig.1 Reference Template of Journal of BNU
Fig.2 JBNU template of references label
Fig.3 Modification Location

Fig.4 Modification Result
It's 23:22.







Reference:


Spyder,switching between python 2 and 3


Kernels for Python2:

Call on pip version:
Python –m pip –version
Installing ipykernel using pip tools:
Python –m pip install ipykernel
Python –m ipykernel install –user
To create Python environment :
Conda create –n ipykernel_py2 python=2 ipykernel
Source activate ipykernel_py2
Python –m ipykernel install –user

Kernels for different environments:
If u want to have multi-Ipython kernels for different virtualenvs or conda environments, u will need to specify unique names for the kernelspecs.








2018年10月26日星期五

LibSVM Error

I was using LibSVM to process classification before, however, I changed the grid.py file and didn't realize it. 

Today, I found the file modification time is unnormal so I download LibSVM from Chih-Jen Lin . It worked again. The following pic illustrates the selection of best parameters of -c and -γ.





2018年10月17日星期三

GLCM program improving to save time


Counter() modificaiton depends on link[1].
Some questions I asked and posted in Stack Overflow website and my one account profile is link[2].
Biggest harvest is modify my program of GLCM to faster about 4 times.


However, it takes over one hour to process window size of 79 pixels. This cannot be acceptant.


Modification Program code in Github: link [3]

Reference link:
[1] https://stackoverflow.com/questions/34734933/access-contents-of-list-after-applying-counter-from-collections-module
[2] https://stackoverflow.com/users/9187964/baikal?tab=questions
[3] https://gist.github.com/Falcon-Baikal/3b6529abe80988501ead0abed1d01186

2018年10月10日星期三

Difficult 4 days of Big Problem of Noise Removal of Sentinel-1 imagery

First Question:
Sentinel-1 original HH or HV tiff image convention is still failing, including in ENVI  and SNAP software. Question on two results by using these methods convention contribute to the extents of these two images are different from the original.

Finally, I using gdal_translate solved the problem.But, I think this convention step is superfluous.

However, there is still GCPs information in the result, then direct adding of GCS_WGS_1984 projection information is invalid and will get a tiff file that pixel coordinate is over 5000+ degree northern latitude. This is obviously WRONG! So, I think Geo Points i.e. GCPs information leads to the error.
Therefore, there is second question.

Second Question:
How to add correct projection of a Geotiff image to a tiff without projection information?
Most relevant link is [1], however, there is no answer to the question. Then, I went on searching in Stack Overflow and Google!

Maybe link [3] can answer to the Q. Let me try!
I think my Question is very similar to link [3], 
Solving method is like below:


you can use gdal_edit.py for this:
gdal_edit.py -gcp 0.0 0.0 68.7535734331 81.6383694455 two.tiff
However, I don't how he extracted all of these points into one string. That's too bad!
GeoTiff official website! 3 formats composite GTiff files!


The following website[6] introduces how to georeference. As @Manimalis said, My Sentinel-1 image is similar to the website. It meas 'At this point, the image is not georeferenced yet.' Then I tested 'gdalwarp' method and only to find it is used to georeference. Therefore, it cannot be used. I just need to add these GCPs to Tiff file rather to georeference.


So, I succeed to georeference a tif file with GDAL with the use of 4 gcps (ground control points). To do this reprojection, I use gdal in command line.
First, use gdal translate like this :
gdal_translate -of GTiff -gcp 0 0 -6.848326  45.501053 -gcp 6862 0 -6.490975 45.501503 -gcp 0 1379 -6.762872 45.377363 -gcp 6862 1379 -6.545354 45.382523 "Inputimage.tif" "OutputImage.tif"
The ground control points are build like this : pixel coordinate in the image (x, y) and then geographical location (longitude, latitude).
I suggest to check with gdalinfo if the output file after gdaltranslate has been correctly fed with the gcps. With gdalinfo, you have to see in dos command something like that :
Coordinate System is `'
GCP Projection =
GCP[  0]: Id=1, Info=
          (0,0) -> (45.501053,-6.848326,0)
GCP[  1]: Id=2, Info=
          (6862,0) -> (45.501503,-6.490975,0)
GCP[  2]: Id=3, Info=
          (0,1379) -> (45.377363,-6.762872,0)
GCP[  3]: Id=4, Info=
          (6862,1379) -> (45.382523,-6.545354,0)
At this point, the image is not georeferenced yet. You have to use gdalwarp like this (there is several way to reproject, here I use "near" :
gdalwarp -r near -order 1 -co COMPRESS=NONE -dstalpha 
"OutputImageF_From_gdal_translate.tif" 
"FinalImage.tif"
shareeditflag                                                                                                     


Finally, I changed language(English-->Chinese) and website(Google-->Chinese) for searching. When I type in ' tiff 提取 gcps' only to find the function extracting GCPs in Geotiff files, that is 'GetGCPCount', 'GetGCPProjection', 'GetGCPs' in website[7](as following picture), all this function I also find using Google in English in link [8]. However, I think those functions can only use in C language and there is no practical examples in the website.
The following is the example in website[7].
I think I have found the answer for the question. Those functions of gdal is just answer.(Oct. 12, 2018)

However, I don't how to using SetGCPs......
Saturday(10.13), I attended practice test of civil servant in the morning, I still about 30 questions not to answer. I began to try to find the wrong reason for my code in the afternoon. In the evening, I found that change SetGCPs function to 'ds.SetGCPs(  gcp )' can get this error, 'TypeError: Dataset_SetGCPs() takes exactly 3 arguments (2 given)',  error of 'TypeError: Dataset_SetGCPs() takes exactly 3 arguments (4 given)' when I use 'ds.SetGCPs(  gcpcount , gcp, gcpproj )'. Therefore, I guess gcp should change format before set it into SetGCPs function.

Then, I found maybe the answer of website[3] is useful. I can try it! Besides, website[9] is GCP() function introduction. It can be following two format. I want to use first type.

GCP​(double x, double y, double pixel, double line)
GCP​(double x, double y, double z, double pixel, double line)

Or if you want to do it in a more pythonic way (adapted from gdal_edit.py):
from osgeo import gdal

gcp_items = filter(None, gcp_string.split("-gcp"))

gcp_list = []
for item in gcp_items:
    pixel, line, x, y = map(float, item.split())
    z = 0
    gcp = gdal.GCP(x, y, z, pixel, line)
    gcp_list.append(gcp)

ds = gdal.Open("two.tiff", gdal.GA_Update)
wkt = ds.GetProjection()
ds.SetGCPs(gcp_list, wkt)
ds = None
Note: this is assuming that the projection of one.tiff and two.tiff are the same. Otherwise you will have to get the wkt from one.tiff.


However, when I using this method and modified my code, after runing well, I got same error as before. gdal.GCP() function is used for converting the format as same to function of GetGCPs(). I do again some idle work. Sad! 





However, this is no error when I just put gcp_list and gcpproj as above picture, but noise tif cannot get GCPs and projection. WHY?????????!!!!!!!!!!!!

I finally solved the error !!!!!! Missing the word 'ds = None', the answer is on website[3]. 
The following picture is result of noise tiff adding GCPs and projections from Sentinel-1 images. My God! Relevant question I posted on Stack Overflow is website[10]


4 days have run off! 

Until now(10.14), Second question has successfully solved by myself!

However, I found I have do the Thermal Noise Removal in re-processing Python program(10.15). Therefore, I don't know Tingting Zhu(WHU) in her PhD graduation thesis to do this work by herself. The following picture is SNAP TNR step introduction
My pre-processing p Python program( website[11]) includes 4 steps.

Eventually, I have to again resume my GLCM program modification work.
Last week, my largest harvest is improve my ability of writing and convention from point data  to raster interpolation based on XML. This experience is very inspiring! ( 17:09 in Oct. 15, 2018)

Reference Link:
[1] https://stackoverflow.com/questions/48770002/project-raster-file-using-gcps
[2] Gdal_translate Webpage: https://www.gdal.org/gdal_translate.html
[3] Add GCP to GeoTIFF https://gis.stackexchange.com/questions/206544/in-python-gdal-how-to-add-ground-control-point-to-geotiff-image-by-using-gdal-tr 
[4]  Use GDAL command line to copy projections  https://gis.stackexchange.com/questions/108673/use-gdal-command-line-to-copy-projections
[5] https://gis.stackexchange.com/questions/257904/converting-geotiff-with-gcps-into-projcs-with-python-gdal
[6] https://gis.stackexchange.com/questions/159004/creating-geotiff-from-tiff-using-gdal/159436#159436
[7] https://blog.csdn.net/bcbobo21cn/article/details/51014246?locationNum=12&fps=1
[8] https://www.gdal.org/classGDALDataset.html
[9] https://gdal.org/java/org/gdal/gdal/GCP.html
[10] https://gis.stackexchange.com/questions/298806/error-of-copying-gcps-information-from-geotiff-to-another-tiff
[11] https://www.dropbox.com/s/bk25khnha7w85wg/procSentinelRTC_recipe.py?dl=0

LibSVM Chinese Brief Infroduction

Reference: [1]  https://blog.csdn.net/v_july_v/article/details/7624837 [2]  https://wenku.baidu.com/view/c402e983336c1eb91b375d37.html?fr...

  • Word (2)