Rasterdataset operations that overwrite the maximum value of rasterdataset

Source: Internet
Author: User

Dim year as string
Year = textbox1.text

'Leap year'
Dim meragematrixleapyear (11) as string 'Rules
Meragematrixleapyear (0) = "01001017"
Meragematrixleapyear (1) = "02033049"
Meragematrixleapyear (2) = "03065081"
Meragematrixleapyear (3) = "04097113"

Meragematrixleapyear (4) = "05129145"
Meragematrixleapyear (5) = "06145161"
Meragematrixleapyear (6) = "07177193"
Meragematrixleapyear (7) = "08209225"

Meragematrixleapyear (8) = "09241257"
Meragematrixleapyear (9) = "10273289"
Meragematrixleapyear (10) = "11305321"
Meragematrixleapyear (11) = "12337353"

'Non-leap year'
Dim meragematrixnonleapyear (11) as string
Meragematrixnonleapyear (0) = "01001017"
Meragematrixnonleapyear (1) = "02033049"
Meragematrixnonleapyear (2) = "03065081"
Meragematrixnonleapyear (3) = "04097113"

Meragematrixnonleapyear (4) = "05113129"
Meragematrixnonleapyear (5) = "06145161"
Meragematrixnonleapyear (6) = "07177193"
Meragematrixnonleapyear (7) = "08209225"

Meragematrixnonleapyear (8) = "09241257"
Meragematrixnonleapyear (9) = "10273289"
Meragematrixnonleapyear (10) = "11305321"
Meragematrixnonleapyear (11) = "12337353"


'Get the focused map from mapdocument
Dim pmxdoc as imxdocument
Set pmxdoc = thisdocument
Dim pmap as IMAP
Set pmap = pmxdoc. focusmap

'Create a rasterbandcollection from the raster layers In ArcMap
Dim penumlayers as ienumlayer


Dim player as ilayer
Dim praslayer as irasterlayer

Dim praster as iraster
Dim prbcolltmp as irasterbandcollection
Dim prband as irasterband

Dim prbcoll as irasterbandcollection


Dim month as integer
Dim dataname as string
Dim data1 as string
Dim data2 as string


'Create a rasterlocalop Operator
Dim plocalop as ilocalop
Set plocalop = new rasterlocalop

'Set output Workspace
Dim penv as irasteranalysisenvironment
Set penv = plocalop

Dim PWS as iworkspace
Dim pwsf as iworkspacefactory
Set pwsf = new rasterworkspacefactory
Set PWS = pwsf. openfromfile ("C: \ Temp", 0) 'output directory of the result data
Set penv. outworkspace = PWS

'Dim prws as irasterworkspace2' is used to create rasterdataset


For month = 0 to 11

Set penumlayers = pmap. Layers
Set prbcoll = new raster

Dataname = mid (meragematrixleapyear (month), 1, 2)
Data1 = mid (meragematrixleapyear (month), 3, 3)
Data2 = mid (meragematrixleapyear (month), 6, 3)

'Loop through all layers In ArcMap
Set player = penumlayers. Next
Do until player is nothing
If typeof player is irasterlayer then

If player. Name = "N" + year + data1 + ". tif" or player. Name = "N" + year + data2 + ". tif" then
Set praslayer = player
Set praster = praslayer. Raster
Set prbcolltmp = praster
Set prband = prbcolltmp. Item (0) 'must be in a single band.
Prbcoll. appendband prband
End if

End if

Set player = penumlayers. Next
Loop

'Compute cell-by-cell (local) Statistics
Dim poutraster as iraster
Set poutraster = plocalop. localstatistics (prbcoll, esrigeoanalysisstatsmaximum)


'Add output into ArcMap as a raster layer
Dim poutraslayer as irasterlayer
Set poutraslayer = new rasterlayer
Poutraslayer. Name = dataname 'assigns the layer name
Poutraslayer. createfromraster poutraster
Pmap. addlayer poutraslayer

Next month

Msgbox "generated! "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.