I needed to add a bunch of tick marks to a line in a layout in ArcGIS. I am not aware of a built-in tool to do this, so I created my own. It is just for the horizontal, but may be modified for the vertical. I made it fairly generic so that the inputs might be automated as well.
It is available here...Hopefully it will help someone.
Showing posts with label ArcGIS. Show all posts
Showing posts with label ArcGIS. Show all posts
Wednesday, October 29, 2008
Monday, September 29, 2008
More ArcScene Stuff
So, I spent all that time setting up the repair data source code, and then discovered that by right-clicking on the layer, going to Data --> Repair Data Source, ArcWhatever fixes all the ones that were in the same folder. Same problem with the base heights though.
Now I'm exporting ArcScene scenes to 2d images. I had originally done this on my laptop and got everything setup on there. There were problems exporting the image with background vector data (roads and coastline). The coastline was a polygon and came out with extra lines cutting across the 3d. So my work around was to export the vector and 3d as separate images and then make them as layers in PhotoShop Elements. This works pretty well. Now I'm working on the desktop and discovered that the images don't export the same size. The reason for this is the monitor size and resolution as the export dimensions are determined by this. You can also change the export dimensions by changing the height and width of ArcScene. This is a pain to duplicate, but at least now I know what the problem is.
Now I'm exporting ArcScene scenes to 2d images. I had originally done this on my laptop and got everything setup on there. There were problems exporting the image with background vector data (roads and coastline). The coastline was a polygon and came out with extra lines cutting across the 3d. So my work around was to export the vector and 3d as separate images and then make them as layers in PhotoShop Elements. This works pretty well. Now I'm working on the desktop and discovered that the images don't export the same size. The reason for this is the monitor size and resolution as the export dimensions are determined by this. You can also change the export dimensions by changing the height and width of ArcScene. This is a pain to duplicate, but at least now I know what the problem is.
Repair Datasource
I had a number of ArcScene documents (sxd) with several layers (>20) with a broken source, and I didn't really feel like manually going through each one and repairing it, so I poked around trying to find an example to do it in VBA. Most of the examples were for feature layers, whereas these were all raster layers, and none were for ArcScene. I found one that worked for rasters, but then I lost the renderer and layer name which were both important in the file.
This is the mesh that I came up with. Probably a good idea to save your sxd as something else before running the code. I also needed to close out and open back up before the settings took effect. The base heights disappeared and I'm not sure why this happened but I already had a bit of code to set the base height to the layer because I'm lazy and didn't want to go layer by layer setting the base heights.
Here is the code to set the source:
You will probably need to change the start layer, as I had it set as 1 instead of 0.
Here is the code for the base heights.
There are no checks to make sure the layer is raster and not a feature layer. This is one area that could be expanded. Since it is for a fairly custom file, I know which layers are what type.
This is the mesh that I came up with. Probably a good idea to save your sxd as something else before running the code. I also needed to close out and open back up before the settings took effect. The base heights disappeared and I'm not sure why this happened but I already had a bit of code to set the base height to the layer because I'm lazy and didn't want to go layer by layer setting the base heights.
Here is the code to set the source:
Private Sub SetSource()
Dim pDoc As ISxDocument: Set pDoc = ThisDocument
Dim pScene As IScene: Set pScene = pDoc.Scene
Dim pSG As ISceneGraph: Set pSG = pScene.SceneGraph
Dim pSV As ISceneViewer: Set pSV = pSG.ActiveViewer
Dim il As Integer
Dim pNewWorkspaceName As IWorkspaceName
Set pNewWorkspaceName = New WorkspaceName
With pNewWorkspaceName
.PathName = "D:\gamblingout"
.WorkspaceFactoryProgID = "esriDataSourcesRaster.RasterWorkspaceFactory.1"
End With
For il = 1 To pScene.layerCount - 1
Dim pLayer As ILayer: Set pLayer = pScene.Layer(il)
Dim pRLayer As IRasterLayer: Set pRLayer = pLayer
Dim pDataLayer2 As IDataLayer2: Set pDataLayer2 = pRLayer
Dim pDatasetName As IDatasetName
Set pDatasetName = pDataLayer2.DataSourceName
Set pDatasetName.WorkspaceName = pNewWorkspaceName
pDataLayer2.DataSourceName = pDatasetName
pDoc.UpdateContents
Next
End Sub
You will probably need to change the start layer, as I had it set as 1 instead of 0.
Here is the code for the base heights.
Public Sub Set3d()
Dim pDoc As ISxDocument: Set pDoc = ThisDocument
Dim pScene As IScene: Set pScene = pDoc.Scene
Dim il As Integer
For il = 1 To pScene.layerCount
Dim pLayer As ILayer: Set pLayer = pScene.Layer(il)
Dim pLayerExt As ILayerExtensions: Set pLayerExt = pLayer
Dim p3dProps As I3DProperties
Dim i As Integer
' look for 3D properties of layer:
For i = 0 To pLayerExt.ExtensionCount - 1
If TypeOf pLayerExt.Extension(i) Is I3DProperties Then
Set p3dProps = pLayerExt.Extension(i)
Exit For
End If
Next
Dim pSurf As IRasterSurface
Dim pBands As IRasterBandCollection
Dim pRasterLayer As IRasterLayer
Set pRasterLayer = pLayer
p3dProps.BaseOption = esriBaseSurface
Set pSurf = New RasterSurface
Set pBands = pRasterLayer.Raster
pSurf.RasterBand = pBands.Item(0)
Set p3dProps.BaseSurface = pSurf
p3dProps.Apply3DProperties pLayer
Next
pDoc.UpdateContents
End Sub
There are no checks to make sure the layer is raster and not a feature layer. This is one area that could be expanded. Since it is for a fairly custom file, I know which layers are what type.
Labels:
ArcGIS,
ArcObjects,
ArcObjects Tutorial,
ArcScene,
GIS Programming
Wednesday, July 30, 2008
Et Tu ESRI?
Sigh. I'm impressed to see the new effort ESRI is putting in trying to emphasize ArcGIS as a GIS that also can be used as a cartographic product. In the past, maps have seem to be an after thought. In the 1st edition of Getting to Know ArcGIS, one of the projects has the user create a series of beautiful, colorful, thematic maps...without a single legend. What good is that? So when I caught site of the recent MappingCenter Blog entry I was a little dismayed at what they are advertiseing with the photo they have up:
This is a terrible example that they are using. If I'm not mistaken, bodies of water are treated as a single elevation at the water surface (unless showing bathymetric contours), therefore showing contours cutting off at the edge of the water surface is totally inappropriate. These contours should go around the pond not through it!
On a side note. The Mapping center does have some useful information. I really like all the Historic Map symbols they created.
On a side note. The Mapping center does have some useful information. I really like all the Historic Map symbols they created.
Tuesday, June 10, 2008
ArcGIS QuickTip #2
This isn't a quicktip. I've posted a short example on how to use ModelBuilder in ArcGIS to build a more robust tool by adding options to manipulate the Environmental Settings.
http://boxshapedworld.googlepages.com/modelbuildertips
http://boxshapedworld.googlepages.com/modelbuildertips
Labels:
ArcGIS,
ArcObjects Tutorial,
ModelBuilder,
Quick Tip
Monday, June 9, 2008
Camel's 'R' Us
I am working on creating scripts to create weighted linear combination. Basically duplicating different features in Idrisi so that I can have two models, one in ArcGIS and Idrisi. This is for the "Camel Project." I have a script now that calculates the weights for a pairwise matrix. Once I found a little information on this topic it was fairly easy to create. It is mostly just multiplying the matrix until the differences between the weights calculated from each iteration equals zero. Unfortunately, the python script is dependent on NumPy (Numerical Python), so it isn't as self-contained as I would like. I didn't feel like writing a function to multiply matrices, although I did this in VB.NET. I also am able to calculate the consistency ratio. I would share the script, but I because I am getting paid to do it, it is up to the client.
I also have managed to use Raster Calculator to duplicate the Fuzzy tool in IDRISI. It is a duplicate of the Linear function, and there are two ways to calculate it. One for monotonically increasing, and the other for monotonically decreasing. The formula is for 0 to 255.
Con is a map algebra function that means conditional. Con(test, true, false).
Here is how it works for monotonically decreasing:
INT((Con([RasterToBeScaled] <> 900, 0,( ((900 - [RasterToBeScaled]) * 255) / 900) + 0))) + .5)
Con([RasterToBeScaled] <> 900, 0 if the cell value is greater than 900 give this cell a value of 0. If it is false then calculate the value
( ((900 - [RasterToBeScaled]) * 255) / 900) + 0)))
INT and +.5 rounds the values properly and removes the decimal places.
The range of this example is from 0 to 900, so you need to change those values depending on what your "maximum and minimum" values are going to be. You really divide 900 - [RasterToBeScaled] by the range (max - min raster values). Since my range was 0 to 900 I skipped this and put 900.
If you need this to increase then you have to change some of it around.
INT((Con([RasterToBeScaled] <> 900, 255,( (([RasterToBeScaled] - 0) * 255) / 900) + 0))) + .5)
Now, whatever is less than zero is zero and greater than 900 is 255. Everything in between is calculated using the formula:
( (([RasterToBeScaled] - 0) * 255) / 900) + 0))
So now we subtract the cell value by the lowest value in your range and everything else is the same.
This is similar, but not quite what I was looking for.
Hope that helps...
I also have managed to use Raster Calculator to duplicate the Fuzzy tool in IDRISI. It is a duplicate of the Linear function, and there are two ways to calculate it. One for monotonically increasing, and the other for monotonically decreasing. The formula is for 0 to 255.
Con is a map algebra function that means conditional. Con(test, true, false).
Here is how it works for monotonically decreasing:
INT((Con([RasterToBeScaled] <> 900, 0,( ((900 - [RasterToBeScaled]) * 255) / 900) + 0))) + .5)
Con([RasterToBeScaled] <> 900, 0 if the cell value is greater than 900 give this cell a value of 0. If it is false then calculate the value
( ((900 - [RasterToBeScaled]) * 255) / 900) + 0)))
INT and +.5 rounds the values properly and removes the decimal places.
The range of this example is from 0 to 900, so you need to change those values depending on what your "maximum and minimum" values are going to be. You really divide 900 - [RasterToBeScaled] by the range (max - min raster values). Since my range was 0 to 900 I skipped this and put 900.
If you need this to increase then you have to change some of it around.
INT((Con([RasterToBeScaled] <> 900, 255,( (([RasterToBeScaled] - 0) * 255) / 900) + 0))) + .5)
Now, whatever is less than zero is zero and greater than 900 is 255. Everything in between is calculated using the formula:
( (([RasterToBeScaled] - 0) * 255) / 900) + 0))
So now we subtract the cell value by the lowest value in your range and everything else is the same.
This is similar, but not quite what I was looking for.
Hope that helps...
Labels:
ArcGIS,
camel,
Fuzzy,
IDRISI,
monotonically,
Pairwise,
Spatial Analyst
Wednesday, June 4, 2008
Python QuickTip
I'm not much of a Python user. I don't care for the syntax (probably because I don't use it enough). It took me forever to find where I could read the input list from a toolbox in ArcGIS...i.e. a multivalue parameter.
Here is the help file that I found. Look under the Using a multivalue input in a script section.
Another problem I have with Python mostly comes from ArcGIS, which is the only time I ever use Python. Well, most of programming revolves around Spatial Software in some way. Everytime I try and do something with the geoprocessing scripts, I seem to run into a bug. I wrote a script once that exported coverages from all the featureclasses in a workspace. This script stopped to function from the toolbox with service pack 3 (9.2). I think this is working again with service pack 4. Also, apparently the reset method on a lot of the cursors do not work, so forget about reusing a cursor. Seems like every time I need to write a little geoprocessing script I need to try and figure out a workaround because I find another problem. Granted though, I've had some success too.
On a completely different note:
I was also updating my Antivirus and saw that one way to help them was add a link to their site. I use the ClamWin open source antivirus program. I've probably used it for maybe a year, and have been happy with it. It isn't the beast of a software that Norton is. I can only vouch for it on a personal computer, so I don't know how it would work at an "enterprise" level. I haven't had any viruses, but then again, I didn't have any before I installed it either...knock on cyber wood.
Here is the help file that I found. Look under the Using a multivalue input in a script section.
Another problem I have with Python mostly comes from ArcGIS, which is the only time I ever use Python. Well, most of programming revolves around Spatial Software in some way. Everytime I try and do something with the geoprocessing scripts, I seem to run into a bug. I wrote a script once that exported coverages from all the featureclasses in a workspace. This script stopped to function from the toolbox with service pack 3 (9.2). I think this is working again with service pack 4. Also, apparently the reset method on a lot of the cursors do not work, so forget about reusing a cursor. Seems like every time I need to write a little geoprocessing script I need to try and figure out a workaround because I find another problem. Granted though, I've had some success too.
On a completely different note:
I was also updating my Antivirus and saw that one way to help them was add a link to their site. I use the ClamWin open source antivirus program. I've probably used it for maybe a year, and have been happy with it. It isn't the beast of a software that Norton is. I can only vouch for it on a personal computer, so I don't know how it would work at an "enterprise" level. I haven't had any viruses, but then again, I didn't have any before I installed it either...knock on cyber wood.
Labels:
ArcGIS,
Clamwin,
Multivalue,
Python,
Quick Tip
Tuesday, June 3, 2008
PDF and ESRI
This has been blogged by several people already (Spatially Adjusted and Fantom Planet to name a few). It sounds like it will be pretty cool in theory. A spatial pdf direct from ArcGIS 9.3. Maybe now I'll stop getting those stupid GeoPDF spam mails.
Sunday, June 1, 2008
Programming Tutorials Update
I've managed to do 7 lessons so far, and am working on the 8th. I used to be pretty good at taking ideas and writing it in plain English, but I realized that the more you learn about a topic the harder it becomes not to use the custom terminology. I'm trying to do my best to keep the lessons in plain English. We'll see how that goes.
I hope to do a lesson every couple of days. Starting with lesson 8, there will probably be a total of 2 or 3 lessons that build a little project.
Hope you enjoy.
I hope to do a lesson every couple of days. Starting with lesson 8, there will probably be a total of 2 or 3 lessons that build a little project.
Hope you enjoy.
Labels:
ArcGIS,
ArcObjects,
ArcObjects Tutorial,
GIS Programming,
Programming
Wednesday, May 28, 2008
Programming Tutorials
I am creating a series of lessons to teach GIS Programming in an ArcGIS Environment.
Please visit the site here.
Please post your comments about the lessons at this post.
Hope you enjoy.
http://www.boxshapedworld.com/tutorials/ArcGIS%20Programming%20TOC.ashx
Please visit the site here.
Please post your comments about the lessons at this post.
Hope you enjoy.
http://www.boxshapedworld.com/tutorials/ArcGIS%20Programming%20TOC.ashx
Labels:
ArcGIS,
ArcObjects,
ArcObjects Tutorial,
Tutorial,
VBA
Subscribe to:
Posts (Atom)
