GIScript2016 is a geospatial data processing and analysis toolkit that supports Python3, supports Jupyter and Spark, and can run on single machines and large-scale clusters. GIScript with Jupyter+Spark on Docker is a very powerful technology stack. A large number of scientific computing packages can also be installed through the conda package management program, such as NumPy, Scikit, Pandas, and OpenCV, NLTK, Tensorflow, Keras and other machine learning packages. An artifact for big data processing, analysis and in-depth research.
1. Create a Docker container
In the previous blog post [ GIScript2016-Jupyter Notebook Deployment on Docker], the method of deploying GIScript to Docker was introduced. Then we can push this container image to DockerHub, which can be used in other computers on the Internet.
1.1 Submit a container image
First, submit an image under your own DockerHub account (if you don't have an account, register one on hub.docker.com), and then submit the current image as the account's version. As follows:
docker commit GISpark openthings/gispark
1.2 Push the image to the cloud
First, log in to the Docker account as follows:
docker login
Enter the account and password registered on DockerHub according to the prompts.
Start pushing Docker images to DockerHub cloud storage as follows.
docker push openthings/gispark
The above openthings is your registered username on Dockerhub, which needs to be changed to your own. The same below.
1.3 Pull the image to the local machine
Then go to another computer and pull the image down:
docker pull openthings/gispark
2. Run the Docker container
2.1 Running a GISript container instance
docker run -it --name GISpark
-p 9000:8888
--user root -e GRANT_SUDO=yes
-v /本地目录/GISpark:/home/jovyan/work/GISpark
openthings/gispark
The local directory is the directory of the host, which is used to store shared data. Enter Docker ps to see a list of all currently running containers.
2.2 Close the container instance
Follow the prompts in the console window, press Ctrl+C and then select y or press Ctrl+C twice to exit the running state.
2.3 Restart the container instance
Use docker start 容器ID
start-stopped instances (use docker ps -a to see a list). Use docker restart 容器ID
to restart a running instance.
2.4 Getting started
Open the browser, enter: http://localhost:9000 , you can see:
3. Run the Python3 routine
Click the "New" button, select "Python3", and create a new Notebook. Then copy the code below into the Cell.
Take file information as an example:
# coding: utf-8
import sys
from GIScript import GISCore,Conversion
'''
! \brief 文件路径定义
'''
strTiffPath = "Raster/astronaut(CMYK)_32.tif"
if __name__ == '__main__':
try:
fileParser = Conversion.FileParser()
bOpen = fileParser.Open(strTiffPath, "fileTIF")
if bOpen:
rasterInfo = fileParser.GetRasterInfo()
nWidth = rasterInfo.GetWidth()
nHeight = rasterInfo.GetHeight()
pixelFormat = rasterInfo.GetPixelFormat()
rc2Bounds = rasterInfo.GetBounds()
nBandCount = rasterInfo.GetBandCount()
nBlockSize = rasterInfo.GetBlockSize()
strPrj = rasterInfo.GetProjection()
dXRatio = rc2Bounds.Width()/nWidth
dYRatio = rc2Bounds.Height()/nHeight
colorset = rasterInfo.GetColorset()
dMax = rasterInfo.GetMax()
dMin = rasterInfo.GetMin()
dNoValue = rasterInfo.GetNoValue()
print("=========文件基本信息=========")
print(" 图片宽:" , nWidth)
print(" 图片高:" , nHeight)
print(" 像素格式:",pixelFormat)
print(" 波段数:", nBandCount)
print(" 块大小:",nBlockSize)
print(" 是否是块存储数据:",rasterInfo.GetIsTile())
print(" Bound范围(左上右下):(", rc2Bounds.left, ","\
,rc2Bounds.top, ",", rc2Bounds.right, ",", rc2Bounds.bottom, ")")
print(" X、Y分辨率:", dXRatio, dYRatio)
print(" 颜色表大小:" , len(colorset))
print(" 极大值:" , dMax)
print(" 极小值:" , dMin)
print(" 无值:", dNoValue)
if strPrj != "":
print(" 投影:", strPrj)
else:
print(" 投影:平面坐标系")
print("=============================")
fileParser.Close()
except SystemExit:
raise
except:
sys.stderr.write(
"""An internal error occured.
""")
raise
Press Shift+Enter to run the above code.