[fdo-users] Shapefile and spatial context

hanko hana.jaborova at spatialtechnology.se
Fri Jun 11 03:59:43 EDT 2010

According to wikipedia:

Shapefile projection format (.prj)

The projection information contained in the .prj file is critical in order
to understand the data contained in the .shp file correctly. 
Although it is technically optional, it is most often provided, as it is not
necessarily possible to guess the projection of any given points. 
The file is stored in well-known text (WKT) format.

Some typical information contained in the .prj file is:
    * Geographic coordinate system
I create a new spatial context
Then I create a new chema with a few Feature Classes.
I set geom.SpatialContextAssociation = newSpatialContext.Name; 

When I apply schema for every Feature Class are created a bunch of files
with the same name as Feature Class (shp, shx, idx, dbf, cpg).
I wonder why is not a PRJ file created for each Feature Class automatically.	

private void CreateSpatialContext()
	string wkt = "GEOGCS [ \"Longitude / Latitude (WGS 84)\", DATUM [\"WGS
84\", SPHEROID [\"WGS 84\", 6378137, 298.257223563]], PRIMEM [
\"Greenwich\", 0.000000 ], UNIT \"Decimal Degree\", 0.01745329251994330]]";

	using (ICreateSpatialContext create =
as ICreateSpatialContext)
		using (FgfGeometryFactory geomFactory = new FgfGeometryFactory())
			DirectPositionImpl lowerLeft = new DirectPositionImpl();
			lowerLeft.X = -180.0;
			lowerLeft.Y = -90.0;
			DirectPositionImpl upperRight = new DirectPositionImpl();
			upperRight.X = 180.0;
			upperRight.Y = 90.0;
			create.CoordinateSystemWkt = wkt;
			create.Description = "This Coordinate System is used for GPS.";
			create.ExtentType =

			IEnvelope envelope = geomFactory.CreateEnvelope(lowerLeft, upperRight);
			IGeometry geom = geomFactory.CreateGeometry(envelope);
			create.Extent = geomFactory.GetFgf(geom);
			create.Name = _spatialContext;
			create.UpdateExisting = false;
			create.XYTolerance = 0.001;
			create.ZTolerance = 0.001;
			if (geom != null)


I create a file containing the WKT text.
TextWriter MyStream = null;
string prjFile = @"C:\Temp\SHP\Ship.prj";
MyStream = File.CreateText(prjFile);


Cheers Hanko
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Shapefile-and-spatial-context-tp5166854p5166854.html
Sent from the FDO Users mailing list archive at Nabble.com.

More information about the fdo-users mailing list