数据转换中遇到的问题

以下是数据转换中存在的一些问题和解决(部分)

1.把shp文件导入postgis数据库中(非使用shp2pgsql.exe),shp中为polygon类型,转换到数据库则为multipolygin

                        CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
			
                        SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
			SimpleFeatureType schema = shpDataStore.getSchema(fileName);
			builder.setName(fileName);
			builder.setCRS(crs);
			for (AttributeDescriptor descriptor : schema.getAttributeDescriptors()) {
				if (descriptor instanceof GeometryDescriptor) {
					builder.add(descriptor);
				}
			}
			SimpleFeatureType simpleFeatureType = builder.buildFeatureType();
			try {
				dataStore.createSchema(simpleFeatureType);
			} catch (Exception e) {
				System.out.println(e.getLocalizedMessage());
			}

  上网Google了下:http://n2.nabble.com/Polygon-or-MultiPolygon-this-is-the-question-td2951547.html

写道
> If I create a feature which is Polygon and save it to the shape file
> (using ShapefileDataStore), then when I read it back it comes as a
> MultiPolygon. If I create a feature as a LineString and save it to the
> shape file , then when I read it back it comes as a MultiLineString.
>
> Could anyone explain that to me please, I am not getting it?
« [hide part of quote]

Shapefiles do not have the concept of plain linestrings or plain
polygons, the have just one type that can contain both multiple
and simple geometries, but there is no way to tell what is actually
stored (unless, of course, one does not try to read the entire
shapefile just to determine that information, which would be
prohibitively expensive).

So the only safe approach is to always use multi geometries no
matter what.
 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值