Tag Info

Hot answers tagged

13

Answer can be found from the official specification http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf. All the non-Null shapes in a shapefile are required to be of the same shape type. The values for shape type are as follows: Value Shape Type 0 Null Shape 1 ...


8

A shapefile does not support mixed geometry. A shapefile either consists of points, polylines or polygons, but not more than one. See this article for more: Shapefiles


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

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


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

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

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


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)


2

I would check the tests in github, here. That said I would say you should look into optimized (big)tiff support. Check these slides which are made for GeoServer but still usable for your case I believe. http://goo.gl/74XUPq Simone.


1

Usually you would ask the features to give you their schema using: SimpleFeatureType schema = collection.getSchema(); You can then use that to generate the Oracle schema to write the data into.


1

In general it's better to use the return type you've declared rather than rely on exceptions, so something like this may work better: public boolean openShapeFile() { try { File dataFile = new File(fileName); dataStore = new ShapefileDataStore(dataFile.toURL()); SimpleFeatureSource source = dataStore.getFeatureSource(); ...


1

The first thing to realise is that GML is a transport/Exchange format you are not really supposed to work directly with it, so the usual thing to do is import it into a spatial database (usually PostGIS) there are plenty of tools to do this both open source and proprietary - see this question for one answer. Secondly, no one should be writing WMS and WFS ...


1

Ciao, I would probably look at the clip process which is part of process-vector. Examples here: enter link description here


1

I don't think that GeoTools can manage this out of the box. But the code shouldn't be too hard to knock up to handle your use case. The Image Tutorial will get you started with reading in and writing out geotiffs. There is certainly tiling code available in the new GeoPackage module that might already do what you need. You might also find JAITools (a ...


1

Ian's answer is correct, and I have marked it as such. For the sake of completeness for anyone else that might be interested... Question 1 No, you do not have to manually reproject layers. Specifying the projection on the viewport should suffice. Example: MapViewport vp = map.getViewport(); CoordinateReferenceSystem crs = ...


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

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

DataStoreFinder is depricated in new versions. And the tutorial you mentioned is an old tutorial. You can code in the following manner: String getCapabilities = "http://localhost:8081/geoserver/wfs?REQUEST=GetCapabilities&version=1.0.0"; Map connectionParameters = new HashMap(); connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL", ...


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.



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