[ArcGIS Storm] GlobeLand30 global data processing tutorial (batch projection conversion, invalid value processing, splicing)

This article describes the GlobeLand30 global data batch processing process. The main steps include: batch framing projection conversion, batch framing invalid value processing, batch map splicing and finished product display. Due to the large number of map frames and the large amount of data, this article is implemented in batches using Python code. For basic operations and processing cases of Python, you can refer to the practical boutique column: "ArcGIS Meets Python"

Article Directory


1. Data introduction

GlobeLand30 is a global land cover data with a spatial resolution of 30 meters, currently available for download and use of data for 3 years: 2000-2010-2020.

GlobeLand30 data adopts the WGS-84 coordinate system. For the area between 85°south latitude and 85°north latitude, the projection method is adopted UTM投影, with 6-degree zone, the coordinate unit is meters, and the coordinates are not marked with a number. The area between the north and south latitude is between 85° and 90°, the projection method is adopted 极地方位投影, and the projection surface is tangent to the north and south points of the earth.

2. Data preparation

Download the 2000-2010-2020data of 3 years ( ) and unzip them to the corresponding folders.

Insert picture description here

Three, processing flow

1. Batch projection conversion

GlobeLand30 data adopts the WGS-84 coordinate system.

For the area between 85°south latitude and 85°north latitude, the projection method is adopted UTM投影, with 6-degree zone, the coordinate unit is meters, and the coordinates are not marked with a number.

The area between the north and south latitude is between 85° and 90°, the projection method is adopted 极地方位投影, and the projection surface is tangent to the north and south points of the earth.

Therefore, it is necessary to perform projection conversion on all the frames first, and then perform subsequent operations such as stitching. This article converts it to the geographic coordinate system as WGS1984.

Python batch processing core code:

def GetRaster(path):
    n=0
    if (os.path.exists(path)):
        files = os.listdir(path)
        for file in files:
            m = os.path.join(path,file)
            if (os.path.isdir(m)):
                h=os.path.split(m)
                ws=root+"/"+h[1]
                arcpy.env.workspace = ws
                rasters = arcpy.ListRasters("*", "tif")
                
                for raster in rasters:
                    print "Finding  "+ raster
                    
                    print "Projecting "+raster
                    out=outPath+"/"+raster
                    arcpy.ProjectRaster_management(raster,out, projecttype, "NEAREST",cellsize , "", "",geogratype)
                    n=n+1
    print str(n)+" rasters are processed !!!"
GetRaster(root)

ArcGIS Python supports multi-threaded processing, and 3 years of data can be batch processed simultaneously. . . .

Due to the large number of frames and the amount of data, the process will last a long time, which may be several hours or days. Therefore, if you do not have a powerful enough machine and heart, it is recommended not to try it lightly.

2000:

Insert picture description here


year 2010:

Insert picture description here


2020:

Insert picture description here

Northern Hemisphere projection result:

Insert picture description here

Partial map display:

Insert picture description here


The coordinate system of each map frame after projection conversion is WGS 1984.

Insert picture description here

2. Batch processing invalid values

After the first step of projection is over, the black border of the image still exists. This will be the result of the stitching process behind the image. After querying, it is found that the pixel value corresponding to the black border is 0. You only need to set it to NoData. The tool is the SetNull function in the raster calculator, and we continue to use Python batch processing.

Insert picture description here


Python automatic batch processing core code:

for inRaster in inRasters:
    outRaster=outpath+inRaster
    ##print outRaster
    print "Processing "+inRaster +" ......"
    outSetNull = SetNull(inRaster,inRaster,WhereClause)
    outSetNull.save(outRaster)
    n=n+1
print str(n)+" rasters are processed!"
Insert picture description here

3. Batch image splicing

There are two tools for splicing raster maps in ArcGIS: [Mosaic] and [Mosaic to New Raster]. Of course, you need to add data manually. Fortunately, our data is in the same folder and you can directly select and drag all of them. Of course, you can also write Python code to complete.

Method 1: Use [Mosaic to New Raster] tool

Insert picture description here

Method 2: Python code

 arcpy.MosaicToNewRaster_management(str, outPath, outName, "", "8_BIT_UNSIGNED", "", "1", "LAST", "FIRST")
It should be noted that the original data set is in tif format, and each map frame has a pyramid, and the loading and display speed is relatively fast, but the pyramid will be lost after SetNull, and the loading speed is very slow.

4. Add category fields and assign values

Open the attribute table, add a text field type, open the editor, enter the category name and save it.

Insert picture description here


Classification assignment reference table:

Insert picture description here
Insert picture description here

5. Create a color map

Double-click the 2000 data layer, open the layer properties, switch to [Symbol System], and click [Color Map] → [Export Color Map].

Insert picture description here


Select the storage path and enter the name. The suffix of the color map is .clr.

Insert picture description here

6. Import the color map

With the color map (GlobeLand30 color map.clr file) just exported, you can quickly symbolize the remaining two years of data by double-clicking on the 2010 and 2020 data layers, opening the layer properties, and switching Go to [Symbol System], click [Color Map] → [Import Color Map].

Insert picture description here

Fourth, the finished product display