Tag Info

Hot answers tagged

14

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


9

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


7

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


5

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


4

You need to import the GeoJSON plugn <dependency> <groupId>org.geotools</groupId> <artifactId>gt-geojson</artifactId> <version>${geotools.version}</version> </dependency> and then call it like this (a full example is here): public String geoData() { final GeometryBuilder builder = new ...


3

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


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

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


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

I had same problem. I solved the problem. My solution: StringBuffer tmpStr = new StringBuffer(); tmpStr.append("ID,date,tstamp,X_prj,Y_prj,NEAR_FID,NEAR_DIST\n"); SimpleFeature f = null; int index = 0; String ID = null; while(simpleFeatureIterator.hasNext()){ f = simpleFeatureIterator.next(); index = f.getID().lastIndexOf('.'); ...


2

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


2

HttpServletRequest request=...; org.geotools.xml.parser.Parser parser = new Parser(new org.geotools.wfs.v1_1.WFSConfigration()); TransactionType tt = (TransactionType) parser.parse(request.getReader()); InsertElementType insert1 = (InsertElementType) tt.getInsert().get(0);


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.


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

You can check the code out of the repository and do pretty much anything you like with it. You might also want to look at the GeoTools code that underlies much of the GeoServer code. GeoServer code is licensed under the GPL - so there are some restrictions on what you can do with it, mostly related to releasing programs without releasing your changes to ...


1

The dataset use Pan-European mapping standard projection system - EPSG3035 If you are open to non-java tool and simplicity, you will be able to reproject the file to WGS84 using GDAL/OGR : http://www.gdal.org/, that way : ogr2ogr -f "ESRI Shapefile" path/to/NUTSV9_LEAC.shp NUTSV9_LEAC_wgs84.shp -s_srs EPSG:3035 -t_srs EPSG:4326


1

New York State Plane Long Island is the state plane zone used for NYC. Its EPSG Code is 2263, units are in feet, and it uses Lambert Conformal Conic. Despite Long Island being in the name, it does cover NYC and is used by all the city agencies here that produce GIS data (Dept City Planning, DOITT, etc - for example all data provided here uses that system: ...


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

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 gave up trying to find a maven repository to resolve the classes that geoserver's example POM file shows as well as a general way find either geotools or geoserver's correct current maven repository information when I ran into monstrosities such as this because I did not want to download / develop against all of geoserver's sources. I ended up downloading ...


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



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