From: Natarajan, S. <se...@pi...> - 2006-07-17 01:31:37
|
Hi, Now I generated a Map (jpeg Image) of just six point locations, I was wondering how to specify the Title for the Map, North Arrow, and Scale Bar etc... Please find the attached code. Thanks, Senthil -----Original Message----- From: Parks, Aaron B. [mailto:ap...@rt...]=20 Sent: Tuesday, July 11, 2006 4:23 PM To: geotools list; Natarajan, Senthil Subject: RE: [Geotools-devel] [Geotools-gt2-users] Generating Map for set ofLat/Long Points Once you actually get the map in an image buffer you can spit out almost any type of graphic using the JAI.=20 getMapPane() grabs my panel that has the buffer on it. Your imports: import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.awt.Graphics2D; Your code: try { int w =3D getMapPane().getWidth(), h =3D getMapPane().getHeight(); BufferedImage image =3D new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 =3D image.createGraphics(); getMapPane().paint(g2); g2.dispose(); ImageIO.write(image, "jpeg", new File("c:\\temp\\test.jpeg")); } catch (Exception f) { System.err.println(f); } AP -----Original Message----- From: geo...@li... [mailto:geo...@li...] On Behalf Of David Adler Sent: Tuesday, July 11, 2006 3:54 PM To: geotools list; Natarajan, Senthil Subject: Re: [Geotools-devel] [Geotools-gt2-users] Generating Map for set ofLat/Long Points There is an snippet at http://geotools.codehaus.org/LiteRendering which=20 shows rendering to an image buffer. I'm not sure if this helps if one wants to draw a nice map using the=20 various styles. At 03:27 PM 7/11/2006, Adrian Custer wrote: >On Tue, 2006-07-11 at 14:43 -0400, Natarajan, Senthil wrote: > > Hi Adrian, > > I ran your tutorial code, and I am getting these and working fine. I > > was wondering how to generate the map; I need to get some map Image=20 > > file. How can we do that? Thanks, > > Senthil > >Hey, > > Note that what you are trying to do is where i was two years ago > so it's reasonable. However, I'm still not able to answer your > question. Geotools is really powerful but it's been built by > people working from another end rather than from the user needs > side of things. So you want to do something really easy but it > turns out to be impossibly hard. Sorry, that's the breaks. > > Also can you lay out the whole process you want to go through. > helping you piecemeal like this is both stretching my knowledge > and confusing me. Are you going to want a map on screen or an > image or on paper? Do you want to match other data files? Is > this a one off effort or do you want to do it repeatedly? > > Finally, look at the uDig and the JUMP project / OpenJUMP. The > latter may be able to help you out of the box^W download. > >Short answer: > I don't know. > >Longer answer: > It will depend on what geotools you are using, because the > actual widget you use will vary. In 2.2 I think you are out of > luck. In 2.0 and 2.1 there are some widgets in the legacy module > you can play with. In the current development tree there's > apparently a widget working again. > > NOTA BENE! I'm not sure that even once you can *display* a map > on screen, you'll then be able to get out any kind of graphic. > You probably can, I just don't know how. > > I would suggest breaking your effort into three parts: > 1) Build a file (say shapefile) that has the data you > want > 2) find a way to display the file (easy with uDig) > 3) find a way to get an image (if that's what you want) > The first you can do with geotools by creating a feature and > then saving to a shapefile data store. it's a bit complex but > possible. The second is trivial with uDig. And the third, I > think with JUMP. Eventually, uDig will do them all---if I can do > anything about it. > >okay, hope that helps, back to working on the docs, >adrian > > >On Tue, 2006-07-11 at 14:43 -0400, Natarajan, Senthil wrote: > > Hi Adrian, > > I ran your tutorial code, and I am getting these and working fine. I > > was wondering how to generate the map; I need to get some map Image=20 > > file. How can we do that? Thanks, > > Senthil > > > > Start of the output for the tutorial: CreateAFeature. > > > > The polygon is: POLYGON ((7 7, 6 9, 6 11, 7 12, 9 11, 11 12, > > 13 11, 13 9, 11 7, 7 7)) > > Point feature type name is: pointfeature > > Point feature type is: DefaultFeatureType [name=3Dpointfeature = , > > namespace=3Dhttp://www.opengis.net/gml , abstract=3Dfalse , ty=20 > > pes=3D(DefaultAttributeType [name=3Dthe_geom , type=3Dclass=20 > > com.vividsolutions.jts.geom.Point , nillable=3Dtrue, min=3D1,=20 > > max=3D1],Default AttributeType [name=3DCITYNAME , type=3Dclass=20 > > java.lang.String , nillable=3Dtrue, min=3D1, = max=3D1],DefaultAttributeType > > [name=3DCITYPOP , type=3Dclass java.lang.Double , nillable=3Dtrue, = min=3D1, max=3D1],)] > > The point Feature is: Feature[ id=3Dfid-13dd332c:10c5ee1195a:-8000 , > > the_geom=3DPOINT (14 14) , CITYNAME=3DHometown , CITYPOP=3D 200000.0 = ] > > The line Feature is: Feature[ id=3Dfid-13dd332c:10c5ee1195a:-7fff , > > the_geom=3DLINESTRING (5 5, 6 5, 6 6, 7 6, 7 7, 8 7, 8 > > 8) , RIVERNAME=3DThe big fat greasy limpopo ] > > The linearRing Feature is: Feature[ id=3Dfid-13dd332c:10c5ee1195a:-7ffe , > > the_geom=3DLINEARRING (7 7, 6 9, 6 11, 7 12, 9 11, 11 1 > > 2, 13 11, 13 9, 11 7, 7 7) ] > > The polygon Feature is: Feature[ id=3Dfid-13dd332c:10c5ee1195a:-7ffd , > > the_geom=3DPOLYGON ((7 7, 6 9, 6 11, 7 12, 9 11, 11 12, > > 13 11, 13 9, 11 7, 7 7)) , MAXELEVATION=3D1654.0 , = ISLANDNAME=3DGreen > > Island ] > > > > End of the tutorial output. > > > > > > > > -----Original Message----- > > From: Adrian Custer [mailto:ac...@gm...] > > Sent: Tuesday, July 11, 2006 12:14 PM > > To: Natarajan, Senthil > > Cc: Geotools users list > > Subject: RE: [Geotools-gt2-users] Generating Map for set of Lat/Long > > Points > > > > Hey, > > > > You have the right idea. You use JTS classes to make the geometry=20 > > (through coordinates) and then the Geotools classes to make a CRS=20 > > and then you put them together to make a Feature. > > > > I'm working on the tutorials you will want but don't have them yet.=20 > > I'll attach three pieces I have. > > (1) mucks around with jts geometries > > (2) makes a feature *without* a CRS > > (3) makes a feature with a CRS > > you should be able to sort through and figure things out. If not,=20 > > you'll have to wait for my tutorials. > > > > cheers, > > adrian > > > > > > > > On Tue, 2006-07-11 at 11:50 -0400, Natarajan, Senthil wrote: > > > Hi Adrian, > > > Thanks for the info and I appreciate. > > > > > > Here is the more detail about the data. You are right those are=20 > > > UTM Projected points. > > > UTM Grid Zone: 10S > > > "UTM-X, m:" 560531 > > > "UTM-Y, m:" 4181786 > > > Datum: 1927 NAD > > > > > > What I want to do is, just to start with, I need to create a map=20 > > > for these points. X,Y > > > 566469,4181502 > > > 567309,4177908 > > > 567306,4178221 > > > 563567,4182488 > > > 563601,4182221 > > > 560531,4181786 > > > > > > I created a map manually using ArcGIS, by just opening the above > > points > > > saved in a .txt file. Please find the attached map file. > > > > > > I just want to do produce the same map programmatically by using=20 > > > some open source GIS API. Is it possible to do this by using JTS? > > > > > > Do I need to create some coordinate points like this........=20 > > > Coordinate ptc =3D new Coordinate(14.0d,14.0d); > > > > > > // Create an array and add the coordinates for a line > > > Coordinate[] lsc =3D new Coordinate[7]; > > > lsc[0] =3D new Coordinate(5.0d,5.0d); > > > lsc[1] =3D new Coordinate(6.0d,5.0d); > > > lsc[2] =3D new Coordinate(6.0d,6.0d); > > > lsc[3] =3D new Coordinate(7.0d,6.0d); > > > lsc[4] =3D new Coordinate(7.0d,7.0d); > > > lsc[5] =3D new Coordinate(8.0d,7.0d); > > > lsc[6] =3D new Coordinate(8.0d,8.0d); > > > > > > I am new to this, it will be great if you could point out some=20 > > > classes which does this (i.e) by taking the above UTM coordinate=20 > > > points and produce the map like the one I attached. > > > > > > Thanks, > > > Senthil > > > > > > > > > > > > > > > -----Original Message----- > > > From: Adrian Custer [mailto:ac...@gm...] > > > Sent: Monday, July 10, 2006 7:36 AM > > > To: Natarajan, Senthil > > > Cc: Geotools users list > > > Subject: Re: [Geotools-gt2-users] Generating Map for set of=20 > > > Lat/Long Points > > > > > > Hello, > > > > > > This is a great first question. I wish we had a tutorial just to > > answer > > > this question and I hope to build one eventually. For now you are > > going > > > to have to work your way through some things on your own. > > > > > > First, your question is actually incomplete. We could easily=20 > > > generate > > a > > > data set with a point at each of those coordinates, as I will=20 > > > explain below. However, if you then expect to match these=20 > > > coordinates to other geographic data, you have to have slightly=20 > > > more information, namely > > the > > > projection system you are using. Your data do not seem to be > > longitudes > > > and latitudes but some other projected data; you will therefore=20 > > > need > > to > > > find out what projection they are using. > > > > > > If all you want to do is create a file of geometric points at=20 > > > those coordinates, then you are essentially going to be using the=20 > > > JTS > > library > > > since this is what Geotools uses. You could look on the JTS web=20 > > > site > > or > > > you could read the current documentation prototype at:=20 > > > http://docs.codehaus.org/display/GEOTDOC/Programmers+Manual+Protot > > > ype > > > and checkout the tutorial file > > > > > http://docs.codehaus.org/download/attachments/50776/GnuGIS_Geotools_ > > Tuto > > > rial000010_Geometry010_Creation.java?version=3D1 > > > > > > Note these are both prototypes, in early stages, and so are less > > elegant > > > than they could be but they should get you started. However,=20 > > > because > > you > > > are not using any projection information, > > > THIS WILL NOT GIVE YOU POINTS THAT YOU CAN MATCH TO OTHER DATA.=20 > > > You have been warned. To do that you will need to build projection > > data > > > and use both your geometry and the projection info to build a=20 > > > geotools feature. I'm hoping to write a tutorial about this=20 > > > shortly. Look > > around > > > at the web site for more info. > > > > > > It would be nice to have a helper function in Geotools to do this > > simple > > > operation and perhaps we can add that eventually. > > > > > > Good luck, > > > > > > sincerely, > > > adrian custer > > > > > > > > > On Sun, 2006-07-09 at 19:13 -0400, Natarajan, Senthil wrote: > > > > Hi, > > > > > > > > I was wondering is it possible to generate a Map using GeoTools=20 > > > > API for a set of Lat/Long points. > > > > > > > > Basically I need to generate a Map for these Locations. > > > > > > > > X, Y > > > > > > > > 566469,4181502 > > > > > > > > 567309,4177908 > > > > > > > > 567306,4178221 > > > > > > > > 563567,4182488 > > > > > > > > 563601,4182221 > > > > > > > > 560531,4181786 > > > > > > > > > > > > > > > > If it is possible could you point out some example code how to=20 > > > > generate the Map. If it is not possible could you please suggest > > some > > > > open source Java API which does this. > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Senthil > > > > > > > > > > > > > > > > > -------------------------------------------------------------------- > > ---- > > > - > > > > Using Tomcat but need to do more? Need to support web services, > > > security? > > > > Get stuff done quickly with pre-integrated technology to make=20 > > > > your > > job > > > easier > > > > Download IBM WebSphere Application Server v.1.0.1 based on=20 > > > > Apache > > > Geronimo > > > > > > > > > = http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 12 > > 1642 > > > > _______________________________________________ > > > > Geotools-gt2-users mailing list=20 > > > > Geo...@li... > > > > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > > > > > >----------------------------------------------------------------------- >-- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 12164 2 >_______________________________________________ >Geotools-devel mailing list >Geo...@li... >https://lists.sourceforge.net/lists/listinfo/geotools-devel ------------------------------------------------------------------------ - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 121642 _______________________________________________ Geotools-devel mailing list Geo...@li... https://lists.sourceforge.net/lists/listinfo/geotools-devel |