Evening Kakpo - as you can see sending me email directly is not a very quick
way for a response. In the future I recommend email the geotools user list as
there are many people who can help answer your questions.
There are a number of ways to access an attribute:
1) directly
String name = (String) feature.getAttribute( "name" )
Downside is that you need to access the features one at a time.
2) You can also accomplish the same thing with an expression
Expression expr = ff.property("name");
String name = expr.evaualte( feature, String.class );
This is handy as you can ask the expression to "pull back" the kind of value
you are looking for (no casting! and it is able to perform simple conversions).
3) You mentioned categorise - there are a number of functions that can do this
in one go … when evaualted on an entire feature collection. And a utility class
that can generate a "rule based" style based on one of these categorisations.
For details:
http://docs.geotools.org/latest/userguide/extension/brewer/index.html
--
Jody Garnett
On Thursday, 8 March 2012 at 5:52 AM, Kakpo Adoko wrote:
> Dear Jody,
>
> I followed the styling examples in the Tutorial and they work perfectly.
>
> However, I have not been able to access the polygons attributes in the
> shapefile to categorise them. Help HTML files pointed to so many ways to do
> this and I got confused!
>
> Do you have a small example that you could send me so that I can see how it
> works?
>
> Super thanks.
>
> Kakpo
>
> PS: I am from Delft University in The Netherlands and am producing this map
> for my research study. Thanks for your help.
>
>
>
>
> Subject: Re: Polygon rendering in Geotools
> From: [email protected] (mailto:[email protected])
> Date: Wed, 7 Mar 2012 08:12:16 +1000
> To: [email protected] (mailto:[email protected])
>
> Using a style with the color defined by an expression using your code
> attribute and the categorize function.
>
> Or using five rules with a different colour for each. Each rule using a
> between function to select content.
>
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users