November 16, 2006

Read Raw Pixel values from Raster using ArcObjects

Relevant Interfaces and Classes
IRaster, IPixelBlock, IRawPixels
see IRaster, IRawPixels examples in ArcGIS developers' help

Sampel code from

Public Function GetRasterValue(X As Double, Y As Double) As Double
'Raster Layer
Dim pRLayer As IRasterLayer
'Set layer to top raster layer in mapcontrol1
Set pRLayer = MainForm.Map1.Map.Layer(0)
'New Raster object
Dim pRaster As IRaster
'Set raster to top raster layer
Set pRaster = pRLayer.Raster

'Pixelblock object (i.e. can be one pixel up to every pixel in raster
Dim pPixelBlock As IPixelBlock
'New point
Dim pPoint As IPoint
Set pPoint = New Point
'Set point to curso coordiantes (map coordinates)
pPoint.PutCoords X, Y
'Set pixel block size to only one cell
Set pPixelBlock = pRaster.CreatePixelBlock(MakePnt(1#, 1#))
'Read in entire domain to find max value

'Read value of pixel
pRaster.Read GetPixelPnt(pPoint, pRaster), pPixelBlock
'Store value of all pixels in pixleblock in an array
Dim nv As Variant
nv = pPixelBlock.SafeArray(0)
'Store value in pPoint.Z
pPoint.Z = nv(0, 0)

GetRasterValue = pPoint.Z
End Function

'Creates point for cell size of 1
Function MakePnt(dX As Double, dY As Double) As IPnt
Set MakePnt = New DblPnt
MakePnt.SetCoords dX, dY
End Function

'Get size of one pixel
Function GetPixelPnt(pPoint As IPoint, pRasterProps As IRasterProps) As IPnt
' make a point based on the raster's row & column
Dim lRow As Long, lCol As Long
Dim pPnt As IPnt, PixelWidth As Double, PixelHeight As Double
Set pPnt = pRasterProps.MeanCellSize
PixelWidth = pPnt.X
PixelHeight = pPnt.Y
Dim dTop As Double, dLeft As Double
dTop = pRasterProps.Extent.YMax
dLeft = pRasterProps.Extent.XMin
Set GetPixelPnt = New DblPnt
GetPixelPnt.SetCoords _
Round(Abs(pPoint.X - dLeft - (0.5 * PixelWidth)) / PixelWidth), _
Round(Abs(pPoint.Y - dTop + (0.5 * PixelHeight)) / PixelHeight)
End Function

Posted by sunx0170 at 2:17 PM · ArcGIS

June 23, 2005


G70.23 .F7 1993, Fractals in Geography, pp228-246
HV91 .P765 2002, Property-tax exemption for charities: Mapping the battlefield Bowman
Journal of Public Economics, 1997, 66, 3, 383-407
Regional Science and Urban Economics, 1992, 22, 334, 453-474
Natural resource journal, Law Library, Summer 2003, Vol. 43, No. 3
Geoforum, 1984, 15, 1, 33-38, Policy Evaluation
* Journal of Urban Economics, 1991, 30, 2, 242-256
Land Use Policy, 1996, 13, 4, 241-259

Posted by sunx0170 at 2:39 PM · Online Resources

April 18, 2005

March 21, 2005

Moving objects between layers

By default, Freehand MX automatically moves selected objects to currently clicked layer, which often cause unintentional operations. For example, if features are placed in the background layer, they will be shown with lighter color. To correct this problem, read "Moving objects and reordering layers" entry of "Using Layers" part in "Using Layers, Symbols, and Styles" Chaper (Using Freehand MX, Freehand Help System).

Posted by sunx0170 at 3:28 PM · Cartography

March 12, 2005

Learn Computer Skills, Not Be Taught


Posted by sunx0170 at 2:18 PM · Cartography

Create Legend

The simplest way to create legend is "copy and paste". Creating point feature legend doesn't need any explanation, just "Ctrl+C and Ctrl+V". For line and polygon, if you can find features whose sizes are suitable for legend, don't hesitate to copy them; if not, draw some lines and polygons, and use Swatches and Styles in Assets to symbolize them. For doing that, you need to save your line and polygon symbolization into Styles first; then, select the lengend and simply click the Styles in Assests.

Posted by sunx0170 at 2:13 PM · Cartography

Make Image Background Transparent


Many point features or labels can be represented by images, e.g., the McDonalds. However, most images are created in rectangles, which set a color as image background and often disturb the map. Most image files contain an alpha value for each pixel controlling transparency. All professional image processing software have the function of setting alpha value, such as Adobe Photoshop. However, Macromedia Freehand MX, a professional VECTOR graphic software, doesn't have the ability to do that. Fortunately, Microsoft Word has a picture tool which is able to set a color as transparent. Though the result may not be very good, for many reasons, it is a good option for most tasks.


1. Insert an image into Microsoft Word;
2. Show the picture toolbar;
3. Select the "Set Transparent Color" tool (The second one from the right);
4. Click the background area of the image;
5. Select the whole image, and copy it using "Edit-Copy" or "Ctrl+C";
6. Go to Freehand, paste it on the map;
7. Resize it if needed.
8. Drag it into Library, save it as a symbol, and give a meaningful name;
9. Apply the image to symbolize features on the map using Swap tool.

Posted by sunx0170 at 2:12 PM · Cartography

Create Map INSET Using Freehand MX


According to the content of insets, they can be classified into two categories: larger-scale and smaller-scale insets. The first category is used to show a congested area in greater detail; whereas, the second is often used to show the position or environment of the main map within a larger area or context. The method introduced here is only applicable for the first type, i.e., to show more details for congested area. The kernel operation for creating inset in Freehand is "Clipping Path", and the explanation of the concept can be found in "Working with clipping paths" part of "Working with Objects" chapter (Freehand Help: Using Freehand MX).

General Steps

1. Make a backup of the map using Save As command in File menu;
2. Zoom to the area you want to put in an inset;
3. Create a new layer by clicking on "Options - New" on Layers panel, and name it "Inset_Layer";
4. Copy the targeted objects into the Inset_Layer, and lock, hide all other layers;
5. Resize the symbols, reduce stroke width etc. to fit the size of the inset;
6. Instead of a circle, use a rectangle to create a clipping path following the instructions in help;
7. Move and resize the clipping path;
8. If the symbolization of some object is not satisfactory, select and change it using "Subselect" tool and Object panel.

Posted by sunx0170 at 2:11 PM · Cartography

March 7, 2005

Python in 455

1. A Python Script will fail if the COM objects cannot write output files to destination folder correctly, as happened when overwritting, writing to USB Key or CD-RW etc. For Python Script, most users need to run their files again and again for debug, so it is recommended to allow overwriting.

DIY: ArcMap -- Tools -- Options -- Geoprocessing -- General -- Overwrit the outputs of geoprocessing operations.

2. Python Parameters
Python scripts can read parameters from command lines through sys.argv[] varaibles. When ArcMap specify ArcTool parameters, it actually will send the parameters to python.

3. Parameter Type
Though FeatureLayer and Shapefile are the same type to Python Script, they are different for ArcToolbox; therefore, the FeatureLayer type doesn't accept a shapefile as a parameter.

Posted by sunx0170 at 4:18 PM · ArcGIS

March 2, 2005


Simple rules for Sliver Polygon Removal
1. Area
2. Perimeter/Area
3. Number of Arcs (Countvertices can generate arc numbers for polygons.)

Posted by sunx0170 at 7:09 PM · Generalization