ArcMap VBA generates SHP elevation Fields Based on DEM elevation values

Source: Internet
Author: User
Tags ipoint

Dim app as iapplication
Set APP = Application

Dim pmxdocument as imxdocument
Set pmxdocument = application. Document

Dim pmap as IMAP
Set pmap = pmxdocument. focusmap

Dim pfeaturelayer as ifeaturelayer
Set pfeaturelayer = pmap. layer (0)

Dim prasterlayer as irasterlayer
Set prasterlayer = pmap. layer (1)

Dim praster2 as iraster2
Set praster2 = prasterlayer. Raster

Dim prasterpros as irasterprops
Set prasterpros = praster2

Dim PFC as ifeatureclass
Set PFC = pfeaturelayer. featureclass

Dim pfeaturebuffer as ifeaturebuffer
Dim pfeaturecursor as ifeaturecursor
Dim pfeature as ifeature
Dim Ppoint as ipoint
Dim Pt as ipoint
Dim Q As long

Dim index as long
Index = PFC. Fields. findfield ("height ")

Dim I as long
Dim J as long
Dim row as long
Dim column as long

Row = prasterpros. Height
Column = prasterpros. Width

For I = 0 to row-1
For J = 0 to column-1

Set Ppoint = new point
Ppoint. x = praster2.tomapx (j)
Ppoint. Y = praster2.tomapy (I)

Set pfeaturebuffer = PFC. createfeaturebuffer
Set pfeaturecursor = PFC. insert (true)
Set pfeature = pfeaturebuffer

Set pfeature. Shape = Ppoint
Pfeature. Value (INDEX) = praster2.getpixelvalue (0, J, I)

Q = pfeaturecursor. insertfeature (pfeaturebuffer)

Next J
Next I

Pfeaturecursor. Flush

Msgbox "done! "

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.