Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a Shapefile with road data. Sometimes the roads are blue, sometimes they are green. I didn't used to mind, but now I'm tiling everything so I need to control the colors.

I'm loading it with this command in ArcEngine:

mapControl.AddShapeFile(fileDir, fileName);

How can I control the colors so they are the same everytime?

I'm using ArcEngine 10 C# with VS2010

share|improve this question

2 Answers 2

up vote 16 down vote accepted

Shapefiles don't have any sort of symbology attached.

Since you're working with ESRI tools, why not wrap them in a layer package? Here's how.

From the link: "When users add a layer file to their maps, it will draw exactly as it was saved as long as they can get access to the data referenced by the layer."

Just be careful to use relative paths, and keep them the same. (The .lyr augments the shapefile; it doesn't replace it.)

Edit to add: you'll also be using the AddLayerFromFile method, rather than AddShapeFile.

share|improve this answer

There is another way, if you set up a new Style File and save to the location of your shapefile with the symbology you want to use, the shapefile will automatically render the features in the same way as the style. This is a hangover from ArcView 3 which is still there at 10 but not sure how much longer.

Have Fun, CDB

share|improve this answer
    
this is the first I've head of this, sounds interesting. Can you provide more info? For example do the style files need to have the same filename as the shapefile they refer too? and do you use the Style Manager to build them or something else? –  matt wilkie Dec 11 '10 at 6:39
    
Yes they do and need to be stored in the same location, They only work when symbolising all features initally so I have used this as a method. Open Style Manager and create a new style in the data location called the same as the shapefile, then create a symbol called the shapefile name. lastly add the shapefile to ArcMap and the symbol you selected will automatically be rendered. Have Fun, CDB –  CDBrown Dec 12 '10 at 23:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.