[postgis-users] SRID for analyzing a USA national data set in Meters

Pedro Doria Meunier pdoria at netmadeira.com
Mon Apr 2 06:29:42 PDT 2007


Hello Michael,

You determine the correct SRID with this bit of code (PHP):
(the $loc was obtained from a SELECT with the astext(geometry) function)

The idea behind this is summarized in the UtmZoneFromLong() function.
Pick a Long value and calculate the utm zone for it.
Then use the SridFromUtmZone() function to get the srid from the given mask
(see below) --> this queries spatial_ref_sys with the calculated $utm param.
SELECT srid FROM spatial_ref_sys WHERE srtext LIKE 'PROJCS[\"WGS 84 / UTM
zone $utm%' LIMIT 1

// extract the POINT geometry
$geometry = str_replace("POINT(","", $loc);
$geometry = str_replace(")","",$geometry);
$coordinate = explode(" ",$geometry);
$lon=$coordinate[0];
$lat=$coordinate[1];

// get utm zone from coordinates
$utm=UtmZoneFromLong($lon);
// get srid from the spatial_ref_sys table for the given utm zone
// add N or S
if($lat>=0) $utm.="N";
else $utm.="S";
$srid=SridFromUtmZone($utm, $connection);


// determine UTM zone from LonLat coordinates
// params $long: longitude
// returns (int) utm
function UtmZoneFromLong($lon) {
	$utm = floor(($lon + 180) / 6) + 1;
	return $utm;
}

// query the spatial_ref_sys table for the srid of the given utm zone
// params $utm: utm zone string (MUST BE TRAILED WITH 'N' OR 'S'!), $conn:
connection to the db
// returns (int) srid
function SridFromUtmZone($utm, $conn){
$myresult = pg_exec($conn, "SELECT srid FROM spatial_ref_sys WHERE srtext
LIKE 'PROJCS[\"WGS 84 / UTM zone $utm%' LIMIT 1");
$srid=pg_result($myresult, 0, 0);
return $srid;
}

HTH,
Pedro Doria Meunier

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of mfrumin
Sent: segunda-feira, 2 de Abril de 2007 14:12
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] SRID for analyzing a USA national data set in
Meters


I have a data set that includes points all over the United States in lat/lng
(say, SRID = 4326) but I need to do some analysis on these data in real
units, say meters.  So, my task is to select an appropriate SRID that will
work reasonably well for the whole USA to reproject lat/lng into meters.  
There are a bazillion SRID's available. Any suggestions?

This analysis doesn't have to be super-precise, so I'm not so concerned with
the limitations of a national projection (as opposed to state/region).

thanks,
Michael

-- 
View this message in context:
http://www.nabble.com/SRID-for-analyzing-a-USA-national-data-set-in-Meters-t
f3505664.html#a9790471
Sent from the PostGIS - User mailing list archive at Nabble.com.

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-users mailing list