[mapserver-users] shape file extent

Vinko Vrsalovic v at w.cl
Mon Feb 4 16:56:07 PST 2002


On Mon, Feb 04, 2002 at 01:14:50PM -0500, Shaik Anwar Hussain wrote:
> Hi List,
> 
>          Does any one know how to get the extent of a selected shape file. 
> 

ArcView: View->Properties->Area of Interest->Theme

AcrExplorer: Don't know how, but must be very similar to arcview.

PHP MapScript: 
<?php

	dl ('php_mapscript.so');

	$shapef = ms_newShapefileObj("/your_dir/your_file_without_extension",
			-1);
			
	for ($i=0;$i<$shapef->numshapes;$i++) {

		$extent = $shapef->getExtent($i);

		echo "$i.- MINX $extent->minx ";
		echo "MINY $extent->miny ";
		echo "MAXX $extent->maxx ";
		echo "MAXY $extent->maxy \n<br>\n";

	}

	$shapef->free();
?>

(From that output you should select the lowest minx and miny and the
highest maxx and maxy for you to use as a global extent for that
shapefile, that should be easy to obtain from the script above)

You can translate this to perl if you like and run it from the console.

I seem to recall that in some of the examples of Perl mapscript (from
the source tree: mapserver/mapscript/perl/examples) there was a perl
script that did exactly that.

-- 
V. <v at w.cl>



More information about the MapServer-users mailing list