From: Greg E. <gr...@er...> - 2009-01-15 08:01:14
|
Thanks! On Jan 14, 2009, at 5:17 PM, Ajay Ravichandran wrote: > Hey Greg > > Usually CRS is null for a shapefile read through shapefiledatastore > if it doesn't have a corresponding .prj file > > You may not need to use an AuthorityFactory in that case if u can > provide a prj file > > Regards > > Ajay ravichandran > > On Jan 14, 2009, at 2:48 PM, Greg Ederer <gr...@er...> wrote: > >> Hi, >> >> I found the answer to my own question: >> >> CRSAuthorityFactory factory = >> ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", null); >> CoordinateReferenceSystem crs = >> factory.createCoordinateReferenceSystem("4326"); >> >> Thanks! >> >> Greg >> >> On Jan 14, 2009, at 12:40 PM, Greg Ederer wrote: >> >>> Hi, >>> >>> I am reading a shapefile using the following code from the User >>> Guide: >>> >>> File file = new File("/Users/gregederer/servers/geoserver_data/data/ >>> shapefiles/gaul/Africa/g2008_1.shp");//getShapeFile(args); >>> >>> ShapefileDataStore shapefile = new >>> ShapefileDataStore(file.toURL()); >>> String typeName = shapefile.getTypeNames()[0]; >>> FeatureSource featureSource = shapefile.getFeatureSource(); >>> FeatureType schema = featureSource.getSchema(); >>> CoordinateReferenceSystem crs = >>> schema.getGeometryDescriptor().getCoordinateReferenceSystem(); >>> >>> MapContext map = new DefaultMapContext(crs); >>> Style style = createStyle(file, schema); >>> map.addLayer(featureSource, style); >>> >>> showMap(map); >>> >>> in showMap(): >>> >>> final JMapPane mapPane = new JMapPane(new StreamingRenderer(), >>> map); >>> mapPane.setMapArea(map.getLayerBounds()); >>> >>> When I run this code against my shapefile, I get: >>> >>> Exception in thread "main" java.io.IOException: CRS of this map >>> context is null. Unable to get bounds. >>> at >>> org >>> .geotools >>> .map.DefaultMapContext.getLayerBounds(DefaultMapContext.java: >>> 544) >>> at org.esv.SummaryStats.ShapeLab.showMap(ShapeLab.java:187) >>> at org.esv.SummaryStats.ShapeLab.main(ShapeLab.java:75) >>> >>> Is it possible that this shapefile has no CRS? If so, is there a >>> factory method that I can use to get the required >>> CoordinateReferenceSystem reference? I happen to know that this >>> particular shapefile is in ESPG:4326. What other parameters will I >>> need? >>> >>> Thanks! >>> >>> Greg >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by: >>> SourcForge Community >>> SourceForge wants to tell your story. >>> http://p.sf.net/sfu/sf-spreadtheword >>> _______________________________________________ >>> Geotools-gt2-users mailing list >>> Geo...@li... >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by: >> SourcForge Community >> SourceForge wants to tell your story. >> http://p.sf.net/sfu/sf-spreadtheword >> _______________________________________________ >> Geotools-gt2-users mailing list >> Geo...@li... >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users |