我有兴趣为2009年Tiger/Line Shapefiles中的道路数据编写可视化程序.我想绘制线数据来显示我县的所有道路.
ESRI Shapefile或简单的shapefile是用于地理信息系统软件的流行的地理空间矢量数据格式.它由ESRI开发和监管,作为ESRI和其他软件产品之间数据互操作性的(主要)开放式规范.1 "shapefile"通常是指带有".shp",".shx",".dbf"的文件集合,以及公共前缀名称上的其他扩展名(例如"lakes.*").实际的shapefile特别涉及具有".shp"扩展名的文件,但是这个文件本身不完整,因为需要其他支持文件.
有没有人知道用于解析和读取Shapefiles的行数据的现有库?
有没有人知道在Java中将地球表面位置从lat,lon转换为UTM(比如WGS84)?我目前正在研究Geotools,但遗憾的是解决方案并不明显.
寻找一个java实用程序.如果您可以使用geotools库告诉我如何使用它,那就更好了.
POM是
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.geotools</groupId>
<artifactId>tutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tutorial</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>10-SNAPSHOT</geotools.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
</repositories>
</project>
Run Code Online (Sandbox Code Playgroud)
我收到错误:
[ERROR] Failed to execute goal on project tutorial: Could not resolve dependencies for project org.geotools:tutorial:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: org.geotools:gt-shapefile:jar:10-SNAPSHOT, org.geotools:gt-swing:jar:10-SNAPSHOT: Could not …
我正在使用geotools从shapefile中提取数据并将它们存储到mysql中.我的应用程序一直在工作,但我经常得到这个锁,我无法理解为什么,因为它仍然有效
[root@website-qc filespool]# /usr/bin/java -jar /opt/mcmap/library/Application/geotools/mcgeotools.jar -t publisher -i 1/194/Namibia_SCLB12.shp -rid 12 -s
app get cmd option cast to int: 12
app passing region id to runconvert: 12
runconvert rid passed: 12
Jul 9, 2012 4:23:48 PM org.geotools.data.db2.DB2DataStoreFactory isAvailable
INFO: DB2 driver found: true
Database connection acquired
Coordinates length: 5390
Coordinates length: 5358
Coordinates length: 9932
Jul 9, 2012 4:28:14 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock? read on file:/opt/mcmap/public/filespool/1/194/Namibia_SCLB12.prj by org.geotools.data.shapefile.prj.PrjFileReader
it was created with …Run Code Online (Sandbox Code Playgroud) 我在Apache Storm中运行Geotools,并且在geotools依赖管理方面有一段时间.当我在本地运行风暴集群(Windows 7笔记本电脑)时,每件事都有效,但当我部署到集群时,我在日志中遇到此异常.
编辑:这是我使用的Java调用此功能
GridCoverage2D image =
new GeoTiffReader(f).read(new GeneralParameterValue[]{policy, gridsize, useJaiRead});
/**
* reproject to WGS84
*/
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
GridCoverage2D reprojectedImage = (GridCoverage2D) Operations.DEFAULT.resample(image, targetCRS);
Run Code Online (Sandbox Code Playgroud)
这是我的环境
geotools 11.1
java 7
POM is below
running on windows 7 when in local mode (works perfectly here)
this problem happens on Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-63-virtual x86_64)
here's the exception from the log
[ERROR] Exception in Bolt org.geotools.data.DataSourceException: GEOTIFF Module Error Report
No code "EPSG:32637" from authority "EPSG" found for …Run Code Online (Sandbox Code Playgroud) 首先,我是GIS的新手,所以请原谅任何错误.我需要发现纬度和经度点与纬度/经度多边形(常规或非常规)之间的距离.确切地说,我需要发现从给定点到多边形边界中的点的最小距离,如下所示.在该示例中,从点p到多边形的距离越近d.注意:我不需要点,只需要最小距离.
经过一些阅读,我使用GeoTools API提出了以下最低工作示例.但是,我认为我搞砸了输出.谁能让我知道如何在mteres中获得点和多边形之间的最小距离?
MWE.java:
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Point;
public class MWE {
public static void main(String[] args) throws Exception {
GeometryFactory gf = JTSFactoryFinder.getGeometryFactory();
Coordinate[] c = new Coordinate[5];
c[0] = new Coordinate(-49.242986, -16.662430);
c[1] = new Coordinate(-49.241999, -16.664465);
c[2] = new Coordinate(-49.239146, -16.663828);
c[3] = new Coordinate(-49.239832, -16.661443);
c[4] = new Coordinate(-49.242986, -16.662430);
Geometry geo = gf.createPolygon(c);
Point p = gf.createPoint(new Coordinate(-49.246870, -16.665493));
double distance = geo.distance(p);
System.out.println("Distance: " + distance); …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个Java库来显示来自各种来源的地图数据,包括shapefile,WMS,WFS,谷歌地图,可能还有ArcIMS等.看起来OpenLayers是最接近我想要的东西,除了它是一个JavaScript库,并且我正在写一个Swing应用程序.
GDAL看起来很有希望,但据我所知,在未来"某个时间"之前不会有Java绑定.
为了清楚起见,我正在寻找一个可用于显示来自多个地图服务器/源的地图的Java API.
有谁知道这样的事情是否存在,如果没有,从哪里开始?我应该在GeoTools之上构建这个API吗?要么...
我们正在构建一个上传包含ESRI-shapefile的zip文件的服务.该服务应该能够读取shapefile并对其内容进行处理.所以我构建了一个将zip文件解压缩到临时文件夹(System.getProperty("java.io.tmpdir")的子文件夹)的类.
另一个类从Unzip-class调用unzip方法,然后尝试使用Geotools读取解压缩的shapefile.它使用Geotools DataStoreFinder.getDataStore(Map params)方法从解压缩的shapefile创建数据存储区.这里出现问题:getDataStore-method返回null.我测试了URL,它看起来很好.URL所源自的文件是一个文件,可以由应用程序读取(使用shapefile.exists(),shapefile.isFile(),shapefile.canRead()进行测试).那么,可能出现什么问题呢?为什么我返回null?
这是(相关)代码:
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.geodan.equus.entity.dataset.BasicFeature;
import com.geodan.equus.exception.EquusException;
import com.geodan.equus.processor.EquusProcessor;
import com.geodan.util.io.UnzipUtils;
import com.vividsolutions.jts.geom.Geometry;
public class ShapefileProcessor implements EquusProcessor
{
private static final File TEMP_UNZIP_DIR = new File(
System.getProperty("java.io.tmpdir") + File.separator
+ "atlas_temp_unzip_dir");
public static Set<BasicFeature> importFeatures(final File zipFile)
throws EquusException
{
// Check if the input file has the zipfile …Run Code Online (Sandbox Code Playgroud) 我最近开始使用GeoTools开始我的第一个程序,其中我也使用JAI-Java Advanced Imaging 1_1_2_01和JDK 1_7.它工作正常,直到我添加了GeoTiff Jars.我发现以下错误
线程"main"中的异常java.lang.NoClassDefFoundError:无法在com.rgb.PixelExtractor.extract的org.geotools.gce.geotiff.GeoTiffReader.read(GeoTiffReader.java:607)初始化类javax.media.jai.JAI (PixelExtractor.java:55)at com.rgb.RGBSpliter.main(RGBSpliter.java:136)
守则如下
public void extract(File f, String name, String date) throws Exception {
ParameterValue<OverviewPolicy> policy = AbstractGridFormat.OVERVIEW_POLICY
.createValue();
policy.setValue(OverviewPolicy.IGNORE);
// this will basically read 4 tiles worth of data at once from the disk...
ParameterValue<String> gridsize = AbstractGridFormat.SUGGESTED_TILE_SIZE.createValue();
//gridsize.setValue(512 * 4 + "," + 512);
// Setting read type: use JAI ImageRead (true) or ImageReaders read methods (false)
ParameterValue<Boolean> useJaiRead = AbstractGridFormat.USE_JAI_IMAGEREAD.createValue();
useJaiRead.setValue(true);
//reader.read(new GeneralParameterValue[] { policy, gridsize, useJaiRead }); …Run Code Online (Sandbox Code Playgroud)