I'm using this library to finish my final project and I have to say I'm no familiar with the maps worlds. My question is if geotools has a method to show automatically the coordinates references in the map, and how use it? That would be really helpful because I spend a lot of time trying to find it without success. I use the quickstart example to show a shapefile with the worlds map. The user can select a rectangular zone of interes and then the application draw the Sea Surface Temperature. The map generated needs the references of where are positioned because we export it to a png image.

One example of what I am looking for are the blue lines in the map below.

enter image description here

  • The blue lines on your map are often referred to as graticules. – PolyGeo Jun 28 '14 at 23:46
  • I am in the same boat - trying to get my map displayed with ortholines with latitude and longitude values labelled. I followed the example at GeoTools' User Guide how to generate Line Grids. My solution so far, using GeoTools 10.7: (sorry, this is extract from my code so missing some definitions outside the scope) ReferencedEnvelope currentBounds = getCurrentExtent(); ReferencedEnvelope gridBounds = new ReferencedEnvelope( currentBounds.getMinX(), currentBounds.getMaxX(), currentBoun – user35351 Aug 3 '14 at 22:26
  • It looks like you are trying to ask three questions within this answer so I recommend taking the Tour for a very quick intro to how this site works. – PolyGeo Aug 4 '14 at 0:32

You can draw these using the vector-grids module and some code like:

 ReferencedEnvelope gridBounds = new ReferencedEnvelope(
        110.0, 150.0, -45.0, -5.0, DefaultGeographicCRS.WGS84);

SimpleFeatureSource grid = Grids.createSquareGrid(gridBounds, 10.0);

There are a variety of grids and options available depending on your exact needs which are described in the tutorial.

  • That's great! Sorry for the delay, but is really important the latitudes and longitudes references in the map. Maybe I have to add the labels manually. – nifer Jul 12 '14 at 16:23
  • I don't understand your issue. You can set the grid to match your map any way you want. – Ian Turton Jul 13 '14 at 8:11
  • 1
    Sorry @iant! I'm not a great english speaker. However my issue is that is really important the longitudes and latitudes coordinates in the lines. Not only the grid is required, the numbers is also required. Because it will be the references for the users. – nifer Jul 14 '14 at 13:40
  • then you will need to add a textsymbolizer to the style you have applied to the lines. That's the same as labeling any other feature. – Ian Turton Jul 15 '14 at 7:11
  • 1
    Is there any example of how to use that? Because I tryed with the examples from link but that examples ends in the creation of the style, I need to know how to create a line and add the style I created. – nifer Aug 2 '14 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.