[Geotools-gt2-users] SLD with GRIDCoverage
Dear all, We are building a GIS for scientific simulation based on geotools. Look at : http://geosysin.iict.ch/irstv-trac/wiki/OrbisGIS/Screenshots We try to use a SLD file to style a gridcoverage but without any sucess. I use the code below but the gridcoverage color is still unchanged. Any ideas ? Best regards public static GridCoverage loadRasterStyleFromXml(GridCoverage gc, String url ) throws FileNotFoundException { StyleFactory factory = StyleFactoryFinder.createStyleFactory(); SLDParser parser = new SLDParser(factory, url); StyledLayerDescriptor sld = parser.parseSLD(); NamedLayer layerOne = (NamedLayer)sld.getStyledLayers()[0]; RasterSymbolizer symbolizer = (RasterSymbolizer)layerOne.getStyles()[0].getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0]; RasterSymbolizerSupport rsp = new RasterSymbolizerSupport(symbolizer); GridCoverage2D recoloredGridCoverage = (GridCoverage2D) rsp.recolorCoverage(gc); recoloredGridCoverage.show(); return recoloredGridCoverage; } -- Ingénieur de recherche Docteur en géographie École Centrale de Nantes Institut de recherche en sciences et techniques de la ville http://www.irstv.cnrs.fr/ http://geosysin.iict.ch/irstv-trac/wiki http://r1.bocher.free.fr http://www.projet-sigle.org - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] What to use instead of Filter?
On 5/22/07, Ian Turton [EMAIL PROTECTED] wrote: On 5/10/07, Justin Deoliveira [EMAIL PROTECTED] wrote: Hi Ian, Were you creating the geoapi filters using the FilterFactory? I believe you are correct in that that interface has a dependency on geoapi geometry. However the FilterFactory2 interface is an extension which allows you to create filters without geoapi geometries. I realize that isn;t exactly intuitive. We should really clean that up before our 2.4 release... OK I found some time to go back to geotools today and try this. As you say it lacks intuitiveness and documentation, so I'm guessing I do something like Filter f = ff.contains(ff.literal(geomName),ff.literal(geometry)); where ff is a FilterFactory2. OK after some further thinking and more caffeine I now see that should be Filter f = ff.contains(ff.property(geomName),ff.literal(geometry)); So JMapPane on trunk now works using the latest undeprecated filters. Ian -- Ian Turton http://www.geotools.org http://pennspace.blogspot.com/ - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Filter.INCLUDE in the SubFeatureList's constructor
I think you have found a mistake! I think a programmer (maybe me) got carried away with code reuse and confused things. You are correct that a SubFeatureCollection with Feature.INCLUDE should be the same as the one that came before. You are on the right way to create a FeatureList ... the code is just letting you down. FeatureCollection.sort is supposed to be implemented (and the resulting FeatureList is very fast for the database based collections). Let me check DefaultFeatureCollection now. Cheers, Jody Hi, I have a FeatureCollection, from wich I'd like to create a FeatureList. I try to do it by creating a SubFeatureList, providing Filter.INCLUDE as Filter, and Sort.NATURAL_ORDER as SortBy. My problem is, that SubFeatureList's constructor delegates to SubFeatureCollection's constructor, which throws exception if the filter parameter is FIlter.INCLUDE. It says that A subcollection with Filter.INCLUDE should be a FeatureCollectionEmpty. My question is, what does this mean? (What is a FeatureCollectionEmpty?) On the other hand, if I comment out the check for Filter.INCLUDE in SubFeatureCollection, the SubFilterList works as I expected. So is that check important for SubFeatureCollection? (I guess that a SubFeatureCollection with Feature.INCLUDE would be the same as the collection it is based on. Am I right?) Or am I on the wrong way to create a FeatureList? The javadoc header of the FeatureList interface tells a way of getting an instance of it, but it seems wrong to me, and the implementation of FeatureCollection.sort(.) is missing from the provided DefaultFeatureCollection. Thank you, Peter - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] SLD with GRIDCoverage
I have not seen the recolorCoverage method before :-) I would of expected the GridCoverageRenderer to make use of the SLD file only at render time. For the longest time only the Opacity value was used for the RasterSymbolizer .. Have you tried stepping through it with a debugger? Jody Dear all, We are building a GIS for scientific simulation based on geotools. Look at : http://geosysin.iict.ch/irstv-trac/wiki/OrbisGIS/Screenshots We try to use a SLD file to style a gridcoverage but without any sucess. I use the code below but the gridcoverage color is still unchanged. Any ideas ? Best regards public static GridCoverage loadRasterStyleFromXml(GridCoverage gc, String url ) throws FileNotFoundException { StyleFactory factory = StyleFactoryFinder.createStyleFactory(); SLDParser parser = new SLDParser(factory, url); StyledLayerDescriptor sld = parser.parseSLD(); NamedLayer layerOne = (NamedLayer)sld.getStyledLayers()[0]; RasterSymbolizer symbolizer = (RasterSymbolizer)layerOne.getStyles()[0].getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0]; RasterSymbolizerSupport rsp = new RasterSymbolizerSupport(symbolizer); GridCoverage2D recoloredGridCoverage = (GridCoverage2D) rsp.recolorCoverage(gc); recoloredGridCoverage.show(); return recoloredGridCoverage; } - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Feature type name
I think you are correct - there was some support for shapefile.xml (some odd metadata format that nobody uses). That would the only hope I know of for storing the name. Unless you can tell me it can be stored in the Shapefile header somewhere? Jody Enam wrote: Upon reading the source of ShapefileDataStore it turns out that feature type name is not stored in the shapefile. So when we open the shapefile again, it guesses the type name as the name of file without the extension part. Am I correct here ? or am I missing sth ? Enam wrote: I'm seeing some issues with feature type names. Consider this code: IndexedShapefileDataStore sds = new IndexedShapefileDataStore(somfileurl); sds.createSchema(featureType); System.out.println(sds.getTypeNames().length); System.out.println(sds.getSchema(sds.getTypeNames()[0])); This outputs the actual typename supplied during schema creating. When I run it again without the createSchema statement, I see that the type name = shapefile name! IndexedShapefileDataStore sds = new IndexedShapefileDataStore(somfileurl); //sds.createSchema(featureType); System.out.println(sds.getTypeNames().length); System.out.println(sds.getSchema(sds.getTypeNames()[0])); - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Re: [Geotools-gt2-users] Producing image from shapefile and some attribute data that can be linked
Hi Andy There is a style maker in geotools - based on the color brewer project. It is one of the extensions - give it a shapefile and the attribute you want to use to color by and it will generate an Style. The code is used in uDig ... I am also interested in writing out a image ... I would like to export the current screen from uDig. You just mentioned that you had no luck ... are you getting empty images? A stack trace? ... anything? If you want you can fire up uDig in order to visualize as you work on a SLD document. It can make the initial colors for you and then you can hack on the xml file. You can then feed the sld file back to your code when you are happy ... does your code draw anything? Cheers, Jody Andy Turner wrote: Hi geotools-gt2-users, I have joined the club again after years of just lurking on the email list. I want to generate a load of static image files which are geographic maps that I can insert into web pages. Can you help? I am using GeoTools 2.3.1 (bin) and the javadocs. I can load the shapefile and iterate through the features and see the attribute on which I want to link. That is this bit: // Read Boundary data using ShapefileDataStore URL _URL = new URL( file:///C:/temp/test.shp ); //boolean readDBF = true; ShapefileDataStoreFactory _ShapefileDataStoreFactory = new ShapefileDataStoreFactory(); ShapefileDataStore _ShapefileDataStore = ( ShapefileDataStore ) _ShapefileDataStoreFactory.createDataStore( _URL ); //ShapefileDataStore _ShapefileDataStore = new ShapefileDataStore( _URL ); FeatureType _FeatureType = _ShapefileDataStore.getSchema(); AttributeType[] _AttributeTypes = _FeatureType.getAttributeTypes(); for ( int i = 0; i _AttributeTypes.length; i ++ ) { System.out.println( _AttributeTypes[ i ].getName() ); } FeatureSource _FeatureSource = _ShapefileDataStore.getFeatureSource(); FeatureCollection _FeatureCollection = _FeatureSource.getFeatures(); FeatureIterator _FeatureIterator = _FeatureCollection.features(); //Feature _Feature; //while ( _FeatureIterator.hasNext() ) { //_Feature = _FeatureIterator.next(); //System.out.println( _Feature.toString() ); //} Next I wanted to create an image of the polygons in the shapefile. This is where I got stuck. Here is what I currently have: // Create image using _ShapefileRenderer ShapefileRenderer _ShapefileRenderer = new ShapefileRenderer(); // Set _MapContext //CoordinateReferenceSystem _CoordinateReferenceSystem = new CoordinateReferenceSystem(); //DefaultMapContext context = new DefaultMapContext( _CoordinateReferenceSystem ); DefaultMapContext _MapContext = new DefaultMapContext(); // Set some extra information to the map _MapContext.setTitle( _Title ); _MapContext.setContactInformation( _ContactInformation ); _MapContext.setAbstract( _Abstract ); _ShapefileRenderer.setContext( _MapContext ); // Create _Style StyleFactoryImpl _StyleFactoryImpl = new StyleFactoryImpl(); PolygonSymbolizer _PolygonSymbolizer = _StyleFactoryImpl.createPolygonSymbolizer(); //Fill _Fill = new Fill(); //Expression _Expression = new Expression(); //_Fill.setColor( _Expression ); //_PolygonSymbolizer.setFill( _Fill ); Rule _Rule = _StyleFactoryImpl.createRule(); _Rule.setSymbolizers( new Symbolizer[] { _PolygonSymbolizer } ); Style _Style = _StyleFactoryImpl.createStyle(); _Style.setName( Style ); _Style.addFeatureTypeStyle( _StyleFactoryImpl.createFeatureTypeStyle( new Rule[] { _Rule } ) ); // Create _MapLayer from the _Style MapLayer _MapLayer = new DefaultMapLayer( _FeatureCollection, _Style, _MapLayer1); // Create _BufferedImage BufferedImage _BufferedImage = new BufferedImage( _Chart_Width, _Chart_Height, BufferedImage.TYPE_INT_RGB ); Graphics _Graphics = _BufferedImage.getGraphics(); _Graphics.setColor( Color.white ); _Graphics.fillRect( 0, 0, _Chart_Width, _Chart_Height ); _ShapefileRenderer.paint( ( Graphics2D ) _Graphics , new Rectangle( 0, 0, _Chart_Width, _Chart_Height ), new AffineTransform() ); // Create image file String type = PNG; javax.imageio.ImageIO.write( _BufferedImage, type, new File( C:/temp/test + . + type ) ); I have tried quite a few things, but had no luck. Please advise? I am now working on linking the other attribute data that I have and trying to figure how to shade these in different colours. Linking the data I was going to do myself as I don't expect there to be anything in GT2 to help. Styling is going to be tricky unless I can figure how to see some
Re: [Geotools-gt2-users] [Maven] compilation error
Darn hopefully you have not found a mistake due to a developer using Java 5. Um ... your version of Java is actually rather old - do you mind trying the Java 1.4.2 as recommended in the developers guide? - http://docs.codehaus.org/display/GEOT/2.1+Language The versions of stuff we support are always on this page: - http://docs.codehaus.org/display/GEOT/2.2+Dependencies Cheers, Jody Hi, So, as a perfect newbie, I tried to build geotools gt2-2.4-M2 with maven on windows, and I had this build failure message (java version was 1.4.1_02) : [INFO] Compiling 95 source files to C:\ns\alpha\carto\geotools\gt2-2.4-M2\module s\library\main\target\test-classes [INFO] [ERROR] BUILD FAILURE [INFO] [INFO] Compilation failure C:\ns\alpha\carto\geotools\gt2-2.4-M2\modules\library\main\src\test\java\org\geo tools\filter\function\QuantileFunctionTest.java:[151,54] reference to evaluate is ambiguous, both method evaluate(org.geotools.feature.Feature) in org.geotools. filter.function.ClassificationFunction and method evaluate(java.lang.Object) in org.geotools.filter.function.QuantileFunction match C:\ns\alpha\carto\geotools\gt2-2.4-M2\modules\library\main\src\test\java\org\geo tools\filter\expression\AddImplTest.java:[23,35] reference to evaluate is ambiguous, both method evaluate(org.geotools.feature.Feature) in org.geotools.filter.D efaultExpression and method evaluate(java.lang.Object) in org.geotools.filter.ex pression.AddImpl match # Is this due to the java version I am using ? How should I fix this ? Thanks for your help - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Geotools-gt2-users mailing list Geotools-gt2-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users