Hello,
From a polygon layer, I try to create an In Memory Layer with Points corresponding to the centroid (GetCenterPoint) of the polygons.
The goal is to set a style on these points.
Is it possible ? and do you have a sample ?
Thank you
Hello,
From a polygon layer, I try to create an In Memory Layer with Points corresponding to the centroid (GetCenterPoint) of the polygons.
The goal is to set a style on these points.
Is it possible ? and do you have a sample ?
Thank you
Hello Eric,
Thank you for your post.
Please try the code below:
InMemoryFeatureLayer l = new InMemoryFeatureLayer();
l.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
Any more questions please feel free to let me know.
Regards,
Gary
Thank you Gary,
l.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
has no effect if there is no point record in the layer.
My question is how to translate a polygons layer (USStates.shp) to an InMemory points layer (points created with the GetCenterPoint method applies on each polygon).
Regards
Hello Eric,
Sorry it’s my fault I didn’t get the point.
Let me guess your polygons is in a shapefilefeaturelayer. First you can get the features which fit your centroid logic from the featurelayer, then use
inMemoryFeatureLayer .InternalFeatures.Add() method to add them in the InMemoryFeatureLayer.
After this, you can use the code I post before to control the style.
Regards,
Gary
Thank you Gary,
InMemoryLayer.InternalFeatures.Add(polygon.GetBoundingBox.GetCenterPoint.GetFeature)
Regards
Eric,
Glad it helped, any more questions just let us know.
Regards,
Gary
Please Gary, an additional question ...
Is there a style to draw a dot whose size is proportional to a value (not a ClassBreak with PointStyle, which drawed point size by range) ?
Thank you
Hello Eric,
Sorry we don’t have that style, if you want to use a style like this to control the InMemoryLayer, you need custom a PointStyle.
Regards,
Gary
Eric,
I just saw Gary’s response and I think there are several ways to accomplish what you want to do.
If you want to draw different sizes of PointSizes for your InMemoryLayer you can use either the ValueStyle, ClassBreakStyle or RegExStyle. Each of these will allow you to draw a different type of point symbol for each point based upon a column value in your InMemoryLayer.
I’m sure the next question is how to add the Column Value to the InmemoryLayer so the style can use it. To do this is pretty easy, fist you need to define the column at the InMemoryLayer level. The code to do this would look like:
InMemoryFeatureLayer myLayer = new InMemoryFeatureLayer();
myLayer.Columns.Add(new FeatureSourceColumn(“Size”));
Then before to add your features to the InMemoryLayer you will want to set the Value column with the value you want to key off of for the Value Style or Class Break Style. The code to do this would look like:
Feature pointFeature = polygon.GetBoundingBox.GetCenterPoint.GetFeature();
pointFeature.ColumnValues.Add(“Size”, YOURVALUE);
myLayer.InternalFeatures.Add(pointFeature);
Please let us know if you have any additional questions.
Thanks!
Ok, thank you for your answers,
Sorry Clint, but I think Gary has the right answer to my question ("how to draw a circle PointStyle whose size is proportional to a value, a different size for each value")
ValueStyle -> the same size of symbol for all points of the layer
ClassBreakStyle -> the same size of symbol for all points of a range of values (break)
RegExStyle -> is not related to the size of symbol to draw
Is that correct ?
Eric,
About these 3 styles, you understood them correctly and I would like to explain them more clear for you:
ValueStyle : This class allows you to match a value with data in the feature to determine how to draw that feature.
ClassBreakStyle : This class represents a style based on class break values(A range of values).
RegExStyle : This class allows you to draw features differently based on regular expression matching.
We have samples for them, they are DrawAFeatureBasedOnAValue, DrawThematicFeatures and DrawFeaturesBasedRegularExpression.
Thanks,
Scott,
Eric,
I think that the sample Sized Point Style wiki.thinkgeo.com/wiki/Map_Suite_De...oint_Style addresses your need. It presents a custom Point Style whose size is proportional to a value from some column. In the example, we are using world capital with the point style being proportional to the population. Please, look at this sample and I think you can adapt it to your situation.
Thank you Scott and Val for your help.
You're right Val Sized Point Style is what I want.
But I work with VS2005 and the following syntax does not work ...
pointStyle.Draw(new Collection<Feature>() { feature }, canvas, labelsInThisLayer, labelsInAllLayers);
Do you know how to translate this syntax in VS2005?
Thanks.
Eric,
Well, we haven't used VS 2005 in a few years. Actually we are using VS 2010 now. If I were you, I would use one of the downgrade utilities from 2008 to 2005 that you can find on the web. I did some search on the web and there are a few that you can download. For examples:
mises.org/Community/blogs/misestech...ility.aspx
community.devexpress.com/forums/t/62970.aspx
I am not sure how good there are. I haven't tried them myself but they are one of the solutions you can find on the web for converting project from VS 2008 to VS 2005.
Thank you.
Thank you Val,
Collection<Feature> myFeatureCollection = new Collection<Feature>();
myFeatureCollection.Add(feature);
pointStyle.Draw(myFeatureCollection, canvas, labelsInThisLayer, labelsInAllLayers);
Regards.
You are welcome.