Tag Info

Hot answers tagged

4

I suggest to use an oblique mercator projection as I explained in Using customized Coordinate System for Archaeological site data You have to define the origin in lon and lat WGS84 degrees, and the rotation against true north.


4

A couple of options: Convert the PostGIS layer to a shapefile in QGIS (save-as), then use the Vector|Conversion|Rasterize tool; Use the gdal_rasterize command directly. For the second option: gdal_rasterize -a VAL -ts [x] [y] PG:'host=localhost dbname=DB user=USER' -sql "SELECT the_geom, VAL FROM table" out.tif Where: VAL = the value to assign ...


3

You can use the GeodeticCalculator which should be faster. Something like: package com.envitia.spike; import org.geotools.geometry.DirectPosition2D; import org.geotools.referencing.CRS; import org.geotools.referencing.GeodeticCalculator; import org.opengis.referencing.FactoryException; import org.opengis.referencing.NoSuchAuthorityCodeException; import ...


3

In your code, you miss to define a feature type: In GeoTools (and not only), you will first need to define the structure of your data, ie the Feature type (~ schema). For this you have to use SimpleFeatureTypeBuilder that will help to build the feature type, afterwhat you will be able to construct properly the SimpleFeatureBuilder based on the featuretype ...


3

You mention Java in your question title but in your question body and tags it seems that ArcGIS for Desktop is available/preferred. The ArcGIS for Desktop procedure that I would use to do this is to perform the following three steps on one CSV file to make sure the workflow works, and then use Copy As Python Snippet to copy the syntax for the three tools ...


2

From the WFS 1.1.0 specification which is freely available in the net: Individual exception messages are contained within the element. The mandatory code attribute may be used to associate an exception code with the accompanying message. The optional locator attribute may be used to indicate where an exception was encountered in the request that ...


2

I finally figured it out... this code assumes that the geotif is in wgs84 (4326) proj, but it works well for getting the lat long for each pixel, and the band values for each pixel (formatted as a csv here). Hope this helps. import com.spatial4j.core.io.GeohashUtils; import java.awt.geom.Rectangle2D; import org.geotools.coverage.grid.GridCoverage2D; import ...


2

Yes, use ST_GeometryN eg, select st_astext(st_geometryn(st_geomfromtext( 'MULTILINESTRING ((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))'),1)); yields LINESTRING(10 10,20 20,10 40). Note, the indexing is based off 1. You could also loop through each one and test for equality, using generate_series to create the indexes, eg, select ...


2

This seems to work for me - I'm using the Admin Boundaries from Natural Earth and a Blue Marble jpeg (with a hand cranked world file) and this code which gives me this image. Without seeing your actual datafiles my suspicion is that you have a tiff file with either no world file or a broken one instead of a geotiff. If that is the case then you should be ...


2

I'm not sure if there is a built in function that does that but you could make your own by testing if a small circle/square around your point intersects a street feature. It is likely that if you even super close to a road, numerical error would creep in and no amount of testing would say a point is EXACTLY ON a segment. (unless it was a vertex point)


1

1) the map should handle the reprojection for you. See the QuickStart for an example. 2) you ask the map for it's maxBounds not current bounds, and you might want to clip by the CRS's DomainOfValidity to avoid unpleasant weirdness. 3) I'm not sure how you are generating your graticles but if you use the grids module you can densify the lines to make them ...


1

Something like: Coordinate[] coords = geometry.getCoordinates(); StringBuilder out = new StringBuilder(); out.append("coordinates="); boolean start = true; for(Coordinate c: coords) { if(!start){ out.append(","); }else{ start=false; } out.append(c.x+","+c.y); }


1

Fixed it. typeBuilder.add("geom", Point.class); should be: typeBuilder.add("the_geom", Point.class); Not sure why it worked before then. Either I don't remember changing that line (not sure why I would though), or perhaps some earlier version of GeoTools just "geom" worked. Looks like I may have picked it up from part of the javadoc that did not get ...


1

I guess you added in your classpath gt-epsg-postgres instead of gt-epsg-hsql? Delete gt-epsg-postgresql-11.0.jar from your classpath and add gt-epsg-hsql-11.0.jar into it. EDIT(Inspired by comments): For making the answer more understandable for others: GeoTools was set to store the EPSG projection database into PostgreSQL database. The default is to use a ...


1

SimpleFeatures are used for Vector data, for images you will need a coverage reader. See the image tutorial for a good introduction.


1

If you want to use Java, you have a few libraries available including GeoTools and the Java bindings for GDAL/OGR API. Using these you can code a solution (check out the documentation). However, far simpler would be to install GDAL which comes with pre-compiled utilities and use ogr2ogr. You can wrap that in a batch process as required.


1

You can certainly use GeoTools for this, you will also probably want to look at a relsted project JAITools which does helpful things with rasters. I wrote some code a while back to rasterize circles on to a Grid and output them as GeoTiffs which should point you in the right direction.


1

There are several issues here: OSM uses web mercator (epsg:3857) so that is where your reprojection is going on. Also you need to consider scale - the Natural Earth data is designed to be viewed and used at near to 1:10Million - at that scale your map looks like this and the dot is in the right place. Finally your code can be improved by using a ...


1

Mark's answer is great! It really helped me out. Here's a slightly modified version of Mark's code. The major difference is that this code does not rely on the java.awt.image package to compute the image size, number of bands, or pixel values. Instead, it uses the GeoTools Coverage API. import org.geotools.coverage.grid.io.GridCoverage2DReader; import ...


1

I now found the solution. I decided to create a new layer to render the images. The (example) code will be like this: List<SimpleFeature> list = new ArrayList<SimpleFeature>(); SimpleFeature feature = build.buildFeature("fid1", new Object[]{ geom.point(707009.4375,243649.18750000006), "TestImage" } ); list.add( feature ); ...


1

JTS polygons are clockwise (see http://tsusiatsoftware.net/jts/jts-faq/jts-faq.html#B6 for an explanation of why). Why it would give you an invalid geometry is a difficult question to answer with out seeing your input polygons. Most likely causes are self intersection, self touching, invalid geometry in input list.


1

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 ...


1

Yes, dealing with distance (or area) in unprojected latitude/longitude coordinates is fraught with peril. The length of a degree of latitude is always the same (60 nautical miles), but the length of a degree of longitude varies with the cosine of the latitude. To do it properly, you want to project your coordinates into some plane coordinate system and do ...


1

If all you want is a picture of the data then you can simply create an image and pass it's graphic object to the renderer in the same way as you would draw to the screen. However if you want a raster representation of the vector map then you should look at the VectorToRaster process.


1

Please try to use Maven when using GeoTools - to be honest trying to build any medium sized Java project without is going to be much harder work than you really want. But if you must plead ignorance then at least install it and learn to use mvn dependency:list which for the Shapefile module in GeoTools gives the following dependencies (on trunk so ...


1

You could try the Rasterize tool in QGIS (Raster - Conversion)


1

Did you consider using GDAL? Extensive information, Documentation and examples are available on the Geographical Data Abstraction Library. You can get step-by-step help to compile the GDAL.jar library as described here gdal.ReprojectImage(src_ds, dst_ds) from from GDAL Class seems to be what you are looking for though I have never used it yet.


1

General conceptual answer: One suggestion might be to use a national state projection polygon layer to determine the "only" or a selection of the best local projections. The other option would be UTM zones. But essential run a point in polygon test to return the crs. You don't mention but I am reading into you savvy question that you know you would need to ...


1

In the past I wrote some code to do this that looks like this: public JaiToolsCircle(ReferencedEnvelope env, double cellSize) { this.env = env; this.cellsize = cellSize; System.out.println("cellsize " + cellsize); height = (int) Math.ceil((env.getHeight() / cellsize))+1; width = (int) Math.ceil((env.getWidth() / ...


1

This seems to be a favourite question on Natural Earths forum ;-) A basic introduction is posted here: http://www.naturalearthdata.com/forums/topic/thematic-codes/ http://www.naturalearthdata.com/forums/topic/are-the-attributes-documented/ http://www.naturalearthdata.com/forums/topic/what-does-mapcolor-mean-in-ne_10m_admin_0_countries/ The mapcolor ...



Only top voted, non community-wiki answers of a minimum length are eligible