Hot answers tagged

8

"EPSG:3488, EPSG:NAD83(NSRS2007) / California Albers" is an equal-area projection. It is based on the Albers Conic, which is defined for the northern hemisphere. Because Sweden is within its range of definition, it is equal-area in Sweden. This means that (up to floating point rounding error) it will give absolutely correct areas. Neither the Mollweide ...


7

A Coordinate Reference System contains two different elements The datum: It defines how the CRS is related to the earth (position of the origin, the scale and the orientation of coordinate axis) e.g. ED50, ETRS89. The datum can be a geodetic datum, a vertical datum or a engineering / local datum. The coordinate system: describes how the coordinates ...


6

CoordinateReferenceSystem is the base Interface from which all other GeoTools SRS are derived from - it is the base class of Geocentric and Geographic projections (and others with vertical and temporal coordinates). It comes from the ISO19111 specification by way of the OGC GeoAPI project. CoordinateSystem is also an interface that comes from ISO19111 and ...


5

You can start with geotools tutorials, which is helpful for beginners. It provides an introduction to GIS workshop making use of examples from GeoTools and other Java libraries.


4

Have a look at the code referenced in my blog post which shows how to do exactly this, including styling the layer. Here is the actual code: private void exportSVG(File file) { Dimension canvasSize = new Dimension(frame.getMapPane().getSize()); Document document = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder ...


4

The main difference is that a bounding box is 2 dimensional while an envelope has 2 or more dimensions.


4

It appears you were/are on the right track as the 'Z' is used for a timezone indicator, here is the source I found that best answers your question "Z" is kind of a unique case for DateTimes. The literal "Z" is actually part of the ISO 8601 datetime standard for UTC times. When "Z" (Zulu) is tacked on the end of a time, it indicates that that time is UTC, ...


3

Ok, I've figured it out. It is possible to apply an affine transform onto some existing CRS using FITTED_CS. Below is an example of rotation of 60 degrees counterclockwise and movement: FITTED_CS["BPAF", PARAM_MT["Affine", PARAMETER["num_row", 3], PARAMETER["num_col", 3], PARAMETER["elt_0_0", -0.5], PARAMETER["elt_0_1", -0....


3

DataStore dataStore = ....; // ShapefileDataStore String t = dataStore.getTypeNames()[0]; SimpleFeatureSource featureSource = dataStore.getFeatureSource(t); SimpleFeatureType schema = featureSource.getSchema(); String geomType = schema.getGeometryDescriptor().getType().getBinding().getName(); System.out.println(geomType); It will out one of the following: ...


3

You need to close the polygon by adding the start point to the end of the list of points that you build the WKT with. So change it to: for (var z = 0; z < arreglo.length; z++) { arreglo2.push(arreglo[z][0]+" "+arreglo[z][1]); } arreglo2.push(arreglo[0][0]+" "+arreglo[0][1]); But I'm pretty sure you can use the OpenLayers WKT ...


2

The problem is caused by null inputs of the createSubType function. If you have a glance at the DataUtilities#createSubType you will see: public static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties, CoordinateReferenceSystem override, String typeName, URI namespace) throws SchemaException { if ((...


2

The easy way is to go with option 2 and the URL it wants is the location of the XSD file which will be in the top of the GML that is within your ServletRequest. So you need to open the root element and extract the namespaces and schema URLs. Then you can create the name and URL from that: GML gml = new GML(Version.WFS1_0); gml.setCoordinateReferenceSystem( ...


2

Short answer: Your feature type doesn't match the Shapefile standard so the illegal bits get dropped by GeoTools. I have a utility class to fix this - try { String url = "geojson.json"; File geojson = new File(url); File shpFile = new File("test.shp"); ShapefileDataStoreFactory dataStoreFactory = new ...


2

JTS saved the day! I wrote my own subroutine to do this by recursively subdividing a big geometry into pieces until each piece is less than a user-specified size. It goes like this: public static Collection<Geometry> split(Geometry g, int maxSize, int maxPieces) { if (maxSize < 1000) { throw new ...


2

As you surmise you need to change the schema. As schema are immutable you need to copy the existing schema into a new one changing the name of the geometry attribute. You will need something like: public boolean writeFeatures( FeatureCollection<SimpleFeatureType, SimpleFeature> features) { if (shpDataStore == null) { throw new ...


2

I just checked with the developers and in the GeoServer version you are using there is no support for coordinate reference systems other than WGS84. This has been added on the 2.8.x series along with some other improvements, you can get a decent summary here. I would suggest to test with a more recent version and let us know. Regards, Simone.


2

I'm still a little unclear on what you are trying to do but if all you need is to simply reproject the native bounds to WGS84 (as GeoServer does) then the following code will work for you: String wkt = "PROJCS[\"unnamed\"," + " GEOGCS[\"WGS 84\"," + " DATUM[\"WGS_1984\"," + " SPHEROID[\"WGS 84\",6378137,298....


2

The KML Encoder (like most of GeoTools) works with features not geometries so you need to wrap your polygon in a feature, this gives you the opportunity to add some attributes to make your KML more useful too. public static void main(String[] args) throws IOException { File t = new File("test1.kml"); SimpleFeatureTypeBuilder builder = new ...


2

The geometry column of a ShapeFile must be called "the_geom", your's is called "location" so the ShapefileWriter ignores it. change SimpleFeatureType featureType = DataUtilities.createType( tipoShape, "location:" + tipoShape + ":srid=4326," + "number:Integer"); to SimpleFeatureType featureType = DataUtilities.createType( tipoShape, "the_geom:" + ...


1

Solved: I must use the source CRS from the GDALINFO output, since it is a custom reference. And the Target CRS is the EPSG4326. And then: DirectPosition dpLc = env.getLowerCorner(); DirectPosition dpUc = env.getUpperCorner(); DirectPosition destLc = new DirectPosition2D(); DirectPosition destUc = new DirectPosition2D(); MathTransform transform = CRS....


1

It looks like it could be a Cygwin/Windows 7 issue as the build is fine on my machine (Linux/Oracle JDK 1.8). I'm a little confused as to why you would use cygwin to control the build, as one of the joys of JAva is it works even on windows (as does Maven). [INFO] ------------------------------------------------------------------------ [INFO] Reactor ...


1

Well, the behavior is the expected one, check the javadocs of the underlying JAI operation here. You are multiplying a byte image with a palette (hence it is single band) for a float/image what you get is a float image and the palette is lost since it would not make sense anymore. What are trying to do exactly?


1

Not that it solves your geoserver problem, but I'm seeing a discrepancy in your projection description. Above you say standard parallels are at 30N and 60N, but the projection description in the dataset has a single standard parallel at 25N. Is the mapped area intended to be in southeast Nebraska?


1

Looks like it moved to the CRS utility class as equalsIgnoreMetadata


1

JTS's DistanceOP#nearestPoints might be an easy way. I have not tested it. http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/operation/distance/DistanceOp.html#nearestPoints%28com.vividsolutions.jts.geom.Geometry,%20com.vividsolutions.jts.geom.Geometry%29 Compute the the nearest points of two geometries. The points are presented in the same ...


1

You can define a local rotated coordinate sytem as I explained here: Using customized Coordinate System for Archaeological site data Center point and rotation have to be defined in degrees. Your idea of wrapping one projection with another is not defined in PROJ.4. You can try it out, but don't expect it to work.


1

For the ID simply pass it in to the featureBuilder instead of null; For other properties you need to modify the schema you generated the featureBuilder with. The easiest way to do this is to use DataUtilities.createType SimpleFeatureType TYPE = DataUtilities.createType("Test", "ian:String,location:Point"); final Point point = builder.point(132.159633, ...


1

@whuber's assertion that an equal-area projection "will give absolutely correct areas" comes with an asterisk, namely, assuming that the edges of the polygon are straight lines in said projection. This is often a good approximation, particularly if the edges are short; but it is rarely strictly true. If, on the other hand, the edges of your polygon are ...


1

The answer to your question seems to be code like: private FeatureEntry createFeatureEntry(SimpleFeatureType schema, ReferencedEnvelope bbox) { FeatureEntry ret = new FeatureEntry(); ret.setGeometryColumn(schema.getGeometryDescriptor().getLocalName()); GeometryType type = schema.getGeometryDescriptor().getType(); Geometries ...


1

Oracle Spatial comes with a collection of Java APIs, and one of them lets you read shapefiles. That API is documented here: http://docs.oracle.com/database/121/SPAJV/toc.htm. Look for the oracle.spatial.util package, specifically class ShapefileFeatureJGeom. It uses lower level classes that perform the actual reading of the shapefile (DBFReaderJGeom and ...



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