Adding points to a shp file

Trimble, Beheen btrimble at SFWMD.GOV
Tue Oct 10 07:58:31 EDT 2006


What is the coordinate of your new points? Are you adding (1,1,0)? Is
the unit understood by ogr? The problem usually is among extent,
projection and spatial reference! See if mapscript has any of these
types of functions. The extent shown, below, by grinfo is not promising.


B

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu] On
Behalf Of mikiet
Sent: Tuesday, October 10, 2006 7:14 AM
To: MAPSERVER-USERS at lists.umn.edu
Subject: [UMN_MAPSERVER-USERS] Adding points to a shp file

Hi there, 

I am using java mapscript and have a requirement to add some points to
an
ESRI shape file (bear with me here, I'm a mapinfo man). I'm using an
ESRI
shape file that came with the ms101 tutorial WorldCities.shp. Its
definitly
a point shape file as when I run ogrinfo on it I get 

Layer name: worldCities
Geometry: Point
Feature Count: 0
Extent: (0.000000, 0.000000) - (0.000000, 0.000000)
Layer SRS WKT:
(unknown)
ID: Integer (6.0)
ATTRIB: Integer (4.0)
MGCC: Integer (4.0)
ADMIN_CODE: Integer (4.0)
UFI: Integer (9.0)
POPULATION: Integer (9.0)
NAME: String (250.0)

I have created a simple class to add a point to this file, see below,
the
code runs without error however no feature is added to the file, I'm
sure
its a simple fix but can anyone point me in the right direction please ?

    public static void test(){
   	 try {
   		System.out.println("starting run....");
		shapeObj shape = new
shapeObj(mapscript.MS_SHAPEFILE_POINT);
		lineObj lo = new lineObj();
		pointObj po = new pointObj(1d,1d,0d);
		lo.add(po);
		shape.add(lo);
		String shapeFullPath =
"C:\\ms4w\\apps\\ms101\\data\\shapefile\\WorldCities.shp";
		shapefileObj shapefile = new shapefileObj(shapeFullPath,
mapscript.MS_SHAPEFILE_POINT);
		shapefile.add(shape);
		System.out.println("Shape added");
    } catch (Exception e) {
    	e.printStackTrace();
    }
    }
-- 
View this message in context:
http://www.nabble.com/Adding-points-to-a-shp-file-tf2415928.html#a673434
3
Sent from the Mapserver - User mailing list archive at Nabble.com.



More information about the mapserver-users mailing list